Skip to content

pypi: export setup.py switches that opt into mypyc - #2018

Open
pohlarized wants to merge 2 commits into
google:mainfrom
pohlarized:agent-upstream-pr-r2/pypi-setup-mypyc-env-gate
Open

pohlarized wants to merge 2 commits into
google:mainfrom
pohlarized:agent-upstream-pr-r2/pypi-setup-mypyc-env-gate

Conversation

@pohlarized

Copy link
Copy Markdown
Collaborator

mypy compiles itself with mypyc only when MYPY_USE_MYPYC=1, which its
wheel builds set. Without it the rebuild produces a pure Python wheel and
auditwheel rejects the result.

When the wheel contains a mypyc "__mypyc" library, set each
*_USE_MYPYC variable that setup.py reads to 1. Only do so when mypyc is
importable, from a mypy requirement or mypy's own source tree. The wheel
does not record which mypy compiled it, so no unpinned mypy is added.

Parents: #2017

@pohlarized pohlarized self-assigned this Nov 10, 2026
@pohlarized pohlarized added feature request New feature or request go Pull requests that update go code labels Nov 10, 2026
@pohlarized
pohlarized marked this pull request as ready for review November 10, 2026 14:01
@pohlarized
pohlarized requested a review from msuozzo November 10, 2026 14:01
Some setup.py files compile their Cython extensions only when an
environment variable asks for it, so that source installs without a
compiler still work. Upstream CI sets the variable, as charset-normalizer
does with CHARSET_NORMALIZER_USE_CYTHON and fonttools with
FONTTOOLS_WITH_CYTHON. Without it the rebuild takes the pure Python path
and auditwheel rejects the result.

Add a BuildEnv map to PlatformWheelBuild, validated in ToWorkflow and
exported in sorted order before the wheel build. When the wheel's modules
record a Cython version, set each *_USE_CYTHON or *_WITH_CYTHON variable
that setup.py reads to 1, and *_CYTHON_ABI3 only for abi3 wheels.
mypy compiles itself with mypyc only when MYPY_USE_MYPYC=1, which its
wheel builds set. Without it the rebuild produces a pure Python wheel and
auditwheel rejects the result.

When the wheel contains a mypyc "<group>__mypyc" library, set each
*_USE_MYPYC variable that setup.py reads to 1. Only do so when mypyc is
importable, from a mypy requirement or mypy's own source tree. The wheel
does not record which mypy compiled it, so no unpinned mypy is added.
@pohlarized
pohlarized force-pushed the agent-upstream-pr-r2/pypi-setup-mypyc-env-gate branch from f0cb698 to a8bd9d4 Compare November 12, 2026 21:50

This branch has not been deployed

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

Labels

feature request New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant