有没有办法添加命名空间前缀 setuptools 包发行版?
我希望向我的 Python setuptools 分布式包添加命名空间前缀。例如,我们有一个名为 common_utils 的包,并且希望将其作为伞.common_utils 进行访问,而不必在包树中包含虚拟目录/模块“umbrella”。
这可能吗?
谢谢,
I'm looking to add a namespace prefix to my Python setuptools distributed package. E.g. we have a package called common_utils and a would like it to be accessed as umbrella.common_utils without having to include the dummy directory/module 'umbrella' in the package tree.
Is this possible?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
package_dir
选项告诉 setuptools 完整的包名称和子包的位置:结果:
更新
正如您所发现的,
python setup.py开发
目标有点像黑客。它将您的项目文件夹添加到site-packages/easy-install.pth
中,但不执行任何操作来使您的包适应 setup.py 中描述的结构。不幸的是,我还没有找到与 setuptools/distribute 兼容的解决方法。听起来您实际上想要这样的东西,您可以将其包含在项目的根目录中并根据您的需求进行自定义:
在项目根目录中创建名为
develop
的文件:You can use the
package_dir
option to tell setuptools the full package name and location of the subpackage:Result:
Updated
As you've discovered, the
python setup.py develop
target is a bit of a hack. It adds your project folder tosite-packages/easy-install.pth
, but does nothing to adapt your package to the structure described in setup.py. Unfortunately I have not found a setuptools/distribute-compatible workaround for this.It sounds like you effectively want something like this, which you could include in the root of your project and customize to your needs:
Create file named
develop
in your project root: