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

前端 未结 1 565
梦如初夏
梦如初夏 2021-01-06 11:01

I\'m using namespaces with setuptools to distribute a same module in two different repositories. The goal is to get mymodule.one and mymodule.two i

相关标签:
1条回答
  • 2021-01-06 11:19

    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.

    0 讨论(0)
提交回复
热议问题