Skip to content

Comments

Add --bare option to uv init#11192

Merged
zanieb merged 2 commits intomainfrom
zb/bare
Feb 5, 2025
Merged

Add --bare option to uv init#11192
zanieb merged 2 commits intomainfrom
zb/bare

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Feb 3, 2025

People are looking for a less opinionated version of uv init. The goal here is to create a pyproject.toml and nothing else. With the --lib or --package flags, we'll still configure a build backend but we won't create the source tree. This disables things like the default description, author behavior, and VCS.

See

@zanieb zanieb added the cli Related to the command line interface label Feb 3, 2025
.map(|fs| fs.install_mirrors.clone())
.unwrap_or_default();

let no_description = no_description || (bare && description.is_none());
Copy link
Member Author

@zanieb zanieb Feb 3, 2025

Choose a reason for hiding this comment

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

This is a little dubious (implementation-wise), but I didn't want to get sucked into refactoring the description handling.

@zanieb zanieb marked this pull request as ready for review February 3, 2025 19:56
@zanieb
Copy link
Member Author

zanieb commented Feb 3, 2025

I'll want to add some prose documentation too, but let's see where this goes first.

@zanieb zanieb requested a review from charliermarsh February 3, 2025 19:57
@zanieb
Copy link
Member Author

zanieb commented Feb 3, 2025

Also open to another name? I'm not sure what though.

Some people in the linked issues think this should be the default and everything else should be opt-in. I'm a little hesitant about that.

@Gankra
Copy link
Contributor

Gankra commented Feb 3, 2025

Some people in the linked issues think this should be the default and everything else should be opt-in. I'm a little hesitant about that.

I do think this flag/mode is a good baseline for other flags to opt back into features. (--bare --vcs=git ...).

Copy link
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

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

Don't have a strong opinion of the name but the impl seems reasonable.


/// Set the project description.
#[arg(long, conflicts_with = "script")]
#[arg(long, conflicts_with = "script", overrides_with = "no_description")]
Copy link
Contributor

Choose a reason for hiding this comment

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

huh, TIL

};

// Initialize the version control system.
init_vcs(path, vcs)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait hold on shouldn't these be wrapped too (in a few places?)

Copy link
Member Author

Choose a reason for hiding this comment

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


/// Only create a `pyproject.toml`.
///
/// Disables creating extra files like `README.md`, the `src/` tree, `.python-version` files,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether --bare should still create a .python-version file (if one doesn't already exist), given how integral it is to the deterministic operation of uv? It seems like most of the feedback about unwanted files/content were about the .py files and directory nesting, rather than the .python-version file - so people might be fine with it left in?

Copy link
Member Author

Choose a reason for hiding this comment

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

People are sort of constantly complaining about the .python-version file actually :/

It don't think it's required for reasonably deterministic action if you have a requires-python in your project. You may be on a different version than someone else, but the lockfile will be consistent.

Copy link
Contributor

@edmorley edmorley Feb 3, 2025

Choose a reason for hiding this comment

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

People are sort of constantly complaining about the .python-version file actually :/

Yeah I've seen quite a few comments, but from what I remember they were in other issues (not about uv init defaults), and generally were about lack of understanding why the seemingly duplicate concepts were needed.

I think longer term perhaps campaigning for an additional Python version field to be added to the pyproject.toml spec would resolve the "why do I need another file" concerns, but for now I think having a pinned Python version via a .python-version file really is still important. Otherwise the day after uv adds support for eg Python 3.14, some developers on a project will end up using Python 3.14 (with lack of wheels), whereas others on their team (who may not have updated uv yet) could still be using Python 3.13 etc - leading to only some people seeing build failures (due to building from source), CI failures, lack of dev-prod parity etc.

It's very likely I'm going to make a missing .python-version file a hard error when deploying a uv app on Heroku for example.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think your take is fair.

My primary concern is that it doesn't make much sense to teach --bare if it does more than just create a pyproject.toml with standards-compliant fields. I'd rather add opt-in support via --pin-python and suggest using it.

It seems feasible that there'd be interest in a standard for a Python version pin in the pyproject.toml; especially now that there are dependency groups that do not require [project] metadata. I'm not excited about trying to pitch it though :D I agree this is the obvious long-term solution over a non-standard .python-version file.

@zanieb zanieb merged commit acbbb2b into main Feb 5, 2025
73 checks passed
@zanieb zanieb deleted the zb/bare branch February 5, 2025 16:12
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 6, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.5.27` -> `0.5.29` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.5.29`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0529)

[Compare Source](astral-sh/uv@0.5.28...0.5.29)

##### Enhancements

-   Add `--bare` option to `uv init` ([#&#8203;11192](astral-sh/uv#11192))
-   Add support for respecting `VIRTUAL_ENV` in project commands via `--active` ([#&#8203;11189](astral-sh/uv#11189))
-   Allow the project `VIRTUAL_ENV` warning to be silenced with `--no-active` ([#&#8203;11251](astral-sh/uv#11251))

##### Python

The managed Python distributions have been updated, including:

-   CPython 3.12.9
-   CPython 3.13.2
-   pkg-config files are now relocatable

See the [`python-build-standalone` release notes](https://github.com/astral-sh/python-build-standalone/releases/tag/20250205) for more details.

##### Bug fixes

-   Always use base Python discovery logic for cached environments ([#&#8203;11254](astral-sh/uv#11254))
-   Use a flock to avoid concurrent initialization of project environments ([#&#8203;11259](astral-sh/uv#11259))
-   Fix handling of `--all-groups` and `--no-default-groups` flags ([#&#8203;11224](astral-sh/uv#11224))

##### Documentation

-   Minor touchups to the Docker provenance docs ([#&#8203;11252](astral-sh/uv#11252))
-   Move content from the `mkdocs.public.yml` into the template ([#&#8203;11246](astral-sh/uv#11246))

### [`v0.5.28`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0528)

[Compare Source](astral-sh/uv@0.5.27...0.5.28)

##### Bug fixes

-   Allow discovering virtual environments from the first interpreter found on the `PATH` ([#&#8203;11218](astral-sh/uv#11218))
-   Clear ephemeral overlays when running tools ([#&#8203;11141](astral-sh/uv#11141))
-   Disable SSL in Git commands for `--allow-insecure-host` ([#&#8203;11210](astral-sh/uv#11210))
-   Fix hardlinks in tar unpacking ([#&#8203;11221](astral-sh/uv#11221))
-   Set base executable when returning virtual environment ([#&#8203;11209](astral-sh/uv#11209))
-   Use base Python for cached environments ([#&#8203;11208](astral-sh/uv#11208))

##### Documentation

-   Add documentation on verifying Docker image attestations ([#&#8203;11140](astral-sh/uv#11140))
-   Add `last updated` to documentation ([#&#8203;11164](astral-sh/uv#11164))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNTguMSIsInVwZGF0ZWRJblZlciI6IjM5LjE1OC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command line interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants