-
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.
Allow relative paths and environment variables in all editable repres…
…entations (#1000) ## Summary I don't know if this is actually a good change, but it tries to make the editable install experience more consistent. Specifically, we now support... ``` # Use a relative path with a `file://` prefix. # Prior to this PR, we supported `file:../foo`, but not `file://../foo`, which felt inconsistent. -e file://../foo # Use environment variables with paths, not just URLs. # Prior to this PR, we supported `file://${PROJECT_ROOT}/../foo`, but not the below. -e ${PROJECT_ROOT}/../foo ``` Importantly, `-e file://../foo` is actually not supported by pip... `-e file:../foo` _is_ supported though. We support both, as of this PR. Open to feedback.
- Loading branch information
1 parent
cd2fb6f
commit 5adb08a
Showing
14 changed files
with
172 additions
and
196 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,45 +1,40 @@ | ||
use std::borrow::Cow; | ||
use std::path::{Path, PathBuf}; | ||
use std::path::PathBuf; | ||
|
||
use url::Url; | ||
|
||
use pep508_rs::VerbatimUrl; | ||
use requirements_txt::EditableRequirement; | ||
|
||
use crate::Verbatim; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct LocalEditable { | ||
pub requirement: EditableRequirement, | ||
/// The underlying [`EditableRequirement`] from the `requirements.txt` file. | ||
pub url: VerbatimUrl, | ||
/// Either the path to the editable or its checkout. | ||
pub path: PathBuf, | ||
} | ||
|
||
impl LocalEditable { | ||
/// Return the [`VerbatimUrl`] of the editable. | ||
/// Return the editable as a [`Url`]. | ||
pub fn url(&self) -> &VerbatimUrl { | ||
self.requirement.url() | ||
} | ||
|
||
/// Return the underlying [`Url`] of the editable. | ||
pub fn raw(&self) -> &Url { | ||
self.requirement.raw() | ||
&self.url | ||
} | ||
|
||
/// Return the resolved path to the editable. | ||
pub fn path(&self) -> &Path { | ||
&self.path | ||
pub fn raw(&self) -> &Url { | ||
self.url.raw() | ||
} | ||
} | ||
|
||
impl Verbatim for LocalEditable { | ||
fn verbatim(&self) -> Cow<'_, str> { | ||
self.url().verbatim() | ||
self.url.verbatim() | ||
} | ||
} | ||
|
||
impl std::fmt::Display for LocalEditable { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
self.requirement.fmt(f) | ||
std::fmt::Display::fmt(&self.url, f) | ||
} | ||
} |
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
Oops, something went wrong.