Skip to content

Commit c62292e

Browse files
committed
Build manual pages in setup.py
1 parent e6ee7ab commit c62292e

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

setup.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
except ImportError:
3131
using_translations = False
3232

33+
try:
34+
from sphinx.setup_command import BuildDoc
35+
using_sphinx = True
36+
except ImportError:
37+
using_sphinx = False
38+
3339

3440
cmdclass = dict(build_py=build_py, build=build)
3541
translations_dir = os.path.join(package_dir, 'translations')
@@ -82,19 +88,35 @@ def initialize_options(self):
8288
cmdclass['update_catalog'] = update_catalog
8389
cmdclass['init_catalog'] = init_catalog
8490

85-
86-
if platform.system() in ['FreeBSD', 'OpenBSD']:
87-
man_dir = 'man'
91+
if using_sphinx:
92+
class BuildDocMan(BuildDoc):
93+
def initialize_options(self):
94+
BuildDoc.initialize_options(self)
95+
self.builder = 'man'
96+
self.source_dir = 'doc/sphinx/source'
97+
self.build_dir = 'build'
98+
99+
build.sub_commands.insert(0, ('build_sphinx_man', None))
100+
cmdclass['build_sphinx_man'] = BuildDocMan
101+
102+
if platform.system() in ['FreeBSD', 'OpenBSD']:
103+
man_dir = 'man'
104+
else:
105+
man_dir = 'share/man'
106+
107+
# manual pages
108+
man_pages = [
109+
(os.path.join(man_dir, 'man1'), ['build/man/bpython.1']),
110+
(os.path.join(man_dir, 'man5'), ['build/man/bpython-config.5']),
111+
]
88112
else:
89-
man_dir = 'share/man'
113+
man_pages = []
90114

91115
data_files = [
92-
# man pages
93-
(os.path.join(man_dir, 'man1'), ['doc/bpython.1']),
94-
(os.path.join(man_dir, 'man5'), ['doc/bpython-config.5']),
95116
# desktop shortcut
96117
(os.path.join('share', 'applications'), ['data/bpython.desktop'])
97118
]
119+
data_files.extend(man_pages)
98120

99121
# translations
100122
mo_files = list()

0 commit comments

Comments
 (0)