pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.1k stars 309 forks source link

PythonInfo's use of platform.check_command() can make troubleshooting difficult #1758

Open rsyring opened 1 month ago

rsyring commented 1 month ago

I use mise to manage my Python installs and virtualenvs. For whatever reason, the way it creates and upgrades it's Python installs causes existing virtualenvs to break. When that happens, I just clear the old virtualenvs out and start over.

A week or two ago, I upgraded my Python version. Today, I jumped into a project I hadn't used for awhile and ran hatch version on a project that uses a dynamic version. The version command exited with no output and an exit code of 1.

It took me some time to track down what was going on (a broken venv) due to the lack of any kind of debugging output. This is due to PythonInfo's use of platform.check_command() which raises a SystemExit exception if the called command has any kind of error. SystemExit causes the interpreter to exit with no output.

IMO, the troubleshooting DX would improve by showing the output of a failed command. Maybe just switching check_command() to run_command() would be sufficient here.

You can easily generate a test case by modifying DEP_CHECK_DATA_SCRIPT so it throws an error. Then run hatch version.