setup.py sdist: store version into the archive

This commit is contained in:
Jérôme Schneider 2013-08-13 17:31:57 +02:00
parent 3e6deecb21
commit ae561db332
2 changed files with 29 additions and 9 deletions

View File

@ -6,3 +6,4 @@ recursive-include compte_agglo_montpellier/apps/feed_plugin/templates *.html
recursive-include compte_agglo_montpellier/apps/feed_plugin/locale *.po *.mo
include local_settings.py.example
include requirements.txt
include VERSION

View File

@ -1,11 +1,15 @@
#! /usr/bin/env python
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
import glob
class compile_translations(Command):
description = 'compile message catalogs to MO files via django compilemessages'
@ -18,8 +22,6 @@ class compile_translations(Command):
pass
def run(self):
import os
import sys
try:
from django.core.management.commands.compilemessages import \
compile_messages
@ -39,18 +41,34 @@ class compile_translations(Command):
class build(_build):
sub_commands = [('compile_translations', None)] + _build.sub_commands
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')
class install_lib(_install_lib):
def run(self):
self.run_command('compile_translations')
_install_lib.run(self)
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
@ -114,5 +132,6 @@ setup(name="compte-agglo-montpellier",
'git+git://repos.entrouvert.org/portail-citoyen-announces#egg=portail-citoyen-announces-0.1.99999',
],
cmdclass={'build': build, 'install_lib': install_lib,
'compile_translations': compile_translations},
'compile_translations': compile_translations,
'sdist': eo_sdist},
)