Installing from custom index setup.py

若如初见. 提交于 2019-12-24 11:34:24

问题


I am the package maintainer of a package that has dependencies to packages hosted in our own pip repository.

I want these packages to also be installed when doing pip install mypackage.

setup(
  name='mypackage',
  version='1.1.2',
  description='My awesome package',
  dependency_links=[
    'http://www.myrepo.se/packages/mydep1/',
    'http://www.myrepo.se/packages/mydep2/'
  ]
  install_requires=[
    'mydep1==1.0.0',
    'mydep2==5.6.7'
  ]
)

The folder structure in the repo is the following:

packages/
  mydep1/
    mydep1-1.0.0.tar.gz
  mydep2/
    mydep2-5.5.1.tar.gz
    mydep2-5.6.7.tar.gz

All according to the accepted answer on this question Using an extra python package index url with setup.py

However, this does not work. I get the error:

Collecting mydep1 (from mypackage==1.1.2)
  Could not find a version that satisfies the requirement mydep1 (from mypackage==1.1.2) (from versions: )
No matching distribution found for mydep1 (from mypackage==1.1.2)

When I have added an extra index url to my requirements.txt before doing it this was I had to add the url as a trusted host. Is that relevant? Also I am using python 3.5.3

EDIT: I activated verbose output from pip and it is not even trying to find the package from my repo.

1 location(s) to search for versions of mydep1:
  * https://pypi.python.org/simple/mydep1/
  Getting page https://pypi.python.org/simple/mydep1/
  ...

回答1:


It seems pip is not processing the dependency links unless you explicitly tell it to (which unfortunately means that all consumers of mypackage must know to do so).

pip install --process-dependency-links mypackage

Since mypackage is also hosted by the same repository it means that a consumers requirements.txt must look like

--trusted-host http://www.myrepo.se/
--extra-index-url http://www.myrepo.se/packages
--process-dependency-links

mypackage==1.1.2


来源:https://stackoverflow.com/questions/52735269/installing-from-custom-index-setup-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!