4

Using Python 3.4 and Setuptools, I'm trying to get namespace packages to work correctly as defined in PEP 420. My directory structure looks something like this:

  • project
    • __init__.py
    • core
      • several .py files
    • logging
      • com1
        • several .py files
      • com2
        • several .py files
    • interface
      • misc files

When using setuptools find_package() function, it finds the "project" package, but it doesn't install any of the folders (implicit sub-packages) inside of "project". When I unzip the .egg file, all I see is the __init__.py file inside, none of the subdirectories or files.

I could just put an __init__.py in every directory, but since those files would all be empty and I don't like the way it makes the structure work, I'm trying to avoid that.

If I move to just outside of my "project" directory, and run the following, it works

python -m project.logging.com1.myfile

but anywhere else it doesn't work, because setuptools isn't installing the sub-directories (implicit namespaces) that don't have __init__.py in them.

How can I make setuptools install my implicit namespace packages correctly? Would I just need to tell it to install all files inside the directory and that will be good enough?

2 Answers 2

3

It appears that the initial pull request that added PEP 420 support to setuptools was rejected. There is an open discussion on the best way to merge in PEP 420 support on another issue, but at the moment, it doesn't appear that implicit namespaces are supported.

Sign up to request clarification or add additional context in comments.

1 Comment

provided links are broken
0

Implicit namespace packages are not supported by find_packages. However, all that find_packages does is a return a list of dotted.package.names. You can still list your packages explicitly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.