Skip to content

Comments

Default to uv package manager when launched from uv#5213

Merged
dmadisetti merged 1 commit intomainfrom
trevor/mo-3013-uv-environment-auto-detection-does-not-work
Jun 6, 2025
Merged

Default to uv package manager when launched from uv#5213
dmadisetti merged 1 commit intomainfrom
trevor/mo-3013-uv-environment-auto-detection-does-not-work

Conversation

@manzt
Copy link
Collaborator

@manzt manzt commented Jun 6, 2025

📝 Summary

Fixes #5185. Changes the default package manager to uv when marimo is launched from uv executable (e.g., uv run marimo in a project, or uvx marimo). Expect behavior with this PR (without setting a package manager):

# prefers uv when launched from uv
uv init foo && cd foo
uv add marimo
uv run marimo edit test.py

# prefers pip when inside the environment
source .venv/bin/activate
marimo edit test.py
# prefers uv when run with `uvx`
uvx marimo

We could probably try to be smarter in the case above where it defaults to pip (since uv environments don't have pip installed), but I think this is the safest and has the nice property of the uvx marimo for the first time use case preferring uv.

🔍 Description of Changes

uv run and uv tool run (aka uvx) sets UV to the uv executable path (astral-sh/uv#11326), which we inspect to infer the preferred default package.

I think it's probably most safe to infer the "preferred" package manager is uv when running from inside uv, so this bypasses the pyproject.toml inspection.

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.

📜 Reviewers

@akshayka

@vercel
Copy link

vercel bot commented Jun 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 4:10pm

@manzt manzt changed the title Infer uv as default package manager when running within uv run Infer uv as default package manager (instead of pip) when running within uv run Jun 6, 2025
@manzt manzt changed the title Infer uv as default package manager (instead of pip) when running within uv run Infer uv as default package manager (instead of pip) when launched from uv Jun 6, 2025
`uv run` and `uv tool run` (aka `uvx`) sets `UV` environment var to the
uv executable path. We feature detect this, rather than looking at the
pyproject metadata.
@manzt manzt force-pushed the trevor/mo-3013-uv-environment-auto-detection-does-not-work branch from 5d92aac to abd27c6 Compare June 6, 2025 16:09
@manzt manzt changed the title Infer uv as default package manager (instead of pip) when launched from uv Default to uv package manager when launched from uv Jun 6, 2025
Copy link
Collaborator

@dmadisetti dmadisetti left a comment

Choose a reason for hiding this comment

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

LGTM discussed a bit out of scope too, where UV is not in path- but maybe this could be mitigated by making uv a dep

@dmadisetti dmadisetti merged commit b068f2a into main Jun 6, 2025
34 of 37 checks passed
@dmadisetti dmadisetti deleted the trevor/mo-3013-uv-environment-auto-detection-does-not-work branch June 6, 2025 17:01
@github-actions
Copy link

github-actions bot commented Jun 6, 2025

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.13.16-dev48

Light2Dark pushed a commit that referenced this pull request Jun 9, 2025
## 📝 Summary

Fixes #5185. Changes the default package manager to `uv` when marimo is
launched from `uv` executable (e.g., `uv run marimo` in a project, or
`uvx marimo`). Expect behavior with this PR (without setting a package
manager):


```py
# prefers uv when launched from uv
uv init foo && cd foo
uv add marimo
uv run marimo edit test.py

# prefers pip when inside the environment
source .venv/bin/activate
marimo edit test.py
```

```py
# prefers uv when run with `uvx`
uvx marimo
```

We could probably try to be smarter in the case above where it defaults
to `pip` (since `uv` environments don't have `pip` installed), but I
think this is the safest and has the nice property of the `uvx marimo`
for the first time use case preferring uv.

## 🔍 Description of Changes

`uv run` and `uv tool run` (aka `uvx`) sets `UV` to the `uv` executable
path (astral-sh/uv#11326), which we inspect to
infer the preferred default package.

I think it's probably most safe to infer the "preferred" package manager
is `uv` when running from inside uv, so this bypasses the
`pyproject.toml` inspection.

## 📋 Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [x] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [x] I have added tests for the changes made.
- [x] I have run the code and verified that it works as expected.

## 📜 Reviewers

@akshayka
sebbeutler pushed a commit to sebbeutler/marimo that referenced this pull request Jun 28, 2025
…5213)

## 📝 Summary

Fixes marimo-team#5185. Changes the default package manager to `uv` when marimo is
launched from `uv` executable (e.g., `uv run marimo` in a project, or
`uvx marimo`). Expect behavior with this PR (without setting a package
manager):


```py
# prefers uv when launched from uv
uv init foo && cd foo
uv add marimo
uv run marimo edit test.py

# prefers pip when inside the environment
source .venv/bin/activate
marimo edit test.py
```

```py
# prefers uv when run with `uvx`
uvx marimo
```

We could probably try to be smarter in the case above where it defaults
to `pip` (since `uv` environments don't have `pip` installed), but I
think this is the safest and has the nice property of the `uvx marimo`
for the first time use case preferring uv.

## 🔍 Description of Changes

`uv run` and `uv tool run` (aka `uvx`) sets `UV` to the `uv` executable
path (astral-sh/uv#11326), which we inspect to
infer the preferred default package.

I think it's probably most safe to infer the "preferred" package manager
is `uv` when running from inside uv, so this bypasses the
`pyproject.toml` inspection.

## 📋 Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [x] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [x] I have added tests for the changes made.
- [x] I have run the code and verified that it works as expected.

## 📜 Reviewers

@akshayka
sebbeutler pushed a commit to sebbeutler/marimo that referenced this pull request Jul 7, 2025
…5213)

## 📝 Summary

Fixes marimo-team#5185. Changes the default package manager to `uv` when marimo is
launched from `uv` executable (e.g., `uv run marimo` in a project, or
`uvx marimo`). Expect behavior with this PR (without setting a package
manager):


```py
# prefers uv when launched from uv
uv init foo && cd foo
uv add marimo
uv run marimo edit test.py

# prefers pip when inside the environment
source .venv/bin/activate
marimo edit test.py
```

```py
# prefers uv when run with `uvx`
uvx marimo
```

We could probably try to be smarter in the case above where it defaults
to `pip` (since `uv` environments don't have `pip` installed), but I
think this is the safest and has the nice property of the `uvx marimo`
for the first time use case preferring uv.

## 🔍 Description of Changes

`uv run` and `uv tool run` (aka `uvx`) sets `UV` to the `uv` executable
path (astral-sh/uv#11326), which we inspect to
infer the preferred default package.

I think it's probably most safe to infer the "preferred" package manager
is `uv` when running from inside uv, so this bypasses the
`pyproject.toml` inspection.

## 📋 Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [x] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [x] I have added tests for the changes made.
- [x] I have run the code and verified that it works as expected.

## 📜 Reviewers

@akshayka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv environment auto detection does not work

2 participants