question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pipenv lock fails for packages with extras as of 2022.8.13

See original GitHub issue

Issue description

There was a regression in the ability to lock Pipfiles containing packages with extras on the 2022.8.13 release. This was working fine on versions prior to 2022.8.13. I believe this is as a result of the changes introduced in #5234

Expected result

Given the Pipfile in the replicate section, it should lock, showing

Locking [dev-packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Updated Pipfile.lock (3e8e27)!

Actual result

[ResolutionFailure]:   File "***.venv/lib/python3.10/site-packages/pipenv/resolver.py", line 824, in _main
[ResolutionFailure]:       resolve_packages(
[ResolutionFailure]:   File "***.venv/lib/python3.10/site-packages/pipenv/resolver.py", line 772, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "***.venv/lib/python3.10/site-packages/pipenv/resolver.py", line 751, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "***.venv/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 1126, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "***.venv/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 919, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "***.venv/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 723, 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: Constraints cannot have extras

Steps to replicate

With the following Pipfile

[packages]
"uvicorn[standard]" = "~=0.18.2"

[dev-packages]
pytest = "~=7.1.1"

[requires]
python_version = "3.9"

Run pipenv lock

Note that there is a package with ‘extras’, namely uvicorn[standard]. This issue does not occur with normal packages.

The change to lock the packages first and then treat that lock as constraints for the dev packages seems to raise the exception that the extras are not allowed.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:33 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
dqkqdcommented, Sep 1, 2022

Or maybe I’m wrong, PipDeprecationWarning says Constraints are only allowed to take the form of a package name and a version specifier so it should not containts url. In that case we could easily fix that by using new_dep.is_named.

new_dep = Requirement.from_pipfile(dep_name, dep) 
    if new_dep.is_named and is_constraints(new_dep.as_ireq()): 
        c = new_dep.as_line().strip() 
        constraints.append(c) 

But the documentation does not say that. So maybe it could have url as constraints? I tried using this constraints file with pip and it did work.

# constraints file
django-redis @ https://github.com/antoniomika/django-redis/archive/4.12.2.zip 
1reaction
matteiuscommented, Sep 2, 2022

@dqkqd I found this interesting and has a lot of context: https://github.com/pypa/pip/issues/8210

That was a long read, but the conclusion is that “unnamed constraints are not allowed.”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release and Version History — pipenv 2022.12.20.dev0 ...
Fix for pipenv lock fails for packages with extras as of 2022.8.13 . #5274. Revert the exclusion of BAD_PACKAGES from batch_install in order...
Read more >
pipenv Documentation - Read the Docs
Fix for pipenv lock fails for packages with extras as of 2022.8.13. #5274. • Revert the exclusion of BAD_PACKAGES from batch_install in order...
Read more >
How to fix locking failed in pipenv? - Stack Overflow
It seems like a library is requiring a version >= importlib-metadata 2.0 . When I pinned the following dependencies it didn't work at...
Read more >
pipenv · PyPI
shell Spawns a shell within the virtualenv. sync Installs all packages specified in Pipfile.lock. uninstall Uninstalls a provided package and removes it from ......
Read more >
Common Pipenv Errors and How to Solve Them: Why Won't it ...
Pipfile Management: Specifying Versions ... The second most common reason locking fails is that we attempt to install a package that is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found