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

Improve behaviour when installing package with build failures that causes backtracking #775

Closed
dgdguk opened this issue Dec 9, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@dgdguk
Copy link

dgdguk commented Dec 9, 2021

I had an interesting experience installing Mercurial on a new machine. The actual cause of failures was due to not having python3-dev installed. However, pipx's possibly relevant error message was:

SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

It took a while for me to work out what was going on, but this seems to be the issues:

  1. pipx only reports exceptions; if a package fails to build but doesn't raise an exception (e.g. Mercurial without python3-dev installed), pipx will swallow the output without alerting the user.
  2. If a package fails to install, pipx tries the previous version. However, in this case, it was going all the way back to Python 2 versions of Mercurial, which were raising a SyntaxError because of the changes in Python 3.

How to reproduce

pipx install mercurial on an Ubuntu machine with python-is-python3 installed and python3-dev not installed. Pipx's logs will have the useful output from the build process, but the terminal interface will hide this in favor of the SyntaxError from trying to install a Python2 package on Python3.

Expected behavior

  1. If a package fails to build without an exception, pipx should highlight that message to the user
  2. If going to a lower version of a package, pipx should inform the user that it tried a lower version and any exceptions raised in those packages are from lower versions (because these may be fixed)
  3. Also if going to a lower version of a package, pipx should make sure that the package is appropriate for the Python version before trying to install it.
@uranusjr
Copy link
Member

Hmm, yeah, that’s an unfortunate combination of characteristics. I think perhaps a solution (that’s entirely contained in pipx) would be that, on pipx install package, instead of trying to install any version of package, pipx would first discover that latest installable version (with pip index behind the scenes), and act like the user had passed pipx install package==version instead.

What do you think? Would you be interested in working on this change to improve the situation?

@dgdguk
Copy link
Author

dgdguk commented Dec 14, 2021

I'm unfortunately busy for the forseeable, so wouldn't have time to learn enough of the pipx codebase to implement a fix. Maybe in the future, but not for a while. I certainly wouldn't object to someone else trying to implement this.

In any case, even if no-one ends up working on this, this bug report should make it easier for other people who encounter this error to figure out what's going on.

@uranusjr uranusjr added the enhancement New feature or request label Dec 14, 2021
@uranusjr
Copy link
Member

No problem, we are all volunteers, and I understand it’s not always viable for people to contribute. Let’s leave this open for someone else interested in improving the situation.

@uranusjr uranusjr changed the title Behaviour when installing package with insufficient build reqs Improve behaviour when installing package with build failures that causes backtracking Dec 14, 2021
@uranusjr
Copy link
Member

If we’re lucky, someone might want to fix it in pip as an alternative: pypa/pip#10655. If I understand correctly, this would automatically make this particular problem go away since pip won’t try older versions when the latest fails to build, and pipx can proceed to show the error message emitted by pip for that build failure.

@dgdguk
Copy link
Author

dgdguk commented Aug 7, 2022

It looks like as I was reporting this issue here, someone was already working on changing the default behavior of pip to not backtrack. That was merged some time ago (https://github.com/pypa/pip/pull/107220), which has fixed this issue

@dgdguk dgdguk closed this as completed Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants