Remix.run Logo
akx 15 days ago

> Using pip-installed libraries brings in the famous packaging problems, but you don't have to use it!

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.
indentit 14 days ago | parent [-]

And if you come back to this script in a few years time and it pulls a newer version of numpy with an incompatible api, there is no easy way of knowing which version it was designed to be used with...

zanecodes 14 days ago | parent | next [-]

Only if you didn't run `uv lock --script` [0] and commit the lockfile. If you don't want that second file sitting next to the script, you could instead specify an `exclude-newer` timestamp, and uv won't resolve any dependency versions newer than that.

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...

akx 14 days ago | parent | prev [-]

You can of course absolutely use `"numpy~=1.12"` as a requirement.