-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary The approach taken here is to model `--target` as an install scheme in which all the directories are just subdirectories of the `--target`. From there, everything else... just works? Like, upgrade, uninstalls, editables, etc. all "just work". Closes #1517.
- Loading branch information
1 parent
71ffb2e
commit ed8f6e4
Showing
14 changed files
with
284 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::path::{Path, PathBuf}; | ||
|
||
use pypi_types::Scheme; | ||
|
||
/// A `--target` directory into which packages can be installed, separate from a virtual environment | ||
/// or system Python interpreter. | ||
#[derive(Debug, Clone)] | ||
pub struct Target(PathBuf); | ||
|
||
impl Target { | ||
/// Return the [`Scheme`] for the `--target` directory. | ||
pub fn scheme(&self) -> Scheme { | ||
Scheme { | ||
purelib: self.0.clone(), | ||
platlib: self.0.clone(), | ||
scripts: self.0.join("bin"), | ||
data: self.0.clone(), | ||
include: self.0.join("include"), | ||
} | ||
} | ||
|
||
/// Initialize the `--target` directory. | ||
pub fn init(&self) -> std::io::Result<()> { | ||
fs_err::create_dir_all(&self.0)?; | ||
fs_err::create_dir_all(self.0.join("bin"))?; | ||
fs_err::create_dir_all(self.0.join("include"))?; | ||
Ok(()) | ||
} | ||
|
||
/// Return the path to the `--target` directory. | ||
pub fn root(&self) -> &Path { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl From<PathBuf> for Target { | ||
fn from(path: PathBuf) -> Self { | ||
Self(path) | ||
} | ||
} |
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
Oops, something went wrong.