Skip to content

Commit

Permalink
Create .python-version files in projects even if one exists outside…
Browse files Browse the repository at this point in the history
… of it (#8896)
  • Loading branch information
zanieb authored Nov 7, 2024
1 parent 9c1c393 commit 00fb6d0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,10 +716,12 @@ impl InitProjectKind {
}
fs_err::write(path.join("pyproject.toml"), pyproject)?;

// Write .python-version if it doesn't exist.
// Write .python-version if it doesn't exist in the target or is empty.
if let Some(python_request) = python_request {
if PythonVersionFile::discover(path, &VersionFileDiscoveryOptions::default())
.await?
.filter(|file| file.version().is_some())
.filter(|file| file.path().parent().is_some_and(|parent| parent == path))
.is_none()
{
PythonVersionFile::new(path.join(".python-version"))
Expand Down

0 comments on commit 00fb6d0

Please sign in to comment.