From bda3c7ebba9f65ab6e469a653e835013cdf760b2 Mon Sep 17 00:00:00 2001 From: Rico Date: Mon, 2 Sep 2019 22:53:30 +0200 Subject: [PATCH] TASK: Use the travis tag when building pypi package Forgot to update the version file to the latest version? No problem, use the travis tag instead! --- setup.py | 79 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/setup.py b/setup.py index 2116390..44097fa 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import os + from setuptools import setup, find_packages packages = find_packages(exclude=['tests*']) @@ -20,37 +21,47 @@ def requirements(): with open("README.md", "r", encoding="utf-8") as file: readme = file.read() -# Taken from https://packaging.python.org/guides/single-sourcing-package-version/ -version = {} -version_file = os.path.join('pastepwn', 'version.py') -with open(version_file, "r", encoding="utf-8") as file: - exec(file.read(), version) - - setup(name='pastepwn', - version=version['__version__'], - install_requires=requirements(), - keywords='python pastebin scraping osint framework', - description='Python framework to scrape PasteBin pastes and analyze them', - long_description=readme, - long_description_content_type='text/markdown', - url='https://github.com/d-Rickyy-b/pastepwn', - author='d-Rickyy-b', - author_email='pastepwn@rickyy.de', - license='MIT', - packages=packages, - include_package_data=True, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Security', - 'Topic :: Internet', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7' - ], ) +# If present, take tag from travis and not locally +travis_tag = os.environ.get("TRAVIS_TAG") + +if travis_tag is not None: + # Travis versions can look like 'v1.5.2' - pypi versions look like '1.5.2' + version = travis_tag.replace("v", "") +else: + # Taken from https://packaging.python.org/guides/single-sourcing-package-version/ + version_dict = {} + version_file = os.path.join('pastepwn', 'version.py') + with open(version_file, "r", encoding="utf-8") as file: + exec(file.read(), version_dict) + version = version_dict['__version__'] + +print("Building version {} of pastepwn".format(version)) + +setup(name='pastepwn', + version=version, + install_requires=requirements(), + keywords='python pastebin scraping osint framework', + description='Python framework to scrape PasteBin pastes and analyze them', + long_description=readme, + long_description_content_type='text/markdown', + url='https://github.com/d-Rickyy-b/pastepwn', + author='d-Rickyy-b', + author_email='pastepwn@rickyy.de', + license='MIT', + packages=packages, + include_package_data=True, + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Security', + 'Topic :: Internet', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7' + ], )