26

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.

Community
  • 1
  • 1
roberkules
  • 6,389
  • 1
  • 40
  • 51
  • @IlyaBaryshev, sorry but I only use the workaround I describe in the update. installing/updating all packages, then uninstall this specific one and then it's the only missing package - in this case it will take the link from the dependencies – roberkules Dec 28 '12 at 03:34
  • 1
    I'm authoring a package, so it's not an option. I'm thinking about vendoring all dependencies inside my package, seem like an only option considering buggy setuptools behavior. – Ilya Baryshev Jan 10 '13 at 06:17
  • Might this be a solution to your problem: http://stackoverflow.com/a/17442663/368102? – Heyl1 Jul 03 '13 at 08:00

2 Answers2

10

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 = 'bar@example.com',
      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
  • actually that's what i'm doing... in the `setup` call i pass `install_requires = requires` and `dependency_links = dependencies`. which is basically the same code as yours. – roberkules Jun 14 '12 at 15:25
8

I ended up doing something very similar to the answer in stackoverflow.com/a/17442663/368102.

I need a requests-file github package that name-conflicts with a different requests-file package in PyPi. They both have a version 1.0, and the PyPi version has some higher versions.

The workaround in my ias_tools/setup.py looks like this:

setup(
    ...
    install_requires=[
        'requests-file<=99.99',
    ],
    dependency_links=[
        'https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip#egg=requests-file-99.99'
    ]
)

In my case, I'm using pip so I also had to use --process-dependency-links:

% pip install --process-dependency-links ./ias_tools
You are using pip version 6.0.6, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Processing ./ias_tools
  DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting requests-file<=99.99 (from ias-tools==0.1)
  Downloading https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip
Requirement already satisfied (use --upgrade to upgrade): requests>=1.1.0 in ./venv/lib/python2.7/site-packages (from requests-file<=99.99->ias-tools==0.1)
Installing collected packages: ias-tools, requests-file
  Running setup.py install for ias-tools
  Running setup.py install for requests-file
Successfully installed ias-tools-0.1 requests-file-1.0

I'm not too worried about the deprecation notice, as a pull request was submitted to pip to deprecate the deprecation (after a discussion about it).

Community
  • 1
  • 1
Allen Luce
  • 6,442
  • 2
  • 33
  • 47
  • My build command was `pip install --upgrade -e .`, and I also needed to add `--process-dependency-links`. Thanks for including that piece of info. – Dag Høidahl Sep 05 '16 at 13:30