【发布时间】:2021-04-19 13:00:49
【问题描述】:
Python 项目大量使用来自另一个存储库的通用声明。
from *another_repository*.common import *class1*, *class2*.
如何在自己的存储库中正确集成此类文件夹,而不将其自身复制到当前项目中?
在setuptools.setup 中有一个类似install_requires 的字段。我尝试了下一个选项:
install_requires = [..., 'another_repository @ git+ssh://git@gitlab.com/another_repository@master&subdirectory=common', ...]
但它不起作用,因为common 文件夹不包含任何setup.py 模块。
【问题讨论】:
-
添加公共仓库作为子模块?
-
@rasjani 还有其他方法吗?它将被用作第三方而不对其做出贡献。
-
如果子模块中的文件作为源分发或轮子的一部分包含(例如,通过 MANIFEST.in 文件包含),则该方法没有任何问题。在安装时依赖一些外部服务不是一个好主意,并且会给随机的人带来问题。
-
您是否有机会将 setup.py 贡献给其他存储库?如果没有,我也推荐子模块的方法。
标签: python git python-import setuptools install-requires