我想通过在我的私有 PyPI 中指定它们来安装依赖项setup.py
.
我已经尝试指定在何处查找依赖项dependency_links
这边走:
setup(
...
install_requires=["foo==1.0"],
dependency_links=["https://my.private.pypi/"],
...
)
我还尝试在 中定义整个 URLdependency_links
:
setup(
...
install_requires=[],
dependency_links=["https://my.private.pypi/foo/foo-1.0.tar.gz"],
...
)
但是当我尝试安装时python setup.py install
,他们都不适合我。
有谁能够帮助我?
EDITS:
使用第一段代码我得到了这个错误:
...
Installed .../test-1.0.0-py3.7.egg
Processing dependencies for test==1.0.0
Searching for foo==1.0
Reading https://my.private.pypi/
Reading https://pypi.org/simple/foo/
Couldn't find index page for 'foo' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for foo==1.0
error: Could not find suitable distribution for Requirement.parse('foo==1.0')
而在第二种情况下,我没有收到任何错误,只是出现以下错误:
...
Installed .../test-1.0.0-py3.7.egg
Processing dependencies for test==1.0.0
Finished processing dependencies for test==1.0.0
更新1:
我尝试过改变setup.py
按照sinoroc的指示。现在我的setup.py
看起来像这样:
setup(
...
install_requires=["foo==1.0"],
dependency_links=["https://username:p[email protected]/folder/foo/foo-1.0.tar.gz"],
...
)
我建了图书馆test
with python setup.py sdist
并尝试安装它pip install /tmp/test/dist/test-1.0.0.tar.gz
,但我仍然收到此错误:
Processing /tmp/test/dist/test-1.0.0.tar.gz
ERROR: Could not find a version that satisfies the requirement foo==1.0 (from test==1.0.0) (from versions: none)
ERROR: No matching distribution found for foo==1.0 (from test==1.0.0)
关于私有 PyPi,我没有任何其他信息,因为我不是它的管理员。正如你所看到的,我只有凭据(username and password)对于该服务器。
此外,PyPi 组织在子文件夹中,https://my.private.pypi/folder/..
我要安装的依赖项在哪里。
更新2:
通过跑步pip install --verbose /tmp/test/dist/test-1.0.0.tar.gz
,看来只有 1 个位置可以搜索图书馆foo
,在公共服务器中https://pypi.org/simple/foo/
并且不在我们的私人服务器中https://my.private.pypi/folder/foo/
.
这里的输出:
...
1 location(s) to search for versions of foo:
* https://pypi.org/simple/foo/
Getting page https://pypi.org/simple/foo/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/foo/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/foo/ HTTP/1.1" 404 13
Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://pypi.org/simple/foo/: 404 Client Error: Not Found for url: https://pypi.org/simple/foo/ - skipping
Given no hashes to check 0 links for project 'foo': discarding no candidates
ERROR: Could not find a version that satisfies the requirement foo==1.0 (from test==1.0.0) (from versions: none)
Cleaning up...
Removing source in /private/var/...
Removed build tracker '/private/var/...'
ERROR: No matching distribution found for foo==1.0 (from test==1.0.0)
Exception information:
Traceback (most recent call last):
...