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

Fill Python requests with platform information during automatic fetches #4810

Merged
merged 2 commits into from
Jul 5, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jul 4, 2024

Closes #4800

We do this during install — it's an important step to ensure the request has the platform information in it.

@zanieb zanieb added the bug Something isn't working label Jul 4, 2024
@@ -88,7 +88,7 @@ impl PythonInstallation {
// Perform a fetch aggressively if managed Python is preferred
if matches!(preference, PythonPreference::Managed) && python_fetch.is_automatic() {
if let Some(request) = PythonDownloadRequest::try_from_request(&request) {
return Self::fetch(request, client_builder, cache).await;
return Self::fetch(request.fill(), client_builder, cache).await;
Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, perhaps we should be doing this a bit further down in Self::fetch?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or in ManagedPythonDownload::from_request to make sure we never miss it?

Copy link
Member

Choose a reason for hiding this comment

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

Why don't we have to do it on line 106?

Copy link
Member Author

Choose a reason for hiding this comment

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

We should. Great indication that we should enforce this elsewhere haha

Copy link
Member

Choose a reason for hiding this comment

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

Lol

Copy link
Member

Choose a reason for hiding this comment

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

Could they have distinct types?

Copy link
Member

Choose a reason for hiding this comment

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

Like fill returns a different type that you can only get by calling fill. That would have the benefit of making it impossible to miss while also giving us the flexibility to fill when we want (vs. coupling with the constructor).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that sounds reasonable but there are a weird amount of requests types to cast between already and I'd want to think a little more holistically if we add another.

@zanieb
Copy link
Member Author

zanieb commented Jul 4, 2024

@konstin could you check this resolves the issue on Linux please?

@zanieb zanieb marked this pull request as ready for review July 4, 2024 15:44
@zanieb
Copy link
Member Author

zanieb commented Jul 4, 2024

The need for a lightweight testing story for Python toolchain commands grows...

@konstin
Copy link
Member

konstin commented Jul 5, 2024

Still failing for me:

$ rm -rf ~/.local/share/uv/ ~/.cache/uv/ && cargo run -q -- tool install --preview -p 3.12 --force black --python-preference only-managed
error: Failed to query Python interpreter at `/home/konsti/.local/share/uv/python/cpython-3.12.3-macos-aarch64-none/install/bin/python3`
  Caused by: Exec format error (os error 8)

@zanieb
Copy link
Member Author

zanieb commented Jul 5, 2024

@konstin that's because I didn't change it in the other place Charlie pointed out

@charliermarsh
Copy link
Member

I'm gonna add and merge for now -- we can revisit if we wanna do something better.

@charliermarsh charliermarsh enabled auto-merge (squash) July 5, 2024 21:04
@charliermarsh charliermarsh merged commit c0ca0b0 into main Jul 5, 2024
47 checks passed
@charliermarsh charliermarsh deleted the zb/python-fill branch July 5, 2024 21:13
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.

uv tool: Wrong toolchain platform, arch used
3 participants