Ryan de Kleer
Ryan de Kleer

Reputation: 1363

setup.py dependency_links not searched for install_requires

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/[email protected]#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:

...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:

Upvotes: 1

Views: 2412

Answers (1)

Tomas
Tomas

Reputation: 155

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/[email protected]#egg=shotgun_api3']
    dependency_links = [
        "git+https://github.com/shotgunsoftware/[email protected]#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.

Upvotes: 2

Related Questions