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

Support uvx python and uvx python@<version> #7430

Closed
zanieb opened this issue Sep 16, 2024 · 5 comments · Fixed by #11076
Closed

Support uvx python and uvx python@<version> #7430

zanieb opened this issue Sep 16, 2024 · 5 comments · Fixed by #11076
Labels
enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged uv tool Related to the uv tool interface

Comments

@zanieb
Copy link
Member

zanieb commented Sep 16, 2024

To improve the experience of spawning an interactive REPL

Related

@zanieb zanieb added uv tool Related to the uv tool interface enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged labels Sep 16, 2024
@Aditya-PS-05
Copy link
Contributor

@zanieb,
According to question -> support uvx python
Internally it will be work as uv run python.

Am I corrected? Is there something else?

@zanieb
Copy link
Member Author

zanieb commented Sep 17, 2024

uvx python is an alias for uv tool run python which would create an isolated empty environment. uv run python will use existing environments if it can find it — it's a bit different in that sense.

@mikeleppane
Copy link
Contributor

@zanieb If it's okay, I would be interested in taking a look at this 🕵‍♂️. If possible, could you give some hints on where to start with this?

@zanieb
Copy link
Member Author

zanieb commented Sep 17, 2024

@mikeleppane sweet! Probably around

let target = Target::parse(target, from.as_deref());

I'm not sure what the best way to refactor it is. Maybe we want a new Target variant Python which we then special-case?

@zanieb
Copy link
Member Author

zanieb commented Sep 17, 2024

Then we'd have to introduce more variants for python@latest and such though, so maybe we just want to special case the "python" name around

// Resolve the `--from` requirement.
let from = match target {
// Ex) `ruff`
Target::Unspecified(name) => Requirement {
name: PackageName::from_str(name)?,
extras: vec![],
marker: MarkerTree::default(),
source: RequirementSource::Registry {
specifier: VersionSpecifiers::empty(),
index: None,
},
origin: None,
},
// Ex) `ruff@0.6.0`
Target::Version(name, version) | Target::FromVersion(_, name, version) => Requirement {
name: PackageName::from_str(name)?,
extras: vec![],
marker: MarkerTree::default(),
source: RequirementSource::Registry {
specifier: VersionSpecifiers::from(VersionSpecifier::equals_version(
version.clone(),
)),
index: None,
},
origin: None,
},
// Ex) `ruff@latest`
Target::Latest(name) | Target::FromLatest(_, name) => Requirement {
name: PackageName::from_str(name)?,
extras: vec![],
marker: MarkerTree::default(),
source: RequirementSource::Registry {
specifier: VersionSpecifiers::empty(),
index: None,
},
origin: None,
},
// Ex) `ruff>=0.6.0`
Target::From(_, from) => resolve_names(
vec![RequirementsSpecification::parse_package(from)?],
&interpreter,
settings,
&state,
connectivity,
concurrency,
native_tls,
cache,
printer,
)
.await?
.pop()
.unwrap(),
};

mikeleppane added a commit to mikeleppane/uv that referenced this issue Sep 18, 2024
zanieb added a commit that referenced this issue Jan 30, 2025
Supersedes #7491
Closes #7430

Thanks @mikeleppane for starting this implementation. I took a bit of a
different approach and it was easier to start over fresh, but I used
some of the test cases there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged uv tool Related to the uv tool interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants