setup.py sdist: store version into the archive
This commit is contained in:
parent
8b78025995
commit
4f18903bdb
|
@ -1 +1,2 @@
|
|||
include VERSION
|
||||
recursive-include entrouvert/djommon/locale *.po *.mo
|
||||
|
|
33
setup.py
33
setup.py
|
@ -3,12 +3,15 @@
|
|||
''' Setup script for python-entrouvert
|
||||
'''
|
||||
|
||||
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):
|
||||
|
@ -22,8 +25,6 @@ class compile_translations(Command):
|
|||
pass
|
||||
|
||||
def run(self):
|
||||
import os
|
||||
import sys
|
||||
try:
|
||||
from django.core.management.commands.compilemessages import \
|
||||
compile_messages
|
||||
|
@ -43,17 +44,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.close()
|
||||
return version
|
||||
for d in glob.glob('*'):
|
||||
if not os.path.isdir(d):
|
||||
continue
|
||||
|
@ -97,5 +115,6 @@ setup(name="python-entrouvert",
|
|||
],
|
||||
dependency_links=[],
|
||||
cmdclass={'build': build, 'install_lib': install_lib,
|
||||
'compile_translations': compile_translations,},
|
||||
'compile_translations': compile_translations,
|
||||
'sdist': eo_sdist},
|
||||
)
|
||||
|
|
Reference in New Issue