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 PEP 723 support to uv run #4656

Merged
merged 1 commit into from
Jul 1, 2024
Merged

Add PEP 723 support to uv run #4656

merged 1 commit into from
Jul 1, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jun 29, 2024

Closes #3096

Summary

Enables uv run foo.py to execute PEP 723-compatible scripts.

For example, given:

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "requests<3",
#   "rich",
# ]
# ///

import requests
from rich.pretty import pprint

resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])

Screenshot 2024-06-29 at 7 23 52 PM

@charliermarsh charliermarsh added the preview Experimental behavior label Jun 29, 2024
@charliermarsh
Copy link
Member Author

There are some refactors I want to do as a follow-up.

@charliermarsh
Copy link
Member Author

Should we suppress output here...?

metadata.requires_python.map(|requires_python| {
ToolchainRequest::Version(VersionRequest::Range(requires_python))
})
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will DRY this up separately, I need to audit the usages.

charliermarsh added a commit that referenced this pull request Jun 30, 2024
## Summary

Small refactor broken out from #4656.
Base automatically changed from charlie/run to main June 30, 2024 14:40
@charliermarsh charliermarsh force-pushed the charlie/pep723 branch 2 times, most recently from c5dcbe4 to c7f73da Compare June 30, 2024 14:45
@charliermarsh charliermarsh merged commit bfadade into main Jul 1, 2024
47 checks passed
@charliermarsh charliermarsh deleted the charlie/pep723 branch July 1, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PEP 723 support to uv run
3 participants