[英]How can I install packages hosted in a private PyPI using setup.py?
我正在嘗試為一個私有項目編寫setup.py
安裝文件,該項目具有公共和私有依賴項。 公共的托管在 PyPI 上,而私有的托管在運行simplepypi的服務器上。
我希望在安裝過程中解析和獲取公共和私有依賴項。
因此,我將我的依賴項添加到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 日志行在任何地方都沒有提到我的私人 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
要使用它,請運行“simplepypi”。 您可以通過以下方式上傳包:
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>
希望這會有所幫助。
默認情況下會忽略dependency_links
(至少在pip 9.0.1 中)
為了讓它聯系到您的服務器,您需要添加--process-dependency-links
我相信pip 10 會帶來一個新的機制,但現在這對我有用
我還必須更新dependency_links
以包含包名稱,例如:
dependency_links=[
"http://internal-pyp:5678/simple/your_package_name"
]
您可以將您的包制作為普通的 pip 包並將其發布到私有存儲庫。 要安裝它,您可以在配置文件中指定全局選項--extra-index-url
:
$ cat ~/.pip/pip.conf
[global]
extra-index-url = https://...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.