setup.py: add VERSION in bdist_wheel

This commit is contained in:
Benjamin Dauvergne 2019-08-23 16:10:27 +02:00
parent b072583917
commit efe821b5e7
1 changed files with 20 additions and 1 deletions

View File

@ -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,
})