pip install dependency links

一个人想着一个人 提交于 2019-11-27 14:45:38

You need to make sure you include the dependency in your install_requires too.

Here's an example setup.py

#!/usr/bin/env python
from setuptools import setup

setup(
    name='foo',
    version='0.0.1',
    install_requires=[
        'balog==0.0.7'
    ],
    dependency_links=[
        'https://github.com/balanced/balog/tarball/master#egg=balog-0.0.7'
    ]
)

Here's the issue with your example setup.py:

You're missing the egg name in the dependency links you setup.

You have

https://github.com/egemsoft/esef-auth/tarball/master/#egg=1.0.0.0

You need

https://github.com/egemsoft/esef-auth/tarball/master/#egg=esef-auth-1.0.0.0

Pip removed support for dependency_links a while back. The latest version of pip that supports dependency_links is 1.3.1, to install it

pip install pip==1.3.1

your dependency links should work at that point. Please note, that dependency_links were always the last resort for pip, ie. if a package with the same name exists on pypi it will be chosen over yours.

Note, https://github.com/pypa/pip/pull/1955 seems to start allowing dependency_links, pip kept it, but you might need to use some command line switches to use a newer version of pip.

EDIT: As of pip 7 ... they rethought dep links and have enabled them, even though they haven't removed the deprecation notice, from the discussions they seem to be here to stay. With pip>=7 here is how you can install things

pip install -e . --process-dependency-links --allow-all-external

Or add the following to a pip.conf, e.g. /etc/pip.conf

[install]
process-dependency-links = yes
allow-all-external = yes
trusted-host =
    bitbucket.org
    github.com

EDIT

A trick I have learnt is to bump up the version number to something really high to make sure that pip doesn't prefer the non dependency link version (if that is something you want). From the example above, make the dependency link look like:

"https://github.com/egemsoft/django-simple-sso/tarball/master#egg=999.0.0",

Also make sure the version either looks like the example or is the date version, any other versioning will make pip think its a dev version and wont install it.

The --process-dependency-links option to enable dependency_links was removed in Pip 19.0.

Instead, you can use a PEP 508 URL to specify your dependency, which is supported since Pip 18.1. Here's an example excerpt from setup.py:

install_requires=[
    "numpy",
    "package1 @ git+https://github.com/user1/package1",
    "package2 @ git+https://github.com/user2/package2@branch1",
],

Note that Pip does not support installing packages with such dependencies from PyPI and in the future you will not be able to upload them to PyPI (see news entry for Pip 18.1).

Costa Huang

I faced a similar situation where I want to use shapely as one of my package dependency. Shapely, however, has a caveat that if you are using windows, you have to use the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/. Otherwise, you have to install a C compiler, which is something I don't want. I want the user to simply use pip install mypackage instead of installing a bunch of other stuffs.

And if you have the typical setup with dependency_links

setup(
  name = 'streettraffic',
  packages = find_packages(), # this must be the same as the name above
  version = '0.1',
  description = 'A random test lib',
  author = 'Costa Huang',
  author_email = 'Costa.Huang@outlook.com',
  install_requires=['Shapely==1.5.17'],
  dependency_links = ['http://www.lfd.uci.edu/~gohlke/pythonlibs/ru4fxw3r/Shapely-1.5.17-cp36-cp36m-win_amd64.whl']
)

and run pip install ., it is simply going to pick the shapely on Pypi and cause trouble on Windows installation. After hours of researching, I found this link Force setuptools to use dependency_links to install mysqlclient and basically use from setuptools.command.install import install as _install to manually install shapely.

from setuptools.command.install import install as _install
from setuptools import setup, find_packages
import pip

class install(_install):
  def run(self):
    _install.do_egg_install(self)

    # just go ahead and do it
    pip.main(['install', 'http://localhost:81/Shapely-1.5.17-cp36-cp36m-win_amd64.whl'])

setup(
  name = 'mypackage',
  packages = find_packages(), # this must be the same as the name above
  version = '0.1',
  description = 'A random test lib',
  author = 'Costa Huang',
  author_email = 'test@outlook.com',
  cmdclass={'install': install}
)

And the script works out nicely. Hope it helps.

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