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

Print more user friendly error when --python version not found #1171

Merged
merged 12 commits into from
Jan 3, 2024

Conversation

Gitznik
Copy link
Contributor

@Gitznik Gitznik commented Dec 27, 2023

  • I have added an entry to docs/changelog.md

Summary of changes

Resolves #1089

Capture FileNotFound error during the install command and exit with a meaningful error message if it indicates that the provided python version was not found.

I think it would actually be nice to do the handling in venv.create_venv which is where the error surfaces. This would mean that the handling is uniform for all places that use this functionality (commands/run, commands/common, commands/install), bit it would also introduce a return value to this function.

def create_venv(...) -> None: -> def create_venv(...) -> EXIT_CODE_OK | EXIT_CODE_SPECIFIED_PYTHON_EXECUTABLE_NOT_FOUND:

If that's desired I'm happy to change the code accordingly.

Test plan

Tested by running nox -s tests-3.12

$ python3 src/pipx install --python python3.2 cowssay
> No executable for the provided Python version 'python3.2' found.
> Please make sure the executable name is on your PATH/the path to the executable is correct.

Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

CI failing.

@Gitznik
Copy link
Contributor Author

Gitznik commented Dec 29, 2023

CI failing.

Windows was not covered, should be fixed now.

Copy link
Contributor

@chrysle chrysle left a comment

Choose a reason for hiding this comment

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

Please rebase.

src/pipx/commands/install.py Outdated Show resolved Hide resolved
Gitznik and others added 2 commits December 30, 2023 15:52
@chrysle
Copy link
Contributor

chrysle commented Dec 30, 2023

Indentation never works with those suggestions :-(

@Gitznik
Copy link
Contributor Author

Gitznik commented Dec 30, 2023

Indentation never works with those suggestions :-(

Yeah that would be too easy. Does the message look fine to you now? I got rid of the newline as it is stripped by pipx_wrap anyways.

Looks like this now:
No executable for the provided Python version 'python3.2' found. Please make sure the executable name is on your PATH / the path to the executable is correct., one line.

Copy link
Contributor

@chrysle chrysle left a comment

Choose a reason for hiding this comment

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

Thanks! Unfortunately, one release chases the other these days...
I'm afraid you'll have to rebase once more.

@gaborbernat gaborbernat enabled auto-merge (squash) January 3, 2024 21:08
@gaborbernat gaborbernat merged commit 2b131cb into pypa:main Jan 3, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Better handling of pipx install error when requested python version not available
3 participants