From aee0c692eff1c9ec54fb961111be49689698bc01 Mon Sep 17 00:00:00 2001 From: Davte Date: Fri, 19 Jul 2019 10:36:40 +0200 Subject: [PATCH] First release Added scripts to build package and upload it on pypi --- MANIFEST.in | 3 ++ ciclopibot/__init__.py | 2 +- setup.py | 74 ++++++++++++++++++++++++++++++++++++++++++ update_package.sh | 23 +++++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in create mode 100644 setup.py create mode 100644 update_package.sh diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b5c7522 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +exclude ciclopibot/data/* +include ciclopibot/data/__init__.py +include ciclopibot/data/help.json diff --git a/ciclopibot/__init__.py b/ciclopibot/__init__.py index 616db1e..7b8e250 100644 --- a/ciclopibot/__init__.py +++ b/ciclopibot/__init__.py @@ -3,6 +3,6 @@ __author__ = "Davide Testa" __email__ = "davide@davte.it" __license__ = "GNU General Public License v3.0" -__version__ = "1.0" +__version__ = "1.0.0" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..41e7491 --- /dev/null +++ b/setup.py @@ -0,0 +1,74 @@ +"""Setup.""" + +import codecs +import os +import re +import setuptools +import sys + +if sys.version_info < (3, 5): + raise RuntimeError("Python3.5+ is needed to run async code") + +here = os.path.abspath(os.path.dirname(__file__)) + + +def read(*parts): + """Read file in `part.part.part.part.ext`. + + Start from `here` and follow the path given by `*parts` + """ + with codecs.open(os.path.join(here, *parts), 'r') as fp: + return fp.read() + + +def find_information(info, *file_path_parts): + """Read information in file.""" + version_file = read(*file_path_parts) + version_match = re.search( + r"^__{info}__ = ['\"]([^'\"]*)['\"]".format( + info=info + ), + version_file, + re.M + ) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") + + +with open("README.md", "r") as readme_file: + long_description = readme_file.read() + +setuptools.setup( + name='ciclopibot', + version=find_information("version", "ciclopibot", "__init__.py"), + author=find_information("author", "ciclopibot", "__init__.py"), + author_email=find_information("email", "ciclopibot", "__init__.py"), + description=( + "Telegram bot based on `davtelepot` providing information about " + "CicloPi, the public bike-sharing service in Pisa." + ), + license=find_information("license", "ciclopibot", "__init__.py"), + long_description=long_description, + long_description_content_type="text/markdown", + url="https://gogs.davte.it/davte/ciclopibot", + packages=setuptools.find_packages(), + platforms=['any'], + install_requires=[ + 'davtelepot', + ], + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Framework :: AsyncIO", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Communications :: Chat", + ], + keywords='telegram bot python asyncio async aiohttp davtelepot ' + 'ciclopi bikesharing bicincitta bicincittà pisa bike', + include_package_data=True, +) diff --git a/update_package.sh b/update_package.sh new file mode 100644 index 0000000..a424042 --- /dev/null +++ b/update_package.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Get current directory +this_script_directory=$(cd `dirname $0` && pwd) + +# Python virtual environment directory: packenv variable in my_config.sh +source $this_script_directory/my_config.sh; + +# Ensure the success of importing procedure +if [ -z ${packenv} ]; +then + printf "Please set in ""my_config.sh"" the path to bot python virtual environment\n\nExample:\npackenv=""path/to/virtual/env""\n"; + exit; +fi + +# Merge, push, build and publish package to pypi.org +bash merge_and_push.sh; +rm -rf "$this_script_directory/build"; +rm -rf "$this_script_directory/dist"; +rm -rf "$this_script_directory/ciclopibot.egg-info"; +$packenv/python setup.py sdist; +$packenv/pip wheel --no-index --no-deps --wheel-dir dist dist/*.tar.gz; +$packenv/twine upload --skip-existing dist/*;