-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad01a76
commit 6d3a5f8
Showing
6 changed files
with
92 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::path::{Path, PathBuf}; | ||
|
||
use tracing::debug; | ||
use uv_fs::Simplified; | ||
|
||
use uv_requirements::RequirementsSource; | ||
|
||
#[derive(Debug, Clone)] | ||
pub(crate) struct Project { | ||
/// The path to the `pyproject.toml` file. | ||
path: PathBuf, | ||
} | ||
|
||
impl Project { | ||
/// Find the current project. | ||
pub(crate) fn find(path: impl AsRef<Path>) -> Option<Self> { | ||
for ancestor in path.as_ref().ancestors() { | ||
let pyproject_path = ancestor.join("pyproject.toml"); | ||
if pyproject_path.exists() { | ||
debug!( | ||
"Loading requirements from: {}", | ||
pyproject_path.user_display() | ||
); | ||
return Some(Self { | ||
path: pyproject_path, | ||
}); | ||
} | ||
} | ||
|
||
None | ||
} | ||
|
||
/// Return the requirements for the project. | ||
pub(crate) fn requirements(&self) -> Vec<RequirementsSource> { | ||
vec![ | ||
RequirementsSource::from_requirements_file(self.path.clone()), | ||
RequirementsSource::from_source_tree(self.path.parent().unwrap().to_path_buf()), | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters