Skip to content

fix: seed build's isolated env with the pinned pip - #3018

Merged
henryiii merged 2 commits into
pypa:mainfrom
henryiii:fix/graalpy-build-pip
Oct 21, 2026
Merged

henryiii merged 2 commits into
pypa:mainfrom
henryiii:fix/graalpy-build-pip

Conversation

@henryiii

Copy link
Copy Markdown
Contributor

馃 AI text below 馃

Fixes #2984.

With the build frontend, build's isolated virtualenv seeds the pip that virtualenv bundles (26.2.2 now), not the pinned pip. pip 26.2 vendors urllib3 2.7.0, which imports ssl.VERIFY_X509_PARTIAL_CHAIN directly. GraalPy 25.0.x does not have this constant, so pip fails with TypeError: Can't create an SSLContext object without an ssl module. The GraalPy pin from #2955 only applies to cibuildwheel's own build venv, so it does not prevent this.

This PR sets VIRTUALENV_PIP to the build venv's pip version on macOS and Windows. A user-set VIRTUALENV_PIP still takes priority. Linux is not changed: manylinux installs build without the virtualenv extra, and GraalPy there uses its own patched pip.

The new test test_build_isolated_env_pip_version pins pip==25.3 and checks the pip version inside build's isolated env. I ran the same project by hand on gp312_250-macosx_arm64. It fails without the fix (('26.2.2', '25.3')) and passes with it. I could not run the CPython test locally, because there are no python.org installs on this machine.

build's virtualenv backend seeded its own bundled pip, ignoring the
dependency constraints. On GraalPy 25.0, pip 26.2 (urllib3 2.7) cannot
create an SSLContext, so builds failed even though pip is pinned for
GraalPy. Set VIRTUALENV_PIP to the build venv's pip on macOS and Windows.

Fixes pypa#2984.

Assisted-by: ClaudeCode:claude-opus-5-5
On Windows, build uses the outer pip, so the isolated env has no pip.

Assisted-by: ClaudeCode:claude-opus-5-5
@joerick

joerick commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Hm. Last time I checked this, VIRTUALENV_PIP had no effect on build.

I think the behaviour depends on whether virtualenv is installed. But I think build doesn't have access to virtualenv in the venvs that cibuildwheel makes.

@henryiii

henryiii commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

This does fix GraalPy on macOS (tested before fixing). I was fixing #2984.

馃 AI text below 馃

It depends on the backend that build selects. build uses the outer pip with venv only if the outer pip's RECORD lists pip/_vendor (_has_valid_outer_pip). Otherwise, if virtualenv is importable (we install build[virtualenv] on macOS and Windows), build uses virtualenv+pip, and virtualenv seeds its own bundled pip.

On macOS, we create the build venv with --symlink-app-data. With that seeder, pip's RECORD has only 7 entries and no pip/_vendor, so build falls back to virtualenv. The CI logs here show virtualenv+pip on macOS and venv+pip on Windows, where we don't use symlinks. That is why VIRTUALENV_PIP does nothing on Windows or Linux, and it explains what you saw before.

I checked locally with GraalPy 25.0.3 on macOS arm64. Without this change, the build fails with the #2984 SSLContext error. With it, the isolated env gets pip 26.1.2 and the build succeeds.

@joerick

joerick commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

I checked myself locally and you're right, VIRTUALENV_PIP does take effect. Not sure what was going on last year. Maybe I made a mistake, or there was a bug.

@henryiii
henryiii merged commit 4463120 into pypa:main Oct 21, 2026
43 of 45 checks passed
@henryiii
henryiii deleted the fix/graalpy-build-pip branch October 21, 2026 21:07
@neutrinoceros

neutrinoceros commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Is it possible that this patch caused what looks like a regression in OpenAstronomy/github-actions-workflows#434 ?

(please be warned, I will not read or reply to AI-generated responses)

@henryiii

Copy link
Copy Markdown
Contributor Author

No, wasn't this one, it was #3017.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraalPy is broken on MacOS in v4.2.0

3 participants