inline streamlined version of build_i18n & intltool into our setup.py
I found the layers and layers of other tools just confusing. "python3 setup.py build" generates an identical (apart from timestamp) POT file and an identical build directory before and after this change.
This commit is contained in:
parent
758def3bf1
commit
48736606ec
52
setup.py
52
setup.py
|
@ -22,18 +22,48 @@ subiquity
|
||||||
Ubuntu Server Installer
|
Ubuntu Server Installer
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
import distutils.cmd
|
||||||
|
import distutils.command.build
|
||||||
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
setup_kwargs = {}
|
from setuptools import setup, find_packages
|
||||||
# dpkg build uses build and install, tox uses sdist
|
|
||||||
if 'SUBIQUITY_NO_I18N' not in os.environ:
|
|
||||||
from DistUtilsExtra.command import build_extra
|
class build(distutils.command.build.build):
|
||||||
from DistUtilsExtra.command import build_i18n
|
|
||||||
setup_kwargs['cmdclass'] = {'build': build_extra.build_extra,
|
def run(self):
|
||||||
'build_i18n': build_i18n.build_i18n}
|
super().run()
|
||||||
|
data_files = self.distribution.data_files
|
||||||
|
|
||||||
|
with open('po/POTFILES.in') as in_fp:
|
||||||
|
with open('po/POTFILES.in.tmp', 'w') as out_fp:
|
||||||
|
for line in in_fp:
|
||||||
|
if line.startswith('['):
|
||||||
|
continue
|
||||||
|
out_fp.write('../' + line)
|
||||||
|
|
||||||
|
subprocess.run([
|
||||||
|
'xgettext',
|
||||||
|
'--directory=.',
|
||||||
|
'--add-comments',
|
||||||
|
'--from-code=UTF-8',
|
||||||
|
'--output=subiquity.pot',
|
||||||
|
'--files-from=POTFILES.in.tmp',
|
||||||
|
], cwd="po")
|
||||||
|
os.unlink('po/POTFILES.in.tmp')
|
||||||
|
|
||||||
|
for po_file in glob.glob("po/*.po"):
|
||||||
|
lang = os.path.basename(po_file[:-3])
|
||||||
|
mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES")
|
||||||
|
mo_file = os.path.join(mo_dir, "subiquity.mo")
|
||||||
|
if not os.path.exists(mo_dir):
|
||||||
|
os.makedirs(mo_dir)
|
||||||
|
subprocess.run(["msgfmt", po_file, "-o", mo_file])
|
||||||
|
targetpath = os.path.join("share/locale", lang, "LC_MESSAGES")
|
||||||
|
data_files.append((targetpath, (mo_file,)))
|
||||||
|
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__),
|
with open(os.path.join(os.path.dirname(__file__),
|
||||||
|
@ -43,6 +73,7 @@ with open(os.path.join(os.path.dirname(__file__),
|
||||||
exec('\n'.join(lines), ns)
|
exec('\n'.join(lines), ns)
|
||||||
version = ns['__version__']
|
version = ns['__version__']
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[-1] == 'clean':
|
if sys.argv[-1] == 'clean':
|
||||||
print("Cleaning up ...")
|
print("Cleaning up ...")
|
||||||
os.system('rm -rf subiquity.egg-info build dist')
|
os.system('rm -rf subiquity.egg-info build dist')
|
||||||
|
@ -75,4 +106,5 @@ setup(name='subiquity',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
data_files=[],
|
data_files=[],
|
||||||
**setup_kwargs)
|
cmdclass={'build': build},
|
||||||
|
)
|
||||||
|
|
|
@ -68,7 +68,6 @@ parts:
|
||||||
- libsystemd-dev
|
- libsystemd-dev
|
||||||
- lsb-release
|
- lsb-release
|
||||||
- pkg-config
|
- pkg-config
|
||||||
- python3-distutils-extra
|
|
||||||
- python3-urwid
|
- python3-urwid
|
||||||
stage-packages:
|
stage-packages:
|
||||||
- cloud-init
|
- cloud-init
|
||||||
|
@ -76,7 +75,6 @@ parts:
|
||||||
- iso-codes
|
- iso-codes
|
||||||
- lsb-release
|
- lsb-release
|
||||||
- python3-bson
|
- python3-bson
|
||||||
- python3-distutils-extra
|
|
||||||
- python3-urwid
|
- python3-urwid
|
||||||
- python3-requests
|
- python3-requests
|
||||||
- python3-requests-unixsocket
|
- python3-requests-unixsocket
|
||||||
|
|
Loading…
Reference in New Issue