Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.maint.python > #9661

Re: building manpages via setup.py

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Ghislain Vaillant <ghisvail@gmail.com>
Newsgroups linux.debian.maint.python
Subject Re: building manpages via setup.py
Date Tue, 01 Aug 2017 17:00:01 +0200
Message-ID <u9GOl-5h7-3@gated-at.bofh.it> (permalink)
References <u9GEH-5cQ-19@gated-at.bofh.it>
X-Original-To PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr>, "debian-python@lists.debian.org" <debian-python@lists.debian.org>
X-Mailbox-Line From debian-python-request@lists.debian.org Tue Aug 1 14:58:13 2017
Old-Return-Path <ghisvail@gmail.com>
X-Amavis-Spam-Status No, score=-7.099 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, LDO_WHITELIST=-5, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham autolearn_force=no
X-Policyd-Weight using cached result; rate: -7
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=No8ESDpESh0e7nhrUYn3qjJOrjyjEW/18Ihh6Vdv3jQ=; b=QbXXJsLmGPqctJBbAwHMhjoI1uFyjiMpv4cYUt4YJZ2Wdo8vjKzDR+GUB2xtzlzkRr dlLPj3oA/2H3MHGBnr1kmmmj5Ow1tfbqVl/VM0v3J3cXcZNeAzQnhdDHQXL/urOJ940c bELMiBLHr7RmiJGJBU6i6TlIYC6s7ctjRG45Wrn0t+ZhmkwzRIizl9KSt5BXKTab80ld afwmWwRpQmjY5WznXY9x29dj9P03f8RyEqydJXsECVmya5/LwoqaEpixW/PYPZcH2LnE VQWReh/eRm8uyYgBpuryxgt3i2Xyz6ZfLi2OCTiIy3NaYNbDeATGbOcKqLigM+BlqxXE ALmA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=No8ESDpESh0e7nhrUYn3qjJOrjyjEW/18Ihh6Vdv3jQ=; b=hs9LK/euq4o0zLgNE7guW1I4wkhcV9mZz1KOeJRy/Ik5cNCISbxErrVpQhrCpu3+oI 5qikqM6A4+V3ts1VliwpcBUCtBnDD8ZCBtacwrmeqn1Sl5lqTQW+LyyAPfrL+9piSpJj /QLiK6LAM9wjELyiHX8QhEp49g6cKI6WjgO+mIBgY3frmh9clzW6pQzM1Ldz9drtgcXo lyjT7kycQ3FT6G1tFGkOrfMvRVViLE85uQ94CbkE4yiLEGFv1Celk4vxNQIA9+SV4h82 Q6cSw/uaCBFvn8hlwTvshsfrIu8NISZLiH7rqsoVsrC7LG4XaUi1IyyUQtkT+Z1bK547 wqMA==
X-Gm-Message-State AIVw110Aiw1A12ryd4jITiuj3/I6JqsfY2FHV/l8mgvm7Q8NGFIo2lSR qhN7Xu4xOGRWl4wKGnM=
X-Received by 10.223.161.133 with SMTP id u5mr17264190wru.191.1501599467073; Tue, 01 Aug 2017 07:57:47 -0700 (PDT)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
MIME-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Language en-GB
Content-Transfer-Encoding 7bit
X-Mailing-List <debian-python@lists.debian.org> archive/latest/15042
List-ID <debian-python.lists.debian.org>
List-URL <https://lists.debian.org/debian-python/>
List-Archive https://lists.debian.org/msgid-search/41a3f00e-cc48-bfac-08c6-787d2e4c41a4@gmail.com
Approved robomod@news.nic.it
Lines 125
Organization linux.* mail to news gateway
Sender robomod@news.nic.it
X-Original-Date Tue, 1 Aug 2017 15:57:46 +0100
X-Original-Message-ID <41a3f00e-cc48-bfac-08c6-787d2e4c41a4@gmail.com>
X-Original-References <A2A20EC3B8560D408356CAC2FC148E53BB3F8A26@SUN-DAG3.synchrotron-soleil.fr>
Xref csiph.com linux.debian.maint.python:9661

Show key headers only | View raw


On 01/08/17 15:15, PICCA Frederic-Emmanuel wrote:
> Hello,
> 
> I am working on the pyfai package.
> This pacakge contain one module with extensions (the important point)
> 
> The new upstream version 0.14.0 provide a build_man target via the setup.py
> 
> So in ordert to generate the doc I need to do
> 
> python setup.py build_man
> 
> Now if I look at this target, I can find this code
> 
> -----
> 
> class BuildMan(Command):
>      """Command to build man pages"""
>      user_options = []
> 
>      def initialize_options(self):
>          pass
> 
>      def finalize_options(self):
>          pass
> 
>      def entry_points_iterator(self):
>          """Iterate other entry points available on the project."""
>          entry_points = self.distribution.entry_points
>          console_scripts = entry_points.get('console_scripts', [])
>          gui_scripts = entry_points.get('gui_scripts', [])
>          scripts = []
>          scripts.extend(console_scripts)
>          scripts.extend(gui_scripts)
>          for script in scripts:
>              elements = script.split("=")
>              target_name = elements[0].strip()
>              elements = elements[1].split(":")
>              module_name = elements[0].strip()
>              function_name = elements[1].strip()
>              yield target_name, module_name, function_name
> 
>      def run(self):
>          build = self.get_finalized_command('build')
>          path = sys.path
>          path.insert(0, os.path.abspath(build.build_lib))
> 
>          env = dict((str(k), str(v)) for k, v in os.environ.items())
>          env["PYTHONPATH"] = os.pathsep.join(path)
> 
>          import subprocess
> 
>          status = subprocess.call(["mkdir", "-p", "build/man"])
>          if status != 0:
>              raise RuntimeError("Fail to create build/man directory")
> 
>          import tempfile
>          import stat
>          script_name = None
> 
>          entry_points = self.entry_points_iterator()
>          for target_name, module_name, function_name in entry_points:
>              logger.info("Build man for entry-point target '%s'" % target_name)
>              # help2man expect a single executable file to extract the help
>              # we create it, execute it, and delete it at the end
> 
>              py3 = sys.version_info >= (3, 0)
>              try:
>                  # create a launcher using the right python interpreter
>                  script_fid, script_name = tempfile.mkstemp(prefix="%s_" % target_name, text=True)
>                  script = os.fdopen(script_fid, 'wt')
>                  script.write("#!%s\n" % sys.executable)
>                  script.write("import %s as app\n" % module_name)
>                  script.write("app.%s()\n" % function_name)
>                  script.close()
>                  # make it executable
>                  mode = os.stat(script_name).st_mode
>                  os.chmod(script_name, mode + stat.S_IEXEC)
> 
>                  # execute help2man
>                  man_file = "build/man/%s.1" % target_name
>                  command_line = ["help2man", script_name, "-o", man_file]
>                  if not py3:
>                      # Before Python 3.4, ArgParser --version was using
>                      # stderr to print the version
>                      command_line.append("--no-discard-stderr")
> 
>                  p = subprocess.Popen(command_line, env=env)
>                  status = p.wait()
>                  if status != 0:
>                      raise RuntimeError("Fail to generate '%s' man documentation" % target_name)
>              finally:
>                  # clean up the script
>                  if script_name is not None:
>                      os.remove(script_name)
> -----
> 
> 
> As you can see this create a launch script for each entry point found in the setup.py and run help2man on it.
> 
> For now I would like to use this setup.py without modification.
> 
> So what should I do to run
> 
> python setup.py build_man with the options provided by pybuild during the normal build in order to let the  generated script find the pyFAI modules and its extensions ?

Simplest I can think of would be to build the extensions inplace 
followed by the call to build_man. Something like:

override_dh_auto_build:
	dh_auto_build
	python3 setup.py build_ext --inplace
	python3 setup.py build_man

I left the http_proxy exports and nodoc guards out for clarity.

> Second questions what is the right way to generate the man pages for a python application ?

Usually via Sphinx if the upstream documentation uses it. Regardless of 
the stack, `help2man` is often considered the poor man choice for 
generating manpages.

Let me know if you'd like me to have a look :-)

Ghis

Back to linux.debian.maint.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-01 16:50 +0200
  Re: building manpages via setup.py Ghislain Vaillant <ghisvail@gmail.com> - 2017-08-01 17:00 +0200
    RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-01 17:50 +0200
  Re: building manpages via setup.py Piotr Ożarowski <piotr@debian.org> - 2017-08-01 17:40 +0200
    RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-02 09:20 +0200
      Re: building manpages via setup.py Piotr Ożarowski <piotr@debian.org> - 2017-08-02 09:30 +0200
        Re: building manpages via setup.py Piotr Ożarowski <piotr@debian.org> - 2017-08-02 09:50 +0200
          Re: building manpages via setup.py Ghislain Vaillant <ghisvail@gmail.com> - 2017-08-02 09:50 +0200
            Re: building manpages via setup.py Ghislain Vaillant <ghisvail@gmail.com> - 2017-08-02 10:20 +0200
              RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-02 10:40 +0200
                Re: building manpages via setup.py Ghislain Vaillant <ghisvail@gmail.com> - 2017-08-02 10:40 +0200
                RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-02 11:20 +0200
                Re: building manpages via setup.py Ghislain Vaillant <ghisvail@gmail.com> - 2017-08-02 11:30 +0200
                RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-02 12:10 +0200
                Re: building manpages via setup.py Ghislain Vaillant <ghisvail@gmail.com> - 2017-08-02 12:50 +0200
                RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-02 14:30 +0200
            RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-02 10:30 +0200
        RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-02 09:50 +0200
        RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-03 12:20 +0200
          RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-03 15:50 +0200
            RE:building manpages via setup.py PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr> - 2017-08-03 16:20 +0200

csiph-web