gpt4 book ai didi

python - 如何使用 setup.py 安装托管在私有(private) PyPI 中的包?

转载 作者:IT老高 更新时间:2023-10-28 21:03:49 27 4
gpt4 key购买 nike

我正在尝试为具有公共(public)和私有(private)依赖项的私有(private)项目编写 setup.py 安装文件。公共(public)的托管在 PyPI 上,而私有(private)的托管在运行 simplepypi 的服务器上。 .

我希望在安装期间解析和获取公共(public)和私有(private)依赖项。

我因此将我的依赖项添加到 setup.py:

setup(
...
install_requires = [
# public dependencies
'argparse==1.2.1',
'beautifulsoup4==4.1.3',
'lxml==3.1.0',
'mongoengine==0.8.2',
'pymongo==2.5.2',
'requests==1.1.0',
'Cython==0.18',
# private dependencies
'myprivatepackage1',
'myprivatepackage2'
],
dependency_links=['http://pypi.myserver.com/packages'],
...
)

我使用命令 python setup.py sdist 构建包 tarball,并使用 pip install --verbose path/to/tarball.tar.gz 将其安装在激活的 virtualenv 中.

但是,pip 日志行没有在任何地方提及我的私有(private) PyPI 服务器,并且 https://pypi.python.org/simple/好像被查询了两次。

Running setup.py egg_info for package from file:///home/b/code/mapado/mypackage/dist/mypackage-0.5.1.tar.gz
running egg_info
creating pip-egg-info/mypackage.egg-info
writing requirements to pip-egg-info/mypackage.egg-info/requires.txt
writing pip-egg-info/mypackage.egg-info/PKG-INFO
writing top-level names to pip-egg-info/mypackage.egg-info/top_level.txt
writing dependency_links to pip-egg-info/mypackage.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/mypackage.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found

reading manifest file 'pip-egg-info/mypackage.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/mypackage.egg-info/SOURCES.txt'
Downloading/unpacking myprivatepackage (from mypackage==0.5.1)
Could not fetch URL https://pypi.python.org/simple/myprivatepackage/: HTTP Error 404: Not Found (myprivatepackage does not have any releases)
Will skip URL https://pypi.python.org/simple/myprivatepackage/ when looking for download links for myprivatepackage (from mypackage==0.5.1)
Could not fetch URL https://pypi.python.org/simple/myprivatepackage/: HTTP Error 404: Not Found (myprivatepackage does not have any releases)
Will skip URL https://pypi.python.org/simple/myprivatepackage/ when looking for download links for myprivatepackage (from mypackage==0.5.1)
Could not find any downloads that satisfy the requirement myprivatepackage (from mypackage==0.5.1)
Cleaning up...

我错过了什么?

最佳答案

您似乎没有像 simplepy 的文档那样指定您的主机说你需要用好的主机名设置你的 ~/.pypirc

To use it run "simplepypi". You can upload packages by:

[...]

Not using twine yet? Here is the legacy way of uploading Python packages (not recommended):

Modify your ~/.pypirc so it looks like:

[distutils]
index-servers =
pypi
local

[local]
username: <whatever>
password: <doesn't matter, see above>
repository: http://127.0.0.1:8000

[pypi]
...

然后你就可以上传你的包了

python setup.py sdist upload -r local

并且可以从那里安装它

pip install -i http://127.0.0.1:8000/pypi <your favorite package>

希望这会有所帮助。

关于python - 如何使用 setup.py 安装托管在私有(private) PyPI 中的包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18828805/

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