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

Use current and requested Python versions in requires-python incompatibility errors #986

Merged
merged 8 commits into from
Jan 22, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jan 19, 2024

Closes #806

@zanieb zanieb added the error messages Messaging when something goes wrong label Jan 19, 2024
Comment on lines 2860 to 2890
Because there are no versions of Python that satisfy Python>=3.11,<3.12 and there are no versions of Python that satisfy Python>=3.12, we can conclude that Python>=3.11 are incompatible.
Because Python 3.9 does not satisfy Python>=3.11,<3.12 and Python 3.9 does not satisfy Python>=3.12, we can conclude that Python>=3.11 are incompatible.
Copy link
Member Author

Choose a reason for hiding this comment

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

Well this message didn't get worse but what the heck is it saying? TODO create an issue tracking this bug

// We assume there is _only_ one available Python version as Puffin only supports
// resolution for a single Python version; if this is not the case for some reason
// we'll just fall back to the usual verbose message in production but panic in
// debug builds
Copy link
Member

Choose a reason for hiding this comment

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

I think this actually isn't true because if you use --python-version, we'll have both the installed and the target version in the tree, and either one could be incompatible (or both). So we might want to make it explicit that this only works if --python-version isn't provided (and remove the debug assert), or find a way to accommodate that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah gee... we should accommodate that somehow thanks for catching it.

Copy link
Member Author

@zanieb zanieb Jan 19, 2024

Choose a reason for hiding this comment

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

Addressed by eeadecd

# Conflicts:
#	crates/puffin/tests/pip_compile.rs
#	crates/puffin/tests/pip_install_scenarios.rs
@zanieb zanieb force-pushed the zb/python branch 3 times, most recently from e0c5f63 to 462f9a8 Compare January 19, 2024 20:25
@zanieb zanieb changed the title Use current Python version in requires-python incompatibility errors Use current and requested Python versions in requires-python incompatibility errors Jan 19, 2024
@zanieb zanieb requested a review from charliermarsh January 19, 2024 22:33
{
// Simple case, the installed version is the same as the target version
// N.B. Usually the target version does not include anything past the
// minor version mumber so we only compare to part of the installed
Copy link
Member

Choose a reason for hiding this comment

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

Are they not exactly the same when not provided? I think I would've expected --python-version 3.10 to be treated as --python-version 3.10.0. I'm just wondering if this will be correct if the user uses a different patch version in the resolution.

Copy link
Member Author

Choose a reason for hiding this comment

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

If a target Python version is provided e.g. --python-version 3.11

DEBUG puffin_resolver::resolver Solving with target Python 3.11.6 and installed Python 3.12.0

If the target Python version is inferred from the current version

DEBUG puffin_resolver::resolver Solving with target Python 3.12 and installed Python 3.12.0

If a target Python version is provided with patch version e.g. --python-version 3.11.3

DEBUG puffin_resolver::resolver Solving with target Python 3.11.3 and installed Python 3.12.0

If a target Python version is provided but not installed e.g. --python-version 3.13

DEBUG puffin_resolver::resolver Solving with target Python 3.13 and installed Python 3.12.0

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 compare the full target to the first two numbers of the installed so we should only have equality here when --python-version is not provided.

Let me know if I can make the this clearer in my comment.

Copy link
Member

@charliermarsh charliermarsh Jan 21, 2024

Choose a reason for hiding this comment

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

These are helpful...

(So first, I am assuming that 3.12 and 3.12.0 are considered equal when you use == with Version. I'm pretty sure this is true and per spec. In that case, we shouldn't need to do the .take(2) thing.)

If a target Python version is provided e.g. --python-version 3.11

I initially thought this one was a bug, because 3.11 should've resolved to 3.11.0. But then I realized we do a thing whereby we assume the highest known minor. That behavior kind of feels wrong in hindsight... I think it exists because --python-version 3.7 would otherwise use 3.7.0, and a lot of things aren't compatible with the first few patch releases in 3.7, and that was a confusing user experience in my testing. But it might be wrong...

If the target Python version is inferred from the current version

So these should match based on Version equality, I think.

If a target Python version is provided with patch version e.g. --python-version 3.11.3

These should be considered unequal based on Version equality.

If a target Python version is provided but not installed e.g. --python-version 3.13

This seems right to me, they'd be considered unequal based on version equality. But it shouldn't have to do with whether the target is installed.

Copy link
Member

Choose a reason for hiding this comment

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

Which case specifically would be wrong if we used == instead of take(2)?

Copy link
Member

Choose a reason for hiding this comment

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

Why would we see 3.12.1 != 3.12 though? Why is one of the versions not inclusive of the patch, when you don't provide a --python-version? Isn't that wrong?

Copy link
Member Author

@zanieb zanieb Jan 22, 2024

Choose a reason for hiding this comment

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

I have no idea why it's implemented that way, but yes as noted above if the target version is inferred from the current Python version it will not include the patch version. I'm all for changing that behavior if it was not intentional, but it doesn't seem like we should do it here.

Here's another commit showing the installed version alongside the target one: 43910a8e

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I think the right order of operations is to fix the missing patch version (in a separate PR) and then rebase this on top of that. Otherwise, we're adding a workaround for a bug that we need to fix immediately. But feel free to merge, I see the issue and can fix now.

Copy link
Member

Choose a reason for hiding this comment

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

Tossed something up here 🤞 #1033

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for fixing it!

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Looks good to me though one question about the .take(2) that I'd like to understand better before merging.

@zanieb zanieb merged commit 6202c9e into main Jan 22, 2024
3 checks passed
@zanieb zanieb deleted the zb/python branch January 22, 2024 06:32
zanieb added a commit that referenced this pull request Jan 22, 2024
In #986 there was some confusion
about what these values are set to and I noticed that we never actually
display the target version being used for a resolution.

- Consistently display the Python interpreter being used, i.e. make it
clear that we are referring the the interpreter/installed Python version
and always show the version number
- Display the target Python version during solving
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve requires-python incompatibility message
2 participants