On 2018 Apr 25, at 16:02, Skip Montanaro <skip.montan...@gmail.com> wrote: > 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".
If by "top/server tree" you mean that there are more subpackages under top.server (not just a server.py file as your diagram shows), then you need to filter out all of those subpackages as well, e.g.: packages = setuptools.find_packages() if sys.version_info.major < 3: packages = [ pkg for pkg in packages if pkg != "top.server" and not pkg.startswith("top.server.") ] _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org https://mail.python.org/mailman/listinfo/distutils-sig