From 762cd93c6d4cd8316b7936a08936c272446d34d7 Mon Sep 17 00:00:00 2001 From: Emmanuel Cazenave Date: Mon, 15 Jul 2019 18:02:43 +0200 Subject: [PATCH] packaging: write version in VERSION file (#34881) --- MANIFEST.in | 1 + setup.py | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 8f1adec..584d698 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,4 @@ recursive-include django_journal/locale *.po *.mo recursive-include django_journal/static *.css *.png include MANIFEST.in include README.rst +include VERSION diff --git a/setup.py b/setup.py index f5747ed..c5e625e 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ import sys from setuptools import setup, find_packages from setuptools.command.install_lib import install_lib as _install_lib from distutils.command.build import build as _build -from setuptools.command.sdist import sdist as _sdist +from setuptools.command.sdist import sdist from distutils.cmd import Command @@ -60,16 +60,25 @@ class build(_build): sub_commands = [('compile_translations', None)] + _build.sub_commands -class sdist(_sdist): - sub_commands = [('compile_translations', None)] + _sdist.sub_commands - - class install_lib(_install_lib): def run(self): self.run_command('compile_translations') _install_lib.run(self) +class eo_sdist(sdist): + def run(self): + if os.path.exists('VERSION'): + os.remove('VERSION') + version = get_version() + version_file = open('VERSION', 'w') + version_file.write(version) + version_file.close() + sdist.run(self) + 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. @@ -112,7 +121,7 @@ setup(name='django-journal', 'build': build, 'install_lib': install_lib, 'compile_translations': compile_translations, - 'sdist': sdist, + 'sdist': eo_sdist, 'test': test }, install_requires=[