`pipenv install` successfully installs a package from a GitLab project's PyPI registry, but then fails in the locking step

Viewed 871

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 Answers

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"}
...
Related