Skip to content

pipenv install --index <my-pypi-registry> <my-package> generates a Pipfile that pipenv lock can't handle #4873

@ben-g-

Description

@ben-g-

I start from a completely blank slate -- no Pipfile, no Pipfile.lock, no virtual environment. And I execute a command like

pipenv install --index <my-pypi-registry> <my-package>

where <my-pypi-registry> is a private PyPI registry (not a mirror of the public PyPI registry!) that hosts the package <my-package>.

The result of the command is:

  • a virtual environment is successfully created
  • and a Pipfile is generated
  • but locking fails.
...
Successfully created virtual environment!
Virtualenv location: C:\tmp\tmp-venv\.venv
Creating a Pipfile for this project...
Installing <my-package>...
Adding <my-package> to Pipfile's [packages]...
Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
 Locking...Building requirements...
Resolving dependencies...
Locking Failed!

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement <my-package> (from versions: none)
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\resolver.py", line 743, in _main
[ResolutionFailure]:       resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\resolver.py", line 704, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\resolver.py", line 685, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\utils.py", line 1370, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\utils.py", line 1099, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "c:\python391\lib\site-packages\pipenv\utils.py", line 877, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for <my-package>

The generated Pipfile looks like this:

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

[packages]
<my-package> = {version = "*", index = "<my-pypi-registry>"}
...

That looks reasonable, but pipenv lock fails on it with the error shown above.

However, if I manually change the Pipfile to look like this, then pipenv lock succeeds, even though this seems essentially the same:

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

[[source]]
url = "<my-pypi-registry>"
verify_ssl = true
name = "mypypi"

[packages]
<my-package> = {version = "*", index = "mypypi"}
...

If (again starting from a completely blank slate) I replace --index with --extra-index-url, so my command looks like this:

pipenv install --extra-index-url <my-pypi-registry> <my-package>

then the command's output looks the same, meaning

  • a virtual environment is successfully created
  • and a Pipfile is generated
  • but locking fails with the same error as above.

However, in this case, the generated Pipfile is clearly wrong, in that it doesn't reference <my-pypi-registry> at all, so it's not surprising that pipenv lock fails on it. It looks like this:

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

[packages]
<my-package> = "*"
...

In summary, this might be two separate bugs.

  1. pipenv lock fails on the seemingly correct Pipfile generated by pipenv install --index ....
  2. pipenv install --extra-index-url ... generates an incorrect Pipfile.

I'm using pipenv version 2021.11.15, which I installed using pip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions