[Updated] D9640: setup: when possible, build and bundle man pages
Phabricator
phabricator at mercurial-scm.org
Wed Jan 13 19:41:01 UTC 2021
Closed by commit rHG63c923fd7fa8: setup: when possible, build and bundle man pages (authored by Dan Villiom Podlaski Christiansen <danchr at gmail.com>).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
CHANGED PRIOR TO COMMIT
https://phab.mercurial-scm.org/D9640?vs=24712&id=24802#toc
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9640?vs=24712&id=24802
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9640/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9640
AFFECTED FILES
setup.py
CHANGE DETAILS
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -196,6 +196,7 @@
from distutils.command.build_py import build_py
from distutils.command.build_scripts import build_scripts
from distutils.command.install import install
+from distutils.command.install_data import install_data
from distutils.command.install_lib import install_lib
from distutils.command.install_scripts import install_scripts
from distutils import log
@@ -212,6 +213,12 @@
# Explain to distutils.StrictVersion how our release candidates are versionned
StrictVersion.version_re = re.compile(r'^(\d+)\.(\d+)(\.(\d+))?-?(rc(\d+))?$')
+# Can we build the documentation?
+try:
+ import docutils
+except ImportError:
+ docutils = None
+
def write_if_changed(path, content):
"""Write content to a file iff the content hasn't changed."""
@@ -471,6 +478,14 @@
# when build_py is run next.
sub_commands = [('build_mo', None)] + build.sub_commands
+ def run(self):
+ if os.name == 'nt':
+ pass
+ elif docutils is None:
+ log.warn('not building optional documentation')
+ else:
+ self.run_command('build_doc')
+
class hgbuildmo(build):
@@ -1040,6 +1055,43 @@
genhtml(root)
+class hginstalldata(install_data):
+ user_options = install_data.user_options + [
+ (
+ 'install-man=',
+ None,
+ 'installation directory for manual pages [share/man]',
+ ),
+ ]
+
+ install_man = None
+
+ def finalize_options(self):
+ install_data.finalize_options(self)
+
+ self.set_undefined_options('install', ('install_man', 'install_man'))
+
+ if self.install_man is None:
+ self.install_man = os.path.join('share', 'man')
+
+ if os.name == 'nt':
+ pass
+ elif docutils is None:
+ log.warn('not installing manual pages')
+ else:
+ manpages = [
+ f for f in os.listdir('doc') if re.search(r'\.[0-9]$', f)
+ ]
+
+ self.data_files += [
+ (
+ os.path.join(self.install_man, 'man' + ext[1:]),
+ ['doc/' + f for f in manpages if f.endswith(ext)],
+ )
+ for ext in set(os.path.splitext(f)[1] for f in manpages)
+ ]
+
+
class hginstall(install):
user_options = install.user_options + [
@@ -1053,17 +1105,26 @@
None,
'noop, present for eggless setuptools compat',
),
+ (
+ 'install-man=',
+ None,
+ 'installation directory for manual pages [share/man]',
+ ),
]
# Also helps setuptools not be sad while we refuse to create eggs.
single_version_externally_managed = True
+ install_man = None
+
def get_sub_commands(self):
+ subcommands = install.get_sub_commands(self)
+ subcommands.append('install_data')
# Screen out egg related commands to prevent egg generation. But allow
# mercurial.egg-info generation, since that is part of modern
# packaging.
excl = {'bdist_egg'}
- return filter(lambda x: x not in excl, install.get_sub_commands(self))
+ return filter(lambda x: x not in excl, subcommands)
class hginstalllib(install_lib):
@@ -1265,6 +1326,7 @@
'build_hgextindex': buildhgextindex,
'install': hginstall,
'install_lib': hginstalllib,
+ 'install_data': hginstalldata,
'install_scripts': hginstallscripts,
'build_hgexe': buildhgexe,
}
To: danchr, #hg-reviewers, marmoute
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210113/da532fee/attachment-0002.html>
More information about the Mercurial-patches
mailing list