Skip to content

Commit 24d35f6

Browse files
committed
Release v0.1.1: Fix package interception bug
- Prevent auto-uv from intercepting installed packages (dbt, pytest, pip, etc.) - Add intelligent filtering for site-packages, venv bin directories - Fixes Fatal Python error when using tools like 'dbt debug' - Only intercepts user scripts, not system/package scripts
1 parent 3791281 commit 24d35f6

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "auto-uv"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "Automatically use 'uv run' when executing Python scripts"
55
keywords = ['uv', 'package manager', 'automation', 'python', 'development']
66
authors = [

src/auto_uv.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,33 @@ def auto_use_uv():
3434
1. We're not already running under uv
3535
2. UV_RUN_ACTIVE environment variable is not set
3636
3. uv is available in the system
37-
4. We're running a script (not interactive or -c command)
37+
4. We're running a user script (not a package/tool script)
3838
3939
If all conditions are met, it re-executes the script with 'uv run'.
40+
41+
Note: This function intelligently skips interception for:
42+
- Installed packages (site-packages, dist-packages)
43+
- Virtual environment executables (bin/, Scripts/)
44+
- Python installation scripts
45+
This prevents interference with tools like dbt, pytest, pip, etc.
4046
"""
4147
# Only intercept if running a script file
4248
if len(sys.argv) > 0 and sys.argv[0] and os.path.isfile(sys.argv[0]):
49+
script_path = os.path.abspath(sys.argv[0])
50+
51+
# Don't intercept if script is in site-packages or installed packages
52+
# This prevents interference with tools like dbt, pip, etc.
53+
if "site-packages" in script_path or "dist-packages" in script_path:
54+
return
55+
56+
# Don't intercept if script is in a virtual environment's bin/Scripts directory
57+
if os.path.sep + "bin" + os.path.sep in script_path or os.path.sep + "Scripts" + os.path.sep in script_path:
58+
return
59+
60+
# Don't intercept if script is in Python installation directory
61+
if sys.prefix in script_path or sys.base_prefix in script_path:
62+
return
63+
4364
if should_use_uv():
4465
# Set environment variable to prevent infinite loop
4566
env = os.environ.copy()

0 commit comments

Comments
 (0)