Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed uv can't create .venv for cpython-x86 on Windows #2707

Merged
merged 4 commits into from
Apr 3, 2024

Conversation

Zander-1024
Copy link
Contributor

@Zander-1024 Zander-1024 commented Mar 28, 2024

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

Adaptation to the win32 platform is added.
@bluss
Copy link
Contributor

bluss commented Mar 28, 2024

Related to astral-sh/rye/issues/952

if platform_info[0] == "win32":
operating_system, version_arch = "win", "i386"
else:
raise ValueError(f"Unsupported Platform: {platform_info[0]}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use "result": "error" and handle the error in rust code instead of raising exceptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but this is python code, and this function is just to get platform information. For unsupported platforms, you should also exit here. I've thought of two solutions. One is to just exit and add exception printing, and the other is to raise an exception. I think using an exception here might be appropriate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the python code raises an exception, the rust caller doesn't know what went wrong: Is the platform not supported? Is the version not supported? Is this python not a python? Is it a permission error? In rust we get an exit status, stdout and stderr, we can't even tell if we started an actual python interpreter.

Showing a python stacktrace is verbose and not helpful to the user. A user only needs one line (platform not supported) and does not need to see implementation details of our interpreter checking code. Instead, we return that the script ran successfully but the platform was not supported here and transform it into a rust error here. This way we get a clear, concise error message:

$ uv venv
  × Can't use Python at `/home/konsti/projects/uv/.venv/bin/python3`
  ╰─▶ Unknown operation system: `wedontknowthisos`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for your answer

[operating_system, version_arch] = sysconfig.get_platform().split("-", 1)
platform_info = sysconfig.get_platform().split("-", 1)
if len(platform_info) == 1:
if platform_info[0] == "win32":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have some context on why 32-bit windows is the only platform where that happens, and can you add a comment above the line explaining the special case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.python.org/3/library/sysconfig.html#sysconfig.get_platform
According to the documentation, sysconfig.get_platform () returns "win32" when using the x86 version of Windows. This is a known issue. I'll add the documentation to the notes later.

@zanieb zanieb added the bug Something isn't working label Mar 28, 2024
Copy link
Contributor

@T-256 T-256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this just happened to me today. We could also have CI for Windows 32bit.

@zanieb
Copy link
Member

zanieb commented Apr 1, 2024

A "check system" CI job would make sense for that.

@konstin
Copy link
Member

konstin commented Apr 2, 2024

@Zander-1024 Do you want to add a check system check or should we merge without?

@Zander-1024
Copy link
Contributor Author

Sorry, I don't know where the problem with this ci build lies. Looking at the print, I should have installed pylint.

@zanieb
Copy link
Member

zanieb commented Apr 2, 2024

The system check tests require the Python you are testing with to be the default on the system e.g. python3. e.g. you're spawning with a py -3.10 invocation but it needs to be python3 and presumably there will be some futzing to make x86 Python the default?

@zanieb
Copy link
Member

zanieb commented Apr 3, 2024

Thanks!

@zanieb zanieb merged commit 4b2e679 into astral-sh:main Apr 3, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants