Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/uv-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ pub struct EnvironmentOptions {
pub no_env_file: EnvFlag,
pub venv_seed: EnvFlag,
pub venv_clear: EnvFlag,
pub init_bare: EnvFlag,
}

impl EnvironmentOptions {
Expand Down Expand Up @@ -749,6 +750,7 @@ impl EnvironmentOptions {
no_env_file: EnvFlag::new(EnvVars::UV_NO_ENV_FILE)?,
venv_seed: EnvFlag::new(EnvVars::UV_VENV_SEED)?,
venv_clear: EnvFlag::new(EnvVars::UV_VENV_CLEAR)?,
init_bare: EnvFlag::new(EnvVars::UV_INIT_BARE)?,
})
}
}
Expand Down
5 changes: 5 additions & 0 deletions crates/uv-static/src/env_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ impl EnvVars {
#[attr_added_in("0.3.0")]
pub const UV_TOOL_BIN_DIR: &'static str = "UV_TOOL_BIN_DIR";

/// Equivalent to the `--bare` argument for `uv init`. If set, uv will only create a
/// `pyproject.toml`.
#[attr_added_in("0.10.7")]
pub const UV_INIT_BARE: &'static str = "UV_INIT_BARE";

/// Equivalent to the `--build-backend` argument for `uv init`. Determines the default backend
/// to use when creating a new project.
#[attr_added_in("0.8.2")]
Expand Down
2 changes: 2 additions & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ impl InitSettings {
)
.unwrap_or(kind.packaged_by_default());

let bare = resolve_flag(bare, "bare", environment.init_bare).is_enabled();

let filesystem_install_mirrors = filesystem
.map(|fs| fs.install_mirrors.clone())
.unwrap_or_default();
Expand Down
46 changes: 46 additions & 0 deletions crates/uv/tests/it/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,52 @@ fn init_bare_opt_in() {
});
}

#[test]
fn init_bare_env_var() {
let context = uv_test::test_context!("3.12");

uv_snapshot!(context.filters(), context.init().arg("foo").env(EnvVars::UV_INIT_BARE, "true"), @"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Initialized project `foo` at `[TEMP_DIR]/foo`
");

context
.temp_dir
.child("foo/README.md")
.assert(predicate::path::missing());
context
.temp_dir
.child("foo/hello.py")
.assert(predicate::path::missing());
context
.temp_dir
.child("foo/.python-version")
.assert(predicate::path::missing());
context
.temp_dir
.child("foo/.git")
.assert(predicate::path::missing());

let pyproject = context.read("foo/pyproject.toml");
insta::with_settings!({
filters => context.filters(),
}, {
assert_snapshot!(
pyproject, @r#"
[project]
name = "foo"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []
"#
);
});
}

// General init --script correctness test
#[test]
fn init_script() -> Result<()> {
Expand Down
Loading