[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE:building manpages via setup.py



Hello Piotr,

I am struggling, with the build system.

I will speak about this solution

> | override_dh_auto_build:
> |       dh_auto_build -- --after-build '{interpreter} setup.py build_man'

the code instrumented of the BuildMan is this one

class BuildMan(Command):
    """Command to build man pages"""
    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

    def run(self):
        build = self.get_finalized_command('build')
        path = sys.path
        path.insert(0, os.path.abspath(build.build_lib))

        print("PYTHONPATH", os.environ.get("PYTHONPATH", None))
        print("sys.path", sys.path, os.path.exists(build.build_lib))
        env = dict((str(k), str(v)) for k, v in os.environ.items())
        env["PYTHONPATH"] = os.pathsep.join(path)
        print("env[PYTHONPATH]", env["PYTHONPATH"])

        import subprocess

        status = subprocess.call(["mkdir", "-p", "build/man"])
        if status != 0:
            raise RuntimeError("Fail to create build/man directory")

        try:
            import tempfile
            import stat
            script_name = None

            # help2man expect a single executable file to extract the help
            # we create it, execute it, and delete it at the end

            # create a launcher using the right python interpreter
            script_fid, script_name = tempfile.mkstemp(prefix="%s_" % PROJECT, text=True)
            script = os.fdopen(script_fid, 'wt')
            script.write("#!%s\n" % sys.executable)
            script.write("import runpy\n")
            script.write("runpy.run_module('%s', run_name='__main__')\n" % PROJECT)
            script.close()

            # make it executable
            mode = os.stat(script_name).st_mode
            os.chmod(script_name, mode + stat.S_IEXEC)

            # execute help2man
            p = subprocess.Popen(["help2man", script_name, "-o", "build/man/silx.1"], env=env)
            status = p.wait()
            if status != 0:
                raise RuntimeError("Fail to generate man documentation")
        finally:
            # clean up the script
            if script_name is not None:
                os.remove(script_name)


When I run the build it generate a pydistconfig file wit this content

D: pybuild plugin_distutils:55: pydistutils config file:
[clean]
all=1
[build]
build-lib=/home/picca/Debian/silx/silx/.pybuild/pythonX.Y_2.7/build
[install]
force=1
install-layout=deb
install-scripts=/usr/bin
install-lib=/usr/lib/python2.7/dist-packages
[easy_install]
allow_hosts=None


But when it comes to the --after step, I get this output

('PYTHONPATH', '/home/picca/Debian/silx/silx/.pybuild/pythonX.Y_2.7/build')
('sys.path', ['/home/picca/Debian/silx/silx/build/lib.linux-i386-2.7', '/home/picca/Debian/silx/silx', '/home/picca/Debian/silx/silx/.pybuild/pythonX.Y_2.7/build', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7'], False)
('env[PYTHONPATH]', '/home/picca/Debian/silx/silx/build/lib.linux-i386-2.7:/home/picca/Debian/silx/silx:/home/picca/Debian/silx/silx/.pybuild/pythonX.Y_2.7/build:/usr/lib/python2.7:/usr/lib/python2.7/plat-i386-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PILcompat:/usr/lib/python2.7/dist-packages/gtk-2.0:/usr/lib/pymodules/python2.7')

So as you can see the path returned by build.build_lib
seems to be

/home/picca/Debian/silx/silx/build/lib.linux-i386-2.7'

and not

/home/picca/Debian/silx/silx/.pybuild/pythonX.Y_2.7/build (provided via pydist)

So my question is what is wrong.

self.get_finalized_command('build')

doesn not take into account the pydistconfig file ?


Thanks for your help


Frederic

Reply to: