Why does setup.py sweeps the content of the namespace before installing?

∥☆過路亽.° 提交于 2019-12-01 06:57:22

There are two requirements for using name spaces correctly.

  1. __init__.py of modules declare a name space
  2. setup.py defines unique name for each module

The contents of both __init__.py files should be:

__import__('pkg_resources').declare_namespace(__name__)

Then setup.py for first module:

setup(name='mymodule_one', packages=find_packages('.'), 
      namespace_packages=['mymodule'])

and second module

setup(name='mymodule_two', packages=find_packages('.'),
      namespace_packages=['mymodule'])

As a result, should be able to install and import both mymodule.one and mymodule.two

The common name space mymodule allows both modules to be imported using the same name.

The name given to setup.py for each module needs to be unique as that is used for the installation path of the module and will overwrite anything that shares it, as you have seen.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!