Patchwork [RFC] setup: build docs from setup.py

login
register
mail settings
Submitter Kevin Bullock
Date July 9, 2014, 4:37 p.m.
Message ID <97d98ce9e84fdb788a21.1404923842@billings.local>
Download mbox | patch
Permalink /patch/5137/
State Changes Requested
Headers show

Comments

Kevin Bullock - July 9, 2014, 4:37 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock@ringworld.org>
# Date 1404923562 18000
#      Wed Jul 09 11:32:42 2014 -0500
# Node ID 97d98ce9e84fdb788a21f38eb80abe51af52a858
# Parent  5b8d2ba8dbdf8ef2aac257d28002ad1bcc4920f9
setup: build docs from setup.py

This patch enables the use of bdist_mpkg to build a Mercurial package
for Mac OS X that includes the documentation. I've been using this
locally for several years to build my own packages before the official
Mac OS X versions appear, and these packages seem to be
indistinguishable from the official ones.
Matt Mackall - July 10, 2014, 8:51 a.m.
On Wed, 2014-07-09 at 11:37 -0500, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock <kbullock@ringworld.org>
> # Date 1404923562 18000
> #      Wed Jul 09 11:32:42 2014 -0500
> # Node ID 97d98ce9e84fdb788a21f38eb80abe51af52a858
> # Parent  5b8d2ba8dbdf8ef2aac257d28002ad1bcc4920f9
> setup: build docs from setup.py

What happens if the doc-building tools aren't installed?

> This patch enables the use of bdist_mpkg to build a Mercurial package
> for Mac OS X that includes the documentation. I've been using this
> locally for several years to build my own packages before the official
> Mac OS X versions appear, and these packages seem to be
> indistinguishable from the official ones.
> 
> diff --git a/setup.py b/setup.py
> --- a/setup.py
> +++ b/setup.py
> @@ -229,6 +229,7 @@ class hgbuild(build):
>      # a mess, now that all module imports are global.
>  
>                      ('build_ext', build.has_ext_modules),
> +                    ('build_doc', None),
>                     ] + build.sub_commands
>  
>  class hgbuildmo(build):
> @@ -318,6 +319,18 @@ class hgbuildpy(build_py):
>              else:
>                  yield module
>  
> +class hgbuilddoc(Command):
> +    description = 'Build documentation in doc/ (manpages)'
> +
> +    def initialize_options(self):
> +        pass
> +
> +    def finalize_options(self):
> +        pass
> +
> +    def run(self):
> +        self.spawn(['make', 'doc'])
> +
>  class buildhgextindex(Command):
>      description = 'generate prebuilt index of hgext (for frozen package)'
>      user_options = []
> @@ -421,6 +434,7 @@ cmdclass = {'build': hgbuild,
>              'build_mo': hgbuildmo,
>              'build_ext': hgbuildext,
>              'build_py': hgbuildpy,
> +            'build_doc': hgbuilddoc,
>              'build_hgextindex': buildhgextindex,
>              'install_scripts': hginstallscripts,
>              'build_hgexe': buildhgexe,
> @@ -490,7 +504,8 @@ for root in ('templates',):
>              f = os.path.join(curdir, f)
>              packagedata['mercurial'].append(f)
>  
> -datafiles = []
> +datafiles = [('man/man1', ['doc/hg.1']),
> +             ('man/man5', ['doc/hgignore.5', 'doc/hgrc.5'])]
>  setupversion = version
>  extra = {}
>  
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - July 12, 2014, 3:58 a.m.
On Fri, 2014-07-11 at 22:36 -0500, Kevin Bullock wrote:
> On Jul 10, 2014, at 3:51 AM, Matt Mackall <mpm@selenic.com> wrote:
> 
> > On Wed, 2014-07-09 at 11:37 -0500, Kevin Bullock wrote:
> >> # HG changeset patch
> >> # User Kevin Bullock <kbullock@ringworld.org>
> >> # Date 1404923562 18000
> >> #      Wed Jul 09 11:32:42 2014 -0500
> >> # Node ID 97d98ce9e84fdb788a21f38eb80abe51af52a858
> >> # Parent  5b8d2ba8dbdf8ef2aac257d28002ad1bcc4920f9
> >> setup: build docs from setup.py
> > 
> > What happens if the doc-building tools aren't installed?
> 
> Then setup.py would fail in the same way `make all` would, including a message telling the user to install docutils. Is that undesirable?

Well, it might mean 'make local' or 'make install-bin' don't work? Also,
since manpages don't matter on Windows, it'd be annoying if it started
complaining about the doc tools.

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -229,6 +229,7 @@  class hgbuild(build):
     # a mess, now that all module imports are global.
 
                     ('build_ext', build.has_ext_modules),
+                    ('build_doc', None),
                    ] + build.sub_commands
 
 class hgbuildmo(build):
@@ -318,6 +319,18 @@  class hgbuildpy(build_py):
             else:
                 yield module
 
+class hgbuilddoc(Command):
+    description = 'Build documentation in doc/ (manpages)'
+
+    def initialize_options(self):
+        pass
+
+    def finalize_options(self):
+        pass
+
+    def run(self):
+        self.spawn(['make', 'doc'])
+
 class buildhgextindex(Command):
     description = 'generate prebuilt index of hgext (for frozen package)'
     user_options = []
@@ -421,6 +434,7 @@  cmdclass = {'build': hgbuild,
             'build_mo': hgbuildmo,
             'build_ext': hgbuildext,
             'build_py': hgbuildpy,
+            'build_doc': hgbuilddoc,
             'build_hgextindex': buildhgextindex,
             'install_scripts': hginstallscripts,
             'build_hgexe': buildhgexe,
@@ -490,7 +504,8 @@  for root in ('templates',):
             f = os.path.join(curdir, f)
             packagedata['mercurial'].append(f)
 
-datafiles = []
+datafiles = [('man/man1', ['doc/hg.1']),
+             ('man/man5', ['doc/hgignore.5', 'doc/hgrc.5'])]
 setupversion = version
 extra = {}