[Distutils] installing both packages and (sometimes) modules

Just van Rossum just@letterror.com
Mon Jan 13 03:48:02 2003


Anthony Baxter wrote:

> 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?

I managed to do something like that by doing this:

packages = <list of packages>
package_dir = <dict of package dirs>

if <need to install extra stuff>:
    packages.append('')
    package_dir[''] = 'DirContainingExtraTopLevelModules'


setup(
    ...
    packages = packages,
    package_dir = package_dir,
)

It's still a kludge, as you can only have one such directory.

Just