Mercurial > p > roundup > code
annotate roundup/dist/command/build.py @ 8569:4006ddad6b8a
docs: add test/requirements.txt and doc same in developers.txt
Help devs get test environment set up. Also document ruff as option with
pylint and flake8.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 13 Apr 2026 12:55:03 -0400 |
| parents | 9c3ec0a5c7fc |
| children |
| rev | line source |
|---|---|
| 4068 | 1 # |
| 2 # Copyright (C) 2009 Stefan Seefeld | |
| 3 # All rights reserved. | |
| 4 # For license terms see the file COPYING.txt. | |
| 5 # | |
| 6 from roundup import msgfmt | |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
7 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
8 from setuptool.command.install import install as base |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
9 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
10 from distutils.command.build import build as base |
| 4068 | 11 import os |
| 12 from glob import glob | |
| 13 | |
| 14 def list_message_files(suffix=".po"): | |
| 15 """Return list of all found message files and their intallation paths""" | |
| 16 _files = glob("locale/*" + suffix) | |
| 17 _list = [] | |
| 18 for _file in _files: | |
| 19 # basename (without extension) is a locale name | |
| 20 _locale = os.path.splitext(os.path.basename(_file))[0] | |
| 21 _list.append((_file, os.path.join( | |
| 22 "share", "locale", _locale, "LC_MESSAGES", "roundup.mo"))) | |
| 23 return _list | |
| 24 | |
| 25 def check_manifest(): | |
| 26 """Check that the files listed in the MANIFEST are present when the | |
| 27 source is unpacked. | |
| 28 """ | |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
29 manifest_file = 'roundup.egg-info/SOURCES.txt' |
| 4068 | 30 try: |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
31 f=open(manifest_file) |
|
8528
fed0f839c260
fix: replace except: with except Exception: (by haosenwang1018@github)
John Rouillard <rouilj@ieee.org>
parents:
7411
diff
changeset
|
32 except Exception: |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
33 print('\n*** SOURCE WARNING: The MANIFEST file "%s" is missing!' % manifest_file) |
| 4068 | 34 return |
| 35 try: | |
| 36 manifest = [l.strip() for l in f.readlines()] | |
| 37 finally: | |
| 38 f.close() | |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
39 err = set([line for line in manifest if not os.path.exists(line)]) |
| 4068 | 40 # ignore auto-generated files |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
41 err = err - set(['roundup-admin', 'roundup-demo', 'roundup-gettext', |
|
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
42 'roundup-mailgw', 'roundup-server', 'roundup-xmlrpc-server']) |
| 4068 | 43 if err: |
| 44 n = len(manifest) | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
45 print('\n*** SOURCE WARNING: There are files missing (%d/%d found)!'%( |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
46 n-len(err), n)) |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
47 print('Missing:', '\nMissing: '.join(err)) |
| 4068 | 48 |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
49 def build_message_files(command): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
50 """For each locale/*.po, build .mo file in target locale directory""" |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
51 for (_src, _dst) in list_message_files(): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
52 _build_dst = os.path.join("build", _dst) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
53 command.mkpath(os.path.dirname(_build_dst)) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
54 command.announce("Compiling %s -> %s" % (_src, _build_dst)) |
|
5450
f2fade4552c5
replaced msgfmt.py with latest version supporting Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5376
diff
changeset
|
55 mo = msgfmt.Msgfmt(_src).get() |
|
f2fade4552c5
replaced msgfmt.py with latest version supporting Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5376
diff
changeset
|
56 open(_build_dst, 'wb').write(mo) |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
57 |
| 4068 | 58 |
| 59 class build(base): | |
| 60 | |
| 61 def run(self): | |
| 62 check_manifest() | |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
63 build_message_files(self) |
| 4068 | 64 base.run(self) |
| 65 |
