pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.29k stars 628 forks source link

Using resolves_to_only_binary causes "Resolving wheels was disallowed..." error in 2.21 #21077

Closed sjincho closed 2 weeks ago

sjincho commented 3 months ago

Describe the bug Using resolves_to_only_binary causes "Resolving wheels was disallowed, but the following project names are configured to only allow resolving pre-built wheels" error when running pants test ::.

Pants version 2.21.0

OS Linux

Additional info Steps to reproduce:

  1. Clone https://github.com/sjincho/pants-2-21-only-binary
    • This repo is based on example-python. The only change I made is to add ansicolors package to resolves_to_binary and re-run generate-lockfiles.
  2. Run pants test ::
  3. Error:
    
    15:48:54.42 [INFO] Canceled: Building pytest.pex from resource://pants.backend.python.subsystems/pytest.lock
    15:48:55.47 [INFO] Completed: Building 2 requirements for requirements.pex from the python-default.lock resolve: setuptools<57,>=56.2.0, types-setuptools<58,>=56.2.0
    15:48:55.49 [ERROR] 1 Exception encountered:

Engine traceback: in test goal

ProcessExecutionFailure: Process 'Building 2 requirements for requirements.pex from the python-default.lock resolve: setuptools<57,>=56.2.0, types-setuptools<58,>=56.2.0' failed with exit code 1. stdout:

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

Use --keep-sandboxes=on_failure to preserve the process chroot for inspection.



The error seems to be caused by the new flag `--no-pre-install-wheels` when running `pex`.
sjincho commented 3 months ago

I did some more testing, and figured out that this seems to be caused by not --no-pre-install-wheels, but https://github.com/pantsbuild/pants/pull/20598.

As noted in https://github.com/pex-tool/pex/issues/2432, it seems like pex throws the error above when both --lock and --only-binary flags are set.

sjincho commented 3 months ago

FYI, pex release https://github.com/pex-tool/pex/releases/tag/v2.4.1 fixes the underlying issue.

krishnan-chandra commented 2 weeks ago

The default version of pex in more recent Pants releases is now well past 2.4.1, so I think this can safely be closed now. In Pants 2.21, you can fix the issue by overriding the version of the pex-cli tool in your pants.toml file.