pex-tool / pex

A tool for generating .pex (Python EXecutable) files, lock files and venvs.
https://docs.pex-tool.org
Apache License 2.0
2.49k stars 254 forks source link

"Resolving wheels disallowed" error when using `--lock` and `--only-binary` #2432

Closed sjincho closed 2 weeks ago

sjincho commented 2 weeks ago

I'm using pex 2.3.1 on Ubuntu 22.04.

If I create a lock file using:

pex3 lock create --output lock.json --only-binary ansicolors ansicolors

and run

pex --lock lock.json

it works w/o problem.

But running:

pex --lock lock.json --only-binary ansicolors

yields the following error:

Resolving wheels was disallowed, but the following project names are configured to only allow resolving pre-built wheels: ansicolors

In Pants 2.21.0, it seems like a change that uses pex to handle binary wheels was introduced. https://github.com/pantsbuild/pants/pull/20598

Due to this change, pants always passes both --lock and --only-binary flags, causing https://github.com/pantsbuild/pants/issues/21077

sjincho commented 2 weeks ago

Similar issue: https://github.com/pex-tool/pex/issues/2389

jsirois commented 2 weeks ago

Thanks for the report and repro. I will note, like #2389 this is a definitely bug, but also a weird use of a lock file. Since a lock is locked already, passing something like --only-binary ansicolors when using the lock doesn't make much sense. It would make a bit more sense if Pants didn't pass all these extra args when using a lock (as opposed to creating or updating one).

jsirois commented 2 weeks ago

The fix for this is now released in Pex 2.4.1: https://github.com/pex-tool/pex/releases/tag/v2.4.1