Skip to content

Commit 04daf12

Browse files
build(windows): pre-build pyyaml with --no-build-isolation
After restoring --no-build-isolation for the three local azure-cli installs, the next failure in the win32 MSI build is pyyaml's sdist build in the requirements install: pip._vendor.pyproject_hooks._impl.BackendUnavailable: Cannot import '_pyyaml_pep517' Root cause is the same as for the local installs: pip's isolated PEP 517 BuildEnvironment subprocess cannot import any backend on the win32 embeddable Python because the embed directory is not on sys.path under python -I, so stdlib C extensions are unreachable. PIP_CONSTRAINT correctly installs setuptools<82 into the build env but the subprocess still fails before reaching the backend. PyPI does not ship a cp314 win32 wheel for pyyaml, so pip is forced to build it from sdist. Cython is pyyaml's only extra build requirement and does ship a cp314 win32 wheel. Pre-install Cython into the main env, then install pyyaml itself with --no-build-isolation so it reuses the main env's already-loaded setuptools<82 + wheel + Cython. The subsequent requirements.py3.windows.txt install then finds pyyaml already satisfied and never spawns the failing BuildEnvironment subprocess.
1 parent 01d5284 commit 04daf12

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

build_scripts/windows/scripts/build.cmd

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ for %%a in (%CLI_SRC%\azure-cli %CLI_SRC%\azure-cli-core %CLI_SRC%\azure-cli-tel
202202
popd
203203
)
204204

205+
REM Pre-build pyyaml from sdist with --no-build-isolation. PyPI has no
206+
REM cp314 win32 wheel for pyyaml, so pip would otherwise spin up a PEP 517
207+
REM BuildEnvironment subprocess that fails to import pyyaml's in-tree
208+
REM _pyyaml_pep517 backend on the win32 embeddable Python (same root cause
209+
REM as the local installs above: the embed dir is not on sys.path under
210+
REM python -I, so stdlib C extensions are unreachable). Installing pyyaml
211+
REM into the main env now (which already has setuptools<82 + wheel) makes
212+
REM the requirements install below find it already satisfied. Cython is
213+
REM pyyaml's only extra build requirement and ships a cp314 win32 wheel.
214+
%BUILDING_DIR%\python.exe -Im pip install --no-warn-script-location --no-cache-dir Cython
215+
if %errorlevel% neq 0 goto ERROR
216+
%BUILDING_DIR%\python.exe -Im pip install --no-warn-script-location --no-cache-dir --no-build-isolation pyyaml
217+
if %errorlevel% neq 0 goto ERROR
218+
205219
%BUILDING_DIR%\python.exe -Im pip install --no-warn-script-location --requirement %CLI_SRC%\azure-cli\requirements.py3.windows.txt
206220
if %errorlevel% neq 0 goto ERROR
207221

0 commit comments

Comments
 (0)