How can I make setuptools install a package from another source that's also available on pypi with the same version number?

roberkules picture roberkules · Jun 14, 2012 · Viewed 8.5k times · Source

It's a similar question to How can I make setuptools install a package that's not on PyPI? but not the same.

As I would like to use the forked version of some package, setuptools ignore the dependency link (as it has the same version number).

Is there a way to force using the link from the dependency_links? Or is the only way to change the version number in the forked repo?

requires = [
    ...
    'pyScss==1.1.3'
    ...

dependencies = [
    'https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3'
]

Update

Weird, apparently it works if this package is the only one in the required list, that is not installed yet. If there's another missing package it will download it from pypi.

Answer

user146416 picture user146416 · Jun 14, 2012

I believe you can just use dependency_links as described in that question:

from setuptools import setup

setup(name = 'mypkg',
    version = '0.0.1',
    description = 'Foo',
    author = 'bar',
    author_email = '[email protected]',
      install_requires = ['pyScss==1.1.3'],
      dependency_links = [
      'https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3'
      ]
    )

Tested using python setup.py develop

You probably want to rename the egg to emphasize it's a fork http://www.python.org/dev/peps/pep-0386/

Outside of the setup.py you can enforce this locally using requirements.txt and pip. Whilst this won't make your package depend on the fork you can easily document it as the way to install.

$ cat requirements.txt
https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3
$ pip install -r requirements.txt