Skip to content

Commit

Permalink
uv init ignores workspace when --isolated flag is used
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jul 22, 2024
1 parent 4797259 commit 5eff6a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ pub(crate) async fn init(
explicit_path: Option<String>,
name: Option<PackageName>,
no_readme: bool,
isolated: bool,
preview: PreviewMode,
printer: Printer,
) -> Result<ExitStatus> {
if preview.is_disabled() {
warn_user_once!("`uv init` is experimental and may change without warning");
}

let current_dir = std::env::current_dir()?.canonicalize()?;

// Default to the current directory if a path was not provided.
let path = match explicit_path {
None => current_dir.clone(),
None => std::env::current_dir()?.canonicalize()?,
Some(ref path) => PathBuf::from(path),
};

Expand Down Expand Up @@ -67,10 +66,14 @@ pub(crate) async fn init(
let path = path.canonicalize()?;

// Discover the current workspace, if it exists.
let workspace = match ProjectWorkspace::discover(&path, None).await {
Ok(project) => Some(project),
Err(WorkspaceError::MissingPyprojectToml) => None,
Err(err) => return Err(err.into()),
let workspace = if isolated {
None
} else {
match ProjectWorkspace::discover(&path, None).await {
Ok(project) => Some(project),
Err(WorkspaceError::MissingPyprojectToml) => None,
Err(err) => return Err(err.into()),
}
};

// Create the `pyproject.toml`.
Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ async fn run_project(
args.path,
args.name,
args.no_readme,
globals.isolated,
globals.preview,
printer,
)
Expand Down

0 comments on commit 5eff6a1

Please sign in to comment.