Mercurial > p > roundup > code
comparison setup.py @ 2316:f8a4c51e5847
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.
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Sun, 16 May 2004 09:23:18 +0000 |
| parents | bf3d44f6b91e |
| children | 804c5c735bf1 |
comparison
equal
deleted
inserted
replaced
| 2314:7c8d2e9a0566 | 2316:f8a4c51e5847 |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 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 $ |
| 20 | 20 |
| 21 from distutils import log | |
| 22 from distutils.core import setup, Extension | 21 from distutils.core import setup, Extension |
| 23 from distutils.util import get_platform | 22 from distutils.util import get_platform |
| 24 from distutils.command.build_scripts import build_scripts | 23 from distutils.command.build_scripts import build_scripts |
| 25 from distutils.command.build import build | 24 from distutils.command.build import build |
| 26 | 25 |
| 140 # basename (without extension) is a locale name | 139 # basename (without extension) is a locale name |
| 141 _locale = os.path.splitext(os.path.basename(_file))[0] | 140 _locale = os.path.splitext(os.path.basename(_file))[0] |
| 142 _list.append((_file, os.path.join( | 141 _list.append((_file, os.path.join( |
| 143 "share", "locale", _locale, "LC_MESSAGES", "roundup.mo"))) | 142 "share", "locale", _locale, "LC_MESSAGES", "roundup.mo"))) |
| 144 return _list | 143 return _list |
| 145 | |
| 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 | 144 |
| 166 def check_manifest(): | 145 def check_manifest(): |
| 167 """Check that the files listed in the MANIFEST are present when the | 146 """Check that the files listed in the MANIFEST are present when the |
| 168 source is unpacked. | 147 source is unpacked. |
| 169 """ | 148 """ |
| 184 print 'Missing:', '\nMissing: '.join(err) | 163 print 'Missing:', '\nMissing: '.join(err) |
| 185 sys.exit(1) | 164 sys.exit(1) |
| 186 | 165 |
| 187 | 166 |
| 188 class build_roundup(build): | 167 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 | |
| 189 def run(self): | 201 def run(self): |
| 190 check_manifest() | 202 check_manifest() |
| 191 compile_po_files() | 203 self.compile_po_files() |
| 192 build.run(self) | 204 build.run(self) |
| 193 | 205 |
| 194 ############################################################################# | 206 ############################################################################# |
| 195 ### Main setup stuff | 207 ### Main setup stuff |
| 196 ############################################################################# | 208 ############################################################################# |
