Skip to content

Commit c8eb459

Browse files
author
Alexander Smishlajev
committed
distutils.log is not available on Python 2.2 and below...
...use Command.announce instead. allow to specify unusual Python tools directory in build command options.
1 parent 2d25e94 commit c8eb459

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

setup.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: setup.py,v 1.66 2004-05-14 18:32:58 a1s Exp $
19+
# $Id: setup.py,v 1.67 2004-05-16 09:23:18 a1s Exp $
2020

21-
from distutils import log
2221
from distutils.core import setup, Extension
2322
from distutils.util import get_platform
2423
from distutils.command.build_scripts import build_scripts
@@ -143,26 +142,6 @@ def list_po_files():
143142
"share", "locale", _locale, "LC_MESSAGES", "roundup.mo")))
144143
return _list
145144

146-
def compile_po_files():
147-
"""Compile all .po files in locale directory"""
148-
# locate the tools directory
149-
if sys.platform == "win32":
150-
_share = sys.prefix
151-
else:
152-
_share = os.path.join(sys.prefix, "share",
153-
"python%i.%i" % sys.version_info[:2])
154-
# import message formatter
155-
sys.path.insert(0, os.path.join(_share, "Tools", "i18n"))
156-
import msgfmt
157-
# compile messages
158-
for (_po, _mo) in list_po_files():
159-
_mo = os.path.join("build", _mo)
160-
_dir = os.path.dirname(_mo)
161-
if not os.path.isdir(_dir):
162-
os.makedirs(_dir)
163-
log.info("Compiling messages in %r => %r", _po, _mo)
164-
msgfmt.make(_po, _mo)
165-
166145
def check_manifest():
167146
"""Check that the files listed in the MANIFEST are present when the
168147
source is unpacked.
@@ -186,9 +165,42 @@ def check_manifest():
186165

187166

188167
class build_roundup(build):
168+
169+
user_options = build.user_options + [
170+
("python-tools=", "p", "Python tools directory"),
171+
]
172+
173+
def initialize_options (self):
174+
build.initialize_options(self)
175+
self.python_tools = None
176+
177+
def finalize_options (self):
178+
build.finalize_options(self)
179+
if self.python_tools is None:
180+
if sys.platform == "win32":
181+
_share = sys.prefix
182+
else:
183+
_share = os.path.join(sys.prefix, "share",
184+
"python%i.%i" % sys.version_info[:2])
185+
self.python_tools = os.path.join(_share, "Tools")
186+
187+
def compile_po_files(self):
188+
"""Compile all .po files in locale directory"""
189+
# import message formatter
190+
sys.path.insert(0, os.path.join(self.python_tools, "i18n"))
191+
import msgfmt
192+
# compile messages
193+
for (_po, _mo) in list_po_files():
194+
_mo = os.path.join("build", _mo)
195+
_dir = os.path.dirname(_mo)
196+
if not os.path.isdir(_dir):
197+
os.makedirs(_dir)
198+
self.announce("Compiling messages in %r => %r" % (_po, _mo))
199+
msgfmt.make(_po, _mo)
200+
189201
def run(self):
190202
check_manifest()
191-
compile_po_files()
203+
self.compile_po_files()
192204
build.run(self)
193205

194206
#############################################################################

0 commit comments

Comments
 (0)