1

This question has been asked several times around the site, but the answer frequently seems to be an omission of the install_requires arg.
Not the case here.

I'm trying to build a wheel that can be pip installed in a way that also installs a required package that's not on PyPI.

my setup.py includes:

setup(
    install_requires= ['shotgun-api3']
    dependency_links = [
        "git+https://github.com/shotgunsoftware/python-api.git@v3.0.36#egg=shotgun_api3"
    ],
    # ...
)

From the commandline I then run python setup.py sdist bdist_wheel to generate the /dist/mypackage-0.1.0-py2-none-any.whl.

Rather than upload my package to an index, I'm trying to install my package from the filesystem; so in a clean virtualenv, I then run: pip -v install mypackage --no-index --find-links file:///F:/RyDev/myproject/dist --process-dependency-links.

And I get:

DistributionNotFound: No matching distribution found for shotgun-api3 (from mypackage)

and because I used the verbose flag, I see:

Collecting shotgun-api3 (from mypackage)
  0 location(s) to search for versions of shotgun-api3:
  Skipping link file:///F:/RyDev/mypackage/dist/mypackage-4.0.0-py2-none-any.whl; wrong project name (not shotgun-api3)
  Skipping link file:///F:/RyDev/mypackage/dist/mypackage-4.0.0.tar.gz; wrong project name (not shotgun-api3)

It's maybe worth noting:

  • if I remove the install_requires arg from setup.py, mypackage will pip install without errors...just without the dependency.
  • I can run pip install git+https://github.com/shotgunsoftware/python-api.git@v3.0.36#egg=shotgun_api3 and it successfully installs the shotgun-api3 package.

...but for the life of me, I can't seem to get shotgun-api3 to install as a dependency for mypackage.

It looks to me like the (git) URL I provided to dependency_links isn't being included in the list of locations, so I'm wondering if I'm missing something around that?

Environment:

  • Python 2.7.13 (cannot upgrade)
  • Windows 7 (cannot switch OS)
  • pip 10.0.1
  • setuptools 39.2.0
  • virtualenv 16.0.0
  • wheel 0.31.1
Ryan de Kleer
  • 1,246
  • 14
  • 24
  • If I remember correctly, `pip` expects the package name in `install_requires` to match the egg name and link in `dependency_links`, so it must be smth like `install_requires=['python-api']` and the dep link `github.com/shotgunsoftware/python-api.git@v3.0.36#egg=python-api`. It will still install package named `shotgun-api3` because the real name will be taken from the setup script. – hoefling May 24 '18 at 13:01
  • You're right about the name match, but it looks like `shotgun_api3` really is the name. I'd cloned the source and built the egg locally, and it generates `shotgun_api3-3.0.36-py2.7.egg`, so I'm thinking it must be something else? – Ryan de Kleer May 24 '18 at 16:09
  • ...again, the verbose output seems to indicate not that it can't find the package at the URL, but rather that it doesn't even look in the URL at all. – Ryan de Kleer May 24 '18 at 16:11
  • Did you ever find the solution for this? I am having the same issue right now: https://stackoverflow.com/questions/52735269/installing-from-custom-index-setup-py – Hampus Oct 10 '18 at 08:48

1 Answers1

2

As for your setup.py:

In pip 19.0 and later, dependency_links is ignored. Use the PEP 508 syntax to specify the URLs to be used by pip:

setup(
    install_requires= ['shotgun-api3 @ git+https://github.com/shotgunsoftware/python-api.git@v3.0.36#egg=shotgun_api3']
    dependency_links = [
        "git+https://github.com/shotgunsoftware/python-api.git@v3.0.36#egg=shotgun_api3"
    ],
    # ...
)

I've left your dependency_links in because nested dependencies in pip make use of setuptools, as discussed today in the comments of another StackOverflow question.

Regarding the installation:

Since I don't have your local packages it's not possible to check if this answer solves your problem. Be sure to remove the --process-dependency-links part when testing it though, because that is no longer supported in the latest pip either.

Alternatively, to install your local package, try pip install -e . instead of manually compiling and specifying everything.

Tomas
  • 155
  • 9