2

I'm using pipenv to install a package from the PyPI registry of a private GitLab project, like this:

pipenv install --index https://<my-gitlab-instance>/api/v4/projects/<my-project-id>/packages/pypi/simple <my-python-package>

The actual installation of the package succeeds, but the command later fails in the locking step. Here's part of the command's output:

Installing <my-python-package>...
Adding <my-python-package> to Pipfile's [packages]...
Installation Succeeded
Pipfile.lock (xxxxxx) out of date, updating to (yyyyyy)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
           Building requirements...
Resolving dependencies...
Locking Failed!

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement <my-python-package> (from versions: none)

The error message says it can't find any version of the package... but it already found and installed a version of the package, so that makes no sense.

I confirmed that the package was installed by importing stuff from it in a python console in the pipenv virtual environment.

I'm using pipenv version 2021.11.15.

Any idea why the locking step fails or how I can debug it?

1 Answer 1

4

I think this is a pipenv bug, and I've reported it here.

The pipenv install command generates a Pipfile that looks like this:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
<my-package> = {version = "*", index = "https://<my-gitlab-instance>/api/v4/projects/<my-project-id>/packages/pypi/simple"}
...

I think that's correct, yet pipenv lock fails on it, so that's apparently a bug in pipenv lock.

A workaround is to manually factor out the private PyPI registry as an additional [[source]] block, like so:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[[source]]
url = "https://<my-gitlab-instance>/api/v4/projects/<my-project-id>/packages/pypi/simple"
verify_ssl = true
name = "mypypi"

[packages]
<my-package> = {version = "*", index = "mypypi"}
...
Sign up to request clarification or add additional context in comments.

1 Comment

Just a note, you can also inject variables into the url. url = "https://$USERNAME:${PASSWORD}@mypypi.example.com/simple" More on this here: pipenv-fork.readthedocs.io/en/latest/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.