X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=setup.py;fp=setup.py;h=2c0c85642e9655d22c89377f4c91148ffd0d6053;hb=875dfd0d60099a9cef7445301aa19d9d3fab55e8;hp=5e7e9a34c11cf2ae712445ae79a43f9467b1672e;hpb=ff5717b37e73094a0d70187cce65d1e014196986;p=fdroidserver.git diff --git a/setup.py b/setup.py index 5e7e9a34..2c0c8564 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +from setuptools import Command from setuptools import setup import os import re @@ -7,6 +8,26 @@ import shutil import sys +class VersionCheckCommand(Command): + """Make sure git tag and version match before uploading""" + user_options = [] + + def initialize_options(self): + """Abstract method that is required to be overwritten""" + + def finalize_options(self): + """Abstract method that is required to be overwritten""" + + def run(self): + version = self.distribution.get_version() + version_git = subprocess.check_output(['git', 'describe', '--tags', '--always']).rstrip().decode('utf-8') + if version != version_git: + print('ERROR: Release version mismatch! setup.py (%s) does not match git (%s)' + % (version, version_git)) + sys.exit(1) + print('Upload using: twine upload dist/fdroidserver*.tar.gz*') + + def get_data_files(): # workaround issue on OSX or --user installs, where sys.prefix is not an installable location if os.access(sys.prefix, os.W_OK | os.X_OK): @@ -56,6 +77,7 @@ setup(name='fdroidserver', scripts=['fdroid', 'fd-commit', 'makebuildserver'], data_files=get_data_files(), python_requires='>=3.4', + cmdclass={'versioncheck': VersionCheckCommand}, install_requires=[ 'clint', 'GitPython',