setup.py sdist: store version into the archive

This commit is contained in:
Jérôme Schneider 2013-08-13 17:26:09 +02:00
parent 5b9e5480c2
commit 4b636b4084
2 changed files with 29 additions and 7 deletions

View File

@ -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

View File

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