flo*_*qqi 23 python pip setup.py python-2.7 python-3.x
如何构建多个兼容Python 2.7+和3.3+兼容的相同命名空间的python模块?
让我们调用命名空间test.现在我想要调用两个单独的模块test.foo,另一个调用test.bar.但是,我目前正在开发test.helloworld,这取决于两者,test.foo和test.bar.两者都列在requirements.txt文件中.
这些模块test.foo和test.bar目前正在使用的Python 2解决方案的命名空间的包:
import pkg_resources
pkg_resources.declare_namespace(__name__)
Run Code Online (Sandbox Code Playgroud)
为开发模式 运行建议的pip-commandpip install -e .将变为: ImportError: No module named 'test.helloworld'导入test.foo或test.bar正在运行时.
用于命名空间包的Python 3解决方案是隐式命名空间包,其中命名空间包没有__init__.py文件.遗憾的是,这不适用于Python 2版本.
如何为Python 2和3设计解决方案(允许我使用pip install -e .)?该--egg解决方案对我不起作用,因为它已被弃用.
| 归档时间: |
|
| 查看次数: |
1459 次 |
| 最近记录: |