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


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

building manpages via setup.py

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From PICCA Frederic-Emmanuel <frederic-emmanuel.picca@synchrotron-soleil.fr>
Newsgroups linux.debian.maint.python
Subject building manpages via setup.py
Date Tue, 01 Aug 2017 16:50:03 +0200
Message-ID <u9GEH-5cQ-19@gated-at.bofh.it> (permalink)
X-Original-To "debian-python@lists.debian.org" <debian-python@lists.debian.org>
X-Mailbox-Line From debian-python-request@lists.debian.org Tue Aug 1 14:42:10 2017
Old-Return-Path <frederic-emmanuel.picca@synchrotron-soleil.fr>
X-Amavis-Spam-Status No, score=-0.101 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-0.001, THREADTOPIC=2] autolearn=no autolearn_force=no
X-Policyd-Weight using cached result; rate: -6.1
X-Greylist delayed 616 seconds by postgrey-1.35 at bendel; Tue, 01 Aug 2017 14:25:21 UTC
Dkim-Filter OpenDKIM Filter v2.10.3 poussette.synchrotron-soleil.fr 11FF1600BC
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=synchrotron-soleil.fr; s=email; t=1501596902; bh=37/13GqL23ApVqLj75Zu7r8bzqvv32RbP2HPzUoHycg=; h=From:To:Subject:Date:From; b=gzaAEq5gBrJxV0c3ZeZhN9PE5YhGXCZINCFzCZ0I7+eKsXtZBn+UyWLflQ5nY1Mxr aXV8zE5wmGAaRly7D8MbTfWMqv9mwnFokpYfCIkbGqzsJ9ZZBiq49XSYZRWpUJuVRM HC2Cves7V6R2KiXojGXJKMlaJtV7qu0otretsdHg=
Dkim-Filter OpenDKIM Filter v2.10.3 poussette.synchrotron-soleil.fr 2587D60085
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=synchrotron-soleil.fr; s=email; t=1501596901; bh=37/13GqL23ApVqLj75Zu7r8bzqvv32RbP2HPzUoHycg=; h=From:To:Subject:Date:From; b=g19EY3atFqSQZGa8+5kzHF7CmVlL6j+Es2VyMKwtX//gvzTTNbyRq5TUvQ/vR1/vj z5jQRg1ykWWwjxH/oHRWNwP7Z09402RmzvkMh5SHuqabFpwr4n81Br/TWOUFVlw14a EJs4rpwpyG+byPzz/vnSQKECuiupuM8doWAHIE+0=
Thread-Topic building manpages via setup.py
Thread-Index AdMKnYeNbtHGA2ChRMa/5+FgMHXlSA==
Accept-Language fr-FR, en-US
Content-Language fr-FR
X-Originating-IP [195.221.0.171]
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-Mailing-List <debian-python@lists.debian.org> archive/latest/15041
List-ID <debian-python.lists.debian.org>
List-URL <https://lists.debian.org/debian-python/>
List-Archive https://lists.debian.org/msgid-search/A2A20EC3B8560D408356CAC2FC148E53BB3F8A26@SUN-DAG3.synchrotron-soleil.fr
Approved robomod@news.nic.it
Lines 118
Organization linux.* mail to news gateway
Sender robomod@news.nic.it
X-Original-Date Tue, 1 Aug 2017 14:15:00 +0000
X-Original-Message-ID <A2A20EC3B8560D408356CAC2FC148E53BB3F8A26@SUN-DAG3.synchrotron-soleil.fr>
Xref csiph.com linux.debian.maint.python:9660

Show key headers only | View raw


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 ?


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

thanks for your help

Frederic

Back to linux.debian.maint.python | Previous | Next — 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