我想通过在
我已经尝试过在
关于私人 PyPi,我没有额外的信息,因为我不是它的管理员。正如您所看到的,我只有该服务器的凭证(用户名和密码)。 此外,该 PyPi 是以子文件夹的形式组织的,
setup.py
中指定它们来从我的私有PyPI安装依赖项。我已经尝试过在
dependency_links
中指定依赖项的位置,方法如下:setup(
...
install_requires=["foo==1.0"],
dependency_links=["https://my.private.pypi/"],
...
)
我也尝试在dependency_links
中定义整个URL:
setup(
...
install_requires=[],
dependency_links=["https://my.private.pypi/foo/foo-1.0.tar.gz"],
...
)
但是当我尝试使用python setup.py install
安装时,两者都无法正常工作。
有人能帮我吗?
编辑:
使用第一段代码时,我遇到了这个错误:
...
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:
我尝试根据sinoroc的指示修改了setup.py
。现在我的setup.py
看起来像这样:
setup(
...
install_requires=["foo==1.0"],
dependency_links=["https://username:password@my.private.pypi/folder/foo/foo-1.0.tar.gz"],
...
)
我使用 python setup.py sdist
命令构建了库 test
,然后尝试使用 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,我没有额外的信息,因为我不是它的管理员。正如您所看到的,我只有该服务器的凭证(用户名和密码)。 此外,该 PyPi 是以子文件夹的形式组织的,
https://my.private.pypi/folder/..,其中我想要安装的依赖项位于其中。
更新2:
通过运行pip install --verbose /tmp/test/dist/test-1.0.0.tar.gz,似乎只有一个位置可以查找库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):
...