[Distutils] installing both packages and (sometimes) modules

Thomas Heller theller@python.net
Mon Jan 13 03:22:02 2003


Anthony Baxter <anthony@interlink.com.au> writes:

> For the spambayes project, I have a distutils setup that installs
> the 'spambayes' package. I also (for 2.2) want it to install copies
> of 'sets.py' and 'heapq.py' modules into site-packages. Unfortunately
> distutils will let me have a 'packages' line, or a 'py_modules' line,
> but not both. Is there an easy way to do this that doesn't involve 
> subclassing a distutils command?

Not that I know of, but why not use a sublass:

----------
from distutils.command import build_py

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 ()

if __name__ == '__main__':
    setup(...
          cmdclass = {"build_py": my_build_py},
          ...)
----------

Thomas