From 4b636b40842ac59e7d8f35475534187043169a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 13 Aug 2013 17:26:09 +0200 Subject: [PATCH] setup.py sdist: store version into the archive --- MANIFEST.in | 1 + setup.py | 35 ++++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index b2fc327..f2116fa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ recursive-include portail_citoyen_announces/locale *.po *.mo recursive-include portail_citoyen_announces/templates *.html *.txt recursive-include portail_citoyen_announces/static *.js *.css *.gif *.png *.jpg +include VERSION diff --git a/setup.py b/setup.py index ff9a731..557eb5d 100755 --- a/setup.py +++ b/setup.py @@ -3,10 +3,15 @@ ''' Setup script for portail-citoyen-announces ''' +import glob +import re +import sys +import os + 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 distutils.command.sdist import sdist as _sdist +from distutils.command.sdist import sdist from distutils.cmd import Command class compile_translations(Command): @@ -20,8 +25,6 @@ class compile_translations(Command): pass def run(self): - import os - import sys from django.core.management.commands.compilemessages import \ compile_messages for path in ['portail_citoyen_announces']: @@ -42,12 +45,29 @@ class install_lib(_install_lib): self.run_command('compile_translations') _install_lib.run(self) +class eo_sdist(sdist): + + 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() + sdist.run(self) + print "removing VERSION file" + if os.path.exists('VERSION'): + os.remove('VERSION') + def get_version(): - import glob - import re - import os version = None + if os.path.exists('VERSION'): + version_file = open('VERSION', 'r') + version = version_file.read() + version_file.close() + return version for d in glob.glob('*'): if not os.path.isdir(d): continue @@ -90,5 +110,6 @@ setup(name="portail_citoyen_announces", ], dependency_links=[], cmdclass={'build': build, 'install_lib': install_lib, - 'compile_translations': compile_translations}, + 'compile_translations': compile_translations, + 'sdist': eo_sdist}, )