From 4b2e67955fc355c69766101f60e182e88094b4da Mon Sep 17 00:00:00 2001 From: Zander <34827878+Zander-1024@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:45:53 +0800 Subject: [PATCH] fixed uv can't create .venv for cpython-x86 on Windows (#2707) Adaptation to the win32 platform is added. https://docs.python.org/3/library/sysconfig.html#sysconfig.get_platform ## Summary fixed uv can't create .venv for cpython-x86 on Windows [uv can't create .venv for cpython-x86 on Windows ](https://github.com/astral-sh/rye/issues/952) --------- Co-authored-by: Nashan <34827878+zhuang1234@users.noreply.github.com> --- .github/workflows/ci.yml | 26 +++++++++++++++++++ .../python/get_interpreter_info.py | 12 ++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b2bdeab4..472d1eb95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -543,6 +543,32 @@ jobs: - name: "Validate global Python install" run: py -3.10 ./scripts/check_system_python.py --uv ./uv.exe + system-test-windows-x86-python-310: + needs: build-binary-windows + name: "check system | python3.10 on windows x86" + runs-on: windows-latest + env: + # Avoid debug build stack overflows. + UV_STACK_SIZE: 2000000 # 2 megabyte, double the default on windows + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + architecture: "x86" + + - name: "Download binary" + uses: actions/download-artifact@v4 + with: + name: uv-windows-${{ github.sha }} + + - name: "Print Python path" + run: echo $(which python) + + - name: "Validate global Python install" + run: python ./scripts/check_system_python.py --uv ./uv.exe + system-test-windows-python-313: needs: build-binary-windows name: "check system | python3.13 on windows" diff --git a/crates/uv-interpreter/python/get_interpreter_info.py b/crates/uv-interpreter/python/get_interpreter_info.py index 3a8917c9e..353caffae 100644 --- a/crates/uv-interpreter/python/get_interpreter_info.py +++ b/crates/uv-interpreter/python/get_interpreter_info.py @@ -415,7 +415,17 @@ def get_operating_system_and_architecture(): """ # https://github.com/pypa/packaging/blob/cc938f984bbbe43c5734b9656c9837ab3a28191f/src/packaging/_musllinux.py#L84 # Note that this is not `os.name`. - [operating_system, version_arch] = sysconfig.get_platform().split("-", 1) + # https://docs.python.org/3/library/sysconfig.html#sysconfig.get_platform + # windows x86 will return win32 + platform_info = sysconfig.get_platform().split("-", 1) + if len(platform_info) == 1: + if platform_info[0] == "win32": + operating_system, version_arch = "win", "i386" + else: + # unknown_operating_system will flow to the final error print + operating_system, version_arch = platform_info[0], "" + else: + [operating_system, version_arch] = platform_info if "-" in version_arch: # Ex: macosx-11.2-arm64 version, architecture = version_arch.rsplit("-", 1)