1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

setup.py: add -s flag to sdist

Add -s flag to sdist command, which, when used, strips away the git
commit hash from the package version. This is needed for upload to PyPI.
This commit is contained in:
Sergei Trofimov 2018-07-06 17:09:09 +01:00 committed by Marc Bonnici
parent 34c6d1983b
commit 56f3b1c317

View File

@ -21,8 +21,10 @@ from itertools import chain
try: try:
from setuptools import setup from setuptools import setup
from setuptools.command.sdist import sdist as orig_sdist
except ImportError: except ImportError:
from distutils.core import setup from distutils.core import setup
from distutils.command.sdist import sdist as orig_sdist
devlib_dir = os.path.join(os.path.dirname(__file__), 'devlib') devlib_dir = os.path.join(os.path.dirname(__file__), 'devlib')
@ -110,4 +112,25 @@ params = dict(
all_extras = list(chain(iter(params['extras_require'].values()))) all_extras = list(chain(iter(params['extras_require'].values())))
params['extras_require']['full'] = all_extras params['extras_require']['full'] = all_extras
class sdist(orig_sdist):
user_options = orig_sdist.user_options + [
('strip-commit', 's',
"Strip git commit hash from package version ")
]
def initialize_options(self):
orig_sdist.initialize_options(self)
self.strip_commit = False
def run(self):
if self.strip_commit:
self.distribution.get_version = lambda : __version__.split('+')[0]
orig_sdist.run(self)
params['cmdclass'] = {'sdist': sdist}
setup(**params) setup(**params)