gpt4 book ai didi

python - 如何让 setuptools(或分发)从本地文件系统安装包

转载 作者:IT老高 更新时间:2023-10-28 20:42:15 24 4
gpt4 key购买 nike

是否可以在 setup.py 中指定(可编辑的)源依赖项,这些依赖项已知驻留在本地文件系统中?

考虑以下目录结构,所有这些都位于单个 VCS 存储库中:

projects
utils
setup.py
...
app1
setup.py
... # app1 files depend on ../utils
app2
setup.py
... # app2 files depend on ../utils

给出以下命令:

cd projects
mkvirtualenv app1
pip install -e app1

我想安装 app1 的所有依赖项,包括“utils”,这是一个“可编辑”依赖项。同样,如果我对 app2 做同样的事情。

我尝试在 install_requiresdependency_links 中使用所有不同的 file://... URL 组合,但无济于事。我想使用像 src+file://../utils 这样的依赖链接 URL,它会告诉 setuptools 包的源代码在这个相对路径的文件系统上。有没有办法做到这一点?

最佳答案

我设法在 setup.py 中提供了相对本地依赖:

setup(
install_requires=[
'utils @ file://localhost/%s/../utils/' % os.getcwd().replace('\\', '/'),
],
)

但也许有人知道更好的解决方案

关于python - 如何让 setuptools(或分发)从本地文件系统安装包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12982406/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com