Skip to content

Commit 1f2f6f5

Browse files
committed
Refactor build command overrides
1 parent ff05288 commit 1f2f6f5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

setup.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77

88
from setuptools import setup, Command
9-
from setuptools.command.build import build as _orig_build
9+
from setuptools.command.build import build
1010

1111
try:
1212
from babel.messages import frontend as babel
@@ -320,26 +320,27 @@ def git_describe_to_python_version(version):
320320
vf.write(f'__version__ = "{version}"\n')
321321

322322

323-
class build(_orig_build):
324-
# Avoid patching the original class' attribute (more robust customisation)
325-
sub_commands = _orig_build.sub_commands[:]
323+
class custom_build(build):
324+
def run(self):
325+
if using_translations:
326+
self.run_command("compile_catalog")
327+
if using_sphinx:
328+
self.run_command("build_sphinx_man")
326329

327330

328-
cmdclass = {"build": build}
331+
cmdclass = {"build": custom_build}
332+
329333

330334
translations_dir = os.path.join("bpython", "translations")
331335

332336
# localization options
333337
if using_translations:
334-
build.sub_commands.insert(0, ("compile_catalog", None))
335-
336338
cmdclass["compile_catalog"] = babel.compile_catalog
337339
cmdclass["extract_messages"] = babel.extract_messages
338340
cmdclass["update_catalog"] = babel.update_catalog
339341
cmdclass["init_catalog"] = babel.init_catalog
340342

341343
if using_sphinx:
342-
build.sub_commands.insert(0, ("build_sphinx_man", None))
343344
cmdclass["build_sphinx_man"] = BuildDoc
344345

345346
if platform.system() in ("FreeBSD", "OpenBSD"):
@@ -378,6 +379,7 @@ class build(_orig_build):
378379
if os.path.exists(os.path.join(translations_dir, mo_subpath)):
379380
mo_files.append(mo_subpath)
380381

382+
381383
setup(
382384
version=version,
383385
data_files=data_files,
@@ -388,6 +390,7 @@ class build(_orig_build):
388390
},
389391
cmdclass=cmdclass,
390392
test_suite="bpython.test",
393+
zip_safe=False,
391394
)
392395

393396
# vim: fileencoding=utf-8 sw=4 ts=4 sts=4 ai et sta

0 commit comments

Comments
 (0)