Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add juv stamp for time-based dependency resolution pinning #50

Merged
merged 12 commits into from
Nov 13, 2024
Merged

Conversation

manzt
Copy link
Owner

@manzt manzt commented Nov 13, 2024

This PR introduces the juv stamp command, which sets an exclude-newer timestamp for constraining dependency resolution in uv by time. This approach significantly improves the ergonomics of using this feature for little scripts, especially in the absence of traditional lockfiles.

By pinning a specific timestamp, juv stamp ensures that uv resolves dependencies as they existed at that point in time. This means you can stamp your scripts before you share them with others, or when you commit scripts or notebooks to version control systems.

New Command: juv stamp

The juv stamp command pins a timestamp as exclude-newer in the metadata of the target file, effectively locking the dependency resolution context:

juv init foo.ipynb

# Stamp the current time
juv stamp foo.ipynb

# Stamp a specific timestamp
juv stamp foo.ipynb --time "2020-03-05T00:00:00-05:00"

# Stamp using a date (resolves to midnight in the system's local timezone)
juv stamp foo.ipynb --date 2022-01-03

# Stamp a specific Git revision
juv stamp foo.ipynb --rev e20c99

# Stamp the latest commit time
juv stamp foo.ipynb --latest

The juv stamp command also works with regular Python scripts. This feature will land eventually in uv (via a config command, but until then you can use this CLI for your uv scripts with uvx:

uv init --script foo.py
uv add --script foo.py polars anywidget
uvx juv stamp foo.py

@manzt manzt added the enhancement New feature or request label Nov 13, 2024
@manzt manzt changed the title Add stamp command Add juv stamp for time-based dependency resolution Nov 13, 2024
@manzt manzt changed the title Add juv stamp for time-based dependency resolution Add juv stamp for more ergonomic time-based dependency resolution pinning Nov 13, 2024
@manzt manzt changed the title Add juv stamp for more ergonomic time-based dependency resolution pinning Add juv stamp for time-based dependency resolution pinning Nov 13, 2024
@manzt manzt merged commit 14c5fa6 into main Nov 13, 2024
13 checks passed
@manzt manzt deleted the manzt/stamp branch November 13, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant