hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Hatch Test System Python Option

Open blink1073 opened this issue 1 year ago • 3 comments
trafficstars

We're looking into adopting the hatch test pattern in jupyter_server, but are stuck on the fact that pypy isn't supported. What we'd like to be able to do is tell hatch test to use the system python $(which python) in our CI.

blink1073 avatar May 28 '24 13:05 blink1073

Hey! Do you mean you have an environment already set up with the proper dependencies and you want to avoid that step and start running scripts without any setup phase?

ofek avatar May 28 '24 13:05 ofek

I mean effectively UV_SYSTEM_PYTHON since we're using uv under the hood.

blink1073 avatar May 28 '24 15:05 blink1073

I ran into a similar issue in my CI, which I fixed by setting the HATCH_PYTHON environment variable to the appropriate path: https://github.com/SupImDos/pydantic-argparse/pull/67

It seems like there should be a better / more intuitive way to do this though. Without having thought about it too much, I'm not sure that the preferred Python should be the one Hatch is using - especially since Hatch seems to install Python 3.12 along with itself (at least in CI).

https://github.com/pypa/hatch/blob/d73037fe7e9b66eeeba2e72d37074373594221c5/src/hatch/env/virtual.py#L325-L333

Maybe the resolution order should prefer the Python version in the active shell (i.e., $(which python)) first?

SupImDos avatar Jul 09 '24 03:07 SupImDos