It appears `hatch python install` might not pick the correct build
When running hatch run test:test some of the Python versions were not found.
Skipped 2 incompatible environments:
test.py3.9 -> cannot locate Python: 3.9
test.py3.11 -> cannot locate Python: 3.11
I tried doing a hatch python install for the missing versions but that did not fix the problem.
$ hatch python install 3.12
Installed 3.12 @ /home/bill/.local/share/hatch/pythons/3.12
$ hatch run test.py3.12:test
Environment `test.py3.12` is incompatible: cannot locate Python: 3.12
$ which python3.12
/home/bill/.local/share/hatch/pythons/3.12/python/bin/python3.12
$ /home/bill/.local/share/hatch/pythons/3.12/python/bin/python3.12
Illegal instruction (core dumped)
The file ~/.local/share/hatch/pythons/3.12/hatch-dist.json appears to show which file was downloaded to install the Python version.
{
"source": "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.12.0%2B20231002-x86_64_v3-unknown-linux-gnu-install_only.tar.gz",
"python_path": "python/bin/python3"
}
I downloaded cpython-3.12.0+20231002-x86_64_v3-unknown-linux-gnu-install_only.tar.gz and extracted it in a separate location. When I ran the executable in that location I got the same error.
$ ./python3.12
Illegal instruction (core dumped)
I did not dig into the details to know what the difference is between v3 and v2, but I also downloaded cpython-3.12.0+20231002-x86_64_v2-unknown-linux-gnu-install_only.tar.gz and extracted it to another location. When I ran it, it worked.
$ ./python3.12
Cannot read termcap database;
using dumb terminal settings.
Python 3.12.0 (main, Oct 3 2023, 00:33:08) [Clang 17.0.1 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
I copied the python directory from the v2 download to ~/.local/share/hatch/pythons/3.12/ and tried running the 3.12 test again.
$ hatch run test.py3.12:test
============================= test session starts ==============================
...
The tests ran okay.
It appears hatch python install is not picking the correct build for the system (it has an older CPU).
Using Ubuntu 22.04.3 LTS (Xubuntu) running in a VM:
# uname -a:
Linux ... 6.5.0-17-generic #17~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 16 14:32:32 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
# /proc/cpuinfo:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
stepping : 9
cpu MHz : 3192.738
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
...
I hope this helps.
So sorry for the poor experience here! Could you please try using this environment variable during installation as a workaround? https://github.com/pypa/hatch/blob/hatch-v1.9.3/src/hatch/python/resolve.py#L175-L176
I looked at the Running Distributions page and see what the v2 and v3 variant means.
I tried this and the tests ran okay.
hatch python remove 3.12
export HATCH_PYTHON_VARIANT_LINUX="V2"
hatch python install 3.12
hatch run test.py3.12:test
I suppose I should put that environment variable info .bashrc or .profile on systems where that is an issue.
Thanks.
Can you please give me more information about your CPU?
What would be the best way to do that? I am aware of /proc/cpuinfo but there may be a better way - I'm only an accidental sysadmin ;-)
Here is the complete cpuinfo output:
# CPU (/proc/cpuinfo):
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
stepping : 9
cpu MHz : 3192.738
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm pti fsgsbase arat md_clear flush_l1d
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds mmio_unknown
bogomips : 6385.47
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
stepping : 9
cpu MHz : 3192.738
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm pti fsgsbase arat md_clear flush_l1d
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds mmio_unknown
bogomips : 6385.47
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
Do you know where it was purchased? I honestly don't know how to translate that output into when it was made.
A new computer has not been in my budget for a few years so I am still using old hardware. I have been running hatch in a VM, and that cpuinfo is from within the VM. It seems likely the host PC will determine the processor capabilities (unless VirtualBox virtualizes newer capabilities).
The host PC is a Dell Optiplex 9010. I bought it refurbished. I don't know exactly how old it is but according to https://en.wikipedia.org/wiki/Dell_OptiPlex the 9010 model was first released mid 2012.
I looked up the Dell support info for the service tag code. It says this about the processor: "3rd Gen Intel Core i5-3470 Processor (6MB, 3.2GHz) w/HD2500 Graphics, Dell Optiplex 9010"
ark.intel.com is good for info on all their cpus by processor number (here i5-3470), see https://ark.intel.com/content/www/us/en/ark/products/68316/intel-core-i5-3470-processor-6m-cache-up-to-3-60-ghz.html which indeed has launch date Q2 2012.
Fixed by https://github.com/pypa/hatch/pull/1484