-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Probe for project configuration files in parent directories
- Loading branch information
Showing
11 changed files
with
122 additions
and
58 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
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
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,8 @@ | ||
use crate::object_model::{Tag, Version}; | ||
use std::path::PathBuf; | ||
|
||
pub struct Project { | ||
pub config_path: PathBuf, | ||
pub python_version: Version, | ||
pub tag: Option<Tag>, | ||
} |
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,35 @@ | ||
use crate::result::Result; | ||
use std::path::PathBuf; | ||
|
||
pub const ISOPY_DIR_NAME: &'static str = ".isopy"; | ||
|
||
pub const PROJECT_CONFIG_FILE_NAME: &'static str = ".python-version.yaml"; | ||
|
||
pub fn default_isopy_dir() -> Option<PathBuf> { | ||
let home_dir = home::home_dir()?; | ||
let isopy_dir = home_dir.join(ISOPY_DIR_NAME); | ||
Some(isopy_dir) | ||
} | ||
|
||
pub fn make_project_config_path<P>(project_dir: P) -> PathBuf | ||
where | ||
P: Into<PathBuf>, | ||
{ | ||
project_dir.into().join(PROJECT_CONFIG_FILE_NAME) | ||
} | ||
|
||
pub fn find_project_config_path<P>(start_dir: P) -> Result<Option<PathBuf>> | ||
where | ||
P: Into<PathBuf>, | ||
{ | ||
let mut dir = start_dir.into(); | ||
loop { | ||
let project_config_path = make_project_config_path(&dir); | ||
if project_config_path.is_file() { | ||
return Ok(Some(project_config_path)); | ||
} | ||
if !dir.pop() { | ||
return Ok(None); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
mod env; | ||
mod helpers; | ||
mod index; | ||
mod project; | ||
mod project_record; | ||
mod repositories; | ||
mod use_; | ||
|
||
pub use self::env::{AnonymousEnvRecord, NamedEnvRecord}; | ||
pub use self::index::{AssetRecord, IndexRecord, PackageRecord}; | ||
pub use self::project::ProjectRecord; | ||
pub use self::project_record::ProjectRecord; | ||
pub use self::repositories::{RepositoriesRecord, RepositoryRecord}; | ||
pub use self::use_::UseRecord; |
File renamed without changes.