3 ms·
I love uv and really feel like I only need to know "uv add" and "uv sync" to be effective using it with python. That's an incredible feat. But, when I hear abo
by xrd 1y ago
I love uv and really feel like I only need to know "uv add" and "uv sync" to be effective using it with python. That's an incredible feat.
But, when I hear about these kinds of extras, it makes me even more excited. Getting cuda and torch to work together is something I have struggled countless times.
The team at Astral should be nominated for a Nobel Peace Prize.
- eigenvalue 1y agoThey’ve definitely saved me many hours of wasted time between uv and ruff.
- danudey 1y ago> "uv add" One life-changing thing I've been using `uv` for: System python version is 3.12: $ python3 --version Python 3.12.3 A script that requires a library we don't have, and won't work on our local python: $ cat test.py #!/usr/bin/env python3 import sys from rich import print if sys.version_info < (3, 13): print("This script will not work on Python 3.12") else: print(f"Hello world, this is python {sys.version}") It fails: $ python3 test.py Traceback (most recent call last): File "/tmp/tmp/test.py", line 10, in <module> from rich import print ModuleNotFoundError: No module named 'rich' Tell `uv` what our requirements are $ uv add --script=test.py --python '3.13' rich Updated `test.py` `uv` updates the script: $ cat test.py #!/usr/bin/env python3 # /// script # requires-python = ">=3.13" # dependencies = [ # "rich", # ] # /// import sys from rich import print if sys.version_info < (3, 13): print("This script will not work on Python 3.12") else: print(f"Hello world, this is python {sys.version}") `uv` runs the script, after installing packages and fetching Python 3.13 $ uv run test.py Downloading cpython-3.13.5-linux-x86_64-gnu (download) (33.8MiB) Downloading cpython-3.13.5-linux-x86_64-gnu (download) Installed 4 packages in 7ms Hello world, this is python 3.13.5 (main, Jun 12 2025, 12:40:22) [Clang 20.1.4 ] And if we run it with Python 3.12, we can see that errors: $ uv run --python 3.12 test.py warning: The requested interpreter resolved to Python 3.12.3, which is incompatible with the script's Python requirement: `>=3.13` Installed 4 packages in 7ms This script will not work on Python 3.12 Works for any Python you're likely to want: $ uv python list cpython-3.14.0b2-linux-x86_64-gnu <download available> cpython-3.14.0b2+freethreaded-linux-x86_64-gnu <download available> cpython-3.13.5-linux-x86_64-gnu /home/dan/.local/share/uv/python/cpython-3.13.5-linux-x86_64-gnu/bin/python3.13 cpython-3.13.5+freethreaded-linux-x86_64-gnu <download available> cpython-3.12.11-linux-x86_64-gnu <download available> cpython-3.12.3-linux-x86_64-gnu /usr/bin/python3.12 cpython-3.12.3-linux-x86_64-gnu /usr/bin/python3 -> python3.12 cpython-3.11.13-linux-x86_64-gnu /home/dan/.local/share/uv/python/cpython-3.11.13-linux-x86_64-gnu/bin/python3.11 cpython-3.10.18-linux-x86_64-gnu /home/dan/.local/share/uv/python/cpython-3.10.18-linux-x86_64-gnu/bin/python3.10 cpython-3.9.23-linux-x86_64-gnu <download available> cpython-3.8.20-linux-x86_64-gnu <download available> pypy-3.11.11-linux-x86_64-gnu <download available> pypy-3.10.16-linux-x86_64-gnu <download available> pypy-3.9.19-linux-x86_64-gnu <download available> pypy-3.8.16-linux-x86_64-gnu <download available> graalpy-3.11.0-linux-x86_64-gnu <download available> graalpy-3.10.0-linux-x86_64-gnu <download available> graalpy-3.8.5-linux-x86_64-gnu <download available>
- j45 1y agoAgreed, making the virtual environment management and so much else disappear lets so much more focus go to python itself.