5

I'd like to install dependencies from my private PyPI by specifying them within a setup.py.

I've already tried to specify where to find dependencies within the dependency_links this way:

setup(
    ...

    install_requires=["foo==1.0"],
    dependency_links=["https://my.private.pypi/"],

    ...
)

I've also tried to define the entire URL within the dependency_links:

setup(
    ...

    install_requires=[],
    dependency_links=["https://my.private.pypi/foo/foo-1.0.tar.gz"],

    ...
)

but when I try to install with python setup.py install, neither of them worked for me.

Can anybody help me?

EDITS:

With the first piece of code I got this error:

...

Installed .../test-1.0.0-py3.7.egg
Processing dependencies for test==1.0.0
Searching for foo==1.0
Reading https://my.private.pypi/
Reading https://pypi.org/simple/foo/
Couldn't find index page for 'foo' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for foo==1.0
error: Could not find suitable distribution for Requirement.parse('foo==1.0')

while in the second case I didn't get any error, just the following:

...

Installed .../test-1.0.0-py3.7.egg
Processing dependencies for test==1.0.0
Finished processing dependencies for test==1.0.0

UPDATE 1:

I've tried to change the setup.py following sinoroc's instructions. Now my setup.py looks like this:

setup(
    ...

    install_requires=["foo==1.0"],
    dependency_links=["https://username:[email protected]/folder/foo/foo-1.0.tar.gz"],

    ...
)

I built the library test with python setup.py sdist and tried to install it with pip install /tmp/test/dist/test-1.0.0.tar.gz, but I still get this error:

Processing /tmp/test/dist/test-1.0.0.tar.gz
ERROR: Could not find a version that satisfies the requirement foo==1.0 (from test==1.0.0) (from versions: none)
ERROR: No matching distribution found for foo==1.0 (from test==1.0.0)

Regarding the private PyPi, I don't have any additional information because I'm not the administrator of it. As you can see, I just have the credentials (username and password) for that server.

Additionally, that PyPi is organised in sub-folders, https://my.private.pypi/folder/.. where the dependency I want to install is.

UPDATE 2:

By running pip install --verbose /tmp/test/dist/test-1.0.0.tar.gz, it seams there is only 1 location where to search for the library foo, in the public server https://pypi.org/simple/foo/ and not in our private server https://my.private.pypi/folder/foo/.

Here the output:

...

1 location(s) to search for versions of foo:
* https://pypi.org/simple/foo/
Getting page https://pypi.org/simple/foo/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/foo/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/foo/ HTTP/1.1" 404 13
Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://pypi.org/simple/foo/: 404 Client Error: Not Found for url: https://pypi.org/simple/foo/ - skipping
Given no hashes to check 0 links for project 'foo': discarding no candidates
ERROR: Could not find a version that satisfies the requirement foo==1.0 (from test==1.0.0) (from versions: none)
Cleaning up...
  Removing source in /private/var/...
Removed build tracker '/private/var/...'
ERROR: No matching distribution found for foo==1.0 (from test==1.0.0)
Exception information:
Traceback (most recent call last):

...
3
  • What error did you get? Commented Nov 4, 2019 at 14:54
  • In the first case I got Couldn't find index page for 'foo' (maybe misspelled?) and in the second case I didn't get any error/warning, simply went through other dependencies
    – alauri
    Commented Nov 4, 2019 at 15:04
  • Can you provide some details about your private package index? Are you using some specific software? Or if something you built yourself, how does the directory tree look like?
    – sinoroc
    Commented Nov 5, 2019 at 9:30

1 Answer 1

2

In your second attempt, I believe you should still have foo==1.0 in the install_requires.


Update

Be aware that pip does not support dependency_links (it used to, but does not anymore).

For pip, the alternative is to use command line options such as --index-url, --extra-index-url, or --find-links. These options can not be enforced on the user of your project (contrary to the dependency links from setuptools), so they have to be properly documented. To facilitate this, a good idea is to provide an example of a requirements.txt file to the users of your project. This file can contain some of pip options.

For example:

# requirements.txt
# ...
--find-links 'https://my.private.pypi/'
foo==1.0
# ...
5
  • Hi sinoroc, thanks for your reply. I've updated the question following your instructions.
    – alauri
    Commented Nov 6, 2019 at 9:58
  • The bit "(from versions: none)" is worrying. It seems to imply that pip (or setuptools) is not able to find any version of foo. Have you double checked that the machine can actually download the .tar.gz file, like with curl or wget for example? Also is there anything relevant appearing when asking for a more verbose output (pip install --verbose /tmp/test/dist/test-1.0.0.tar.gz)?
    – sinoroc
    Commented Nov 6, 2019 at 10:07
  • I'm able to directly download the library, either via curl or from the browser. I've updated to question with output got with pip install --verbose
    – alauri
    Commented Nov 6, 2019 at 11:00
  • 1
    Oh... But somewhere along the way you went from setuptools to pip. Your original question mentioned python setup.py install, then in your updates you started mentioning pip install instead. But pip doesn't support dependency_links (some older versions do). Can you try again with python setup.py install? For pip there are alternatives.
    – sinoroc
    Commented Nov 6, 2019 at 11:09
  • 1
    Sorry, my fault, I was doing two different tests together! With python setup.py install and following your suggestions it works! Now, the problem is that I'd need to do the same with pip, can you please tell me which are the alternatives for it? PS: I'll accept your answer
    – alauri
    Commented Nov 6, 2019 at 11:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.