setup.py: prevent clobering of DJANGO_SETTINGS_MODULE when compiling messages (fixes #20666)
This commit is contained in:
parent
3ebef31d1e
commit
b6fa4e97b7
29
setup.py
29
setup.py
|
@ -1,17 +1,18 @@
|
|||
#!/usr/bin/python
|
||||
import os
|
||||
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 as _sdist
|
||||
from distutils.cmd import Command
|
||||
|
||||
|
||||
class test(Command):
|
||||
description = 'run django tests'
|
||||
user_options = []
|
||||
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
|
@ -39,24 +40,35 @@ class compile_translations(Command):
|
|||
pass
|
||||
|
||||
def run(self):
|
||||
import os
|
||||
from django.core.management import call_command
|
||||
curdir = os.getcwd()
|
||||
os.chdir(os.path.realpath('django_journal'))
|
||||
call_command('compilemessages')
|
||||
os.chdir(curdir)
|
||||
try:
|
||||
os.environ.pop('DJANGO_SETTINGS_MODULE', None)
|
||||
from django.core.management import call_command
|
||||
os.chdir(os.path.realpath('django_journal'))
|
||||
call_command('compilemessages')
|
||||
except ImportError:
|
||||
print
|
||||
sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
|
||||
print
|
||||
print
|
||||
finally:
|
||||
os.chdir(curdir)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
def get_version():
|
||||
import glob
|
||||
import re
|
||||
|
@ -113,5 +125,4 @@ setup(name='django-journal',
|
|||
],
|
||||
setup_requires=[
|
||||
'django >= 1.4.2',
|
||||
],
|
||||
)
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue