uv
uv copied to clipboard
Package not importable post install without a process restart
So this is a weird one that involves the editables project, cc @pfmoore for awareness. Originally reported via https://github.com/tox-dev/tox-uv/issues/41, but created a simpler reproducer here. Consider the following test file (first demonstrating with pip) called magic.py
from __future__ import annotations
import inspect
import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "editables"])
from editables import EditableProject
print(inspect.getfile(EditableProject))
Which works and does the expected thing:
❯ virtualenv venv --clear; venv/bin/python magic.py
created virtual environment CPython3.12.2.final.0-64 in 187ms
creator CPython3Posix(dest=/Users/bgabor8/git/github/tox-uv/venv, clear=True, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, via=copy, app_data_dir=/Users/bgabor8/Library/Application Support/virtualenv)
added seed packages: pip==24.0
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Collecting editables
Using cached editables-0.5-py3-none-any.whl.metadata (3.1 kB)
Using cached editables-0.5-py3-none-any.whl (5.1 kB)
Installing collected packages: editables
Successfully installed editables-0.5
/Users/bgabor8/git/github/tox-uv/venv/lib/python3.12/site-packages/editables/__init__.py
When doing the same with uv, altered the test file via magic-uv.py:
from __future__ import annotations
import inspect
import subprocess
subprocess.check_call(["uv", "pip", "install", "editables"])
from editables import EditableProject
print(inspect.getfile(EditableProject))
Which then fails with:
❯ rm .venv -rf; uv venv; .venv/bin/python magic_uv.py
Using Python 3.12.2 interpreter at: /Users/bgabor8/.pyenv/versions/3.12.2/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate.fish
Resolved 1 package in 1ms
Installed 1 package in 2ms
+ editables==0.5
Traceback (most recent call last):
File "/Users/bgabor8/git/github/tox-uv/magic_uv.py", line 7, in <module>
from editables import EditableProject
ModuleNotFoundError: No module named 'editables'
It might be macOS only... per the original reporter, but is really weird because is only problem the first run:
~/git/github/tox-uv on main [!?⇕]
❯ .venv/bin/python -c 'import editables'