by akx · 1y ago · 0 comments
These days, with uv and PEP 723 inline script metadata, that's not an issue either.
# /// script
# dependencies = ["numpy"]
# requires-python = ">=3.12"
# ///
import numpy as np
and uv run myscript.py
will just Do The Right Thing.It might be cool if uv ignored dependency versions newer than the script's last modified timestamp, but this behavior would probably need to be very explicit to avoid the situation where a working script is mysteriously broken by making an innocuous change which updates its last modified timestamp, causing uv to resolve a newer, incompatible dependency version.
[0] https://docs.astral.sh/uv/guides/scripts/#locking-dependenci...