From efe821b5e748e9629e2d1b27fdad91135daad84b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 23 Aug 2019 16:10:27 +0200 Subject: [PATCH] setup.py: add VERSION in bdist_wheel --- setup.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 437dd15..af0fd8a 100755 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ import os from setuptools import setup, find_packages from setuptools.command.sdist import sdist +from wheel.bdist_wheel import bdist_wheel class eo_sdist(sdist): @@ -22,6 +23,21 @@ class eo_sdist(sdist): os.remove('VERSION') +class eo_bdist_wheel(bdist_wheel): + def run(self): + print("creating VERSION file") + if os.path.exists('VERSION'): + os.remove('VERSION') + version = get_version() + version_file = open('VERSION', 'w') + version_file.write(version) + version_file.close() + super(eo_bdist_wheel, self).run() + print("removing VERSION file") + if os.path.exists('VERSION'): + os.remove('VERSION') + + def get_version(): '''Use the VERSION, if absent generates a version with git describe, if not tag exists, take 0.0- and add the length of the commit log. @@ -74,4 +90,7 @@ setup(name="django-gssapi", 'static/js/*.js', ], }, - cmdclass={'sdist': eo_sdist}) + cmdclass={ + 'sdist': eo_sdist, + 'bdist_wheel': eo_bdist_wheel, + })