[Distutils] How to eliminate on part of a package?

Skip Montanaro skip.montanaro at gmail.com
Wed Apr 25 16:02:01 EDT 2018


I recently ported a package to Python 3. The overall structure is
pretty straightforward:

top/
    client/
        module.py
    server/
        server.py

There's more to it, but that's enough for demonstration. I am
retaining Python 2.7 compatibility on the client side, but have
dispensed with that business on the server. (I run the server, not my
users.) Accordingly, I would like the py27 version of the package to
not have a subpackage named "server".

I thought it would be easy peasy to just trim the server bits from
setuptools.find_packages() in my setup.py file (I have
36.5.0.post20170921 of setuptools), something like this:

packages = setuptools.find_packages()
if sys.version_info.major < 3:
    packages.remove("top.server")

In either case, I pass the resulting list as the packages argument of
setuptools.setup(...).

That doesn't work though. I get some sort of mish-mash where part of
the top/server tree is copied, part not. I eventually get an error
from a cp command, something about ".../server is not a directory".

It would seem there is more I need to do, but nothing jumped out at me
in the online documentation
(http://setuptools.readthedocs.io/en/latest/setuptools.html). FWIW,
while I see a section on that page titled, "New and Changed setup()
Keywords", I didn't see a corresponding "Old and Unchanged setup()
Keywords" there or up a level.

Any pointers, hints, or suggestions appreciated...

Skip Montanaro


More information about the Distutils-SIG mailing list