[Distutils] install packages & modules simultaneously?

Thomas Heller theller at python.net
Wed Jun 18 10:13:16 EDT 2003


David Goodger <goodger at python.org> writes:

> Docutils relies on a few 3rd-party modules, and includes them as a
> convenience.  They are only to be installed if they're not already
> present in a Python installation, so I have code in setup.py check for
> them.
>
> Distutils doesn't seem to be able to handle packages and individual
> modules simultaneously.  Distutils complains if I specify both
> "packages" and "py_modules" in a single call.  I got the script to
> work by calling distutils.core.setup twice: first for the third-party
> modules, then for the "docutils" packages
> (http://docutils.sf.net/setup.py).  Installation isn't so bad, but
> doing "python setup.py sdist" creates 2 tarballs and feels very
> kludgey.  Does anyone know of a better way?

I found the following code (commented out) in one of my setup scripts.
It might do what you want, but it is untested:

from distutils.command import build_py

# a class which will allow to distribute packages *and*
# modules with one setup script, currently unused.
class my_build_py(build_py.build_py):
    def run (self):
        if not self.py_modules and not self.packages:
            return

        if self.py_modules:
            self.build_modules()
        if self.packages:
            self.build_packages()

        self.byte_compile(self.get_outputs(include_bytecode=0))
    # run ()

Thomas




More information about the Distutils-SIG mailing list