简体   繁体   中英

python implicit namespace packages are not installing with setuptools

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM