-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support editable in pip-sync and pip-compile (#587)
Support `-e path/do/dir` in pip-sync and and pip-compile.
- Loading branch information
Showing
47 changed files
with
1,013 additions
and
247 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
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
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 |
---|---|---|
|
@@ -15,16 +15,21 @@ pub enum DirectUrl { | |
Archive(DirectArchiveUrl), | ||
} | ||
|
||
/// A git repository url | ||
/// A local path url | ||
/// | ||
/// Examples: | ||
/// * `git+https://git.example.com/MyProject.git` | ||
/// * `git+https://git.example.com/[email protected]#egg=pkg&subdirectory=pkg_dir` | ||
/// * `file:///home/ferris/my_project` | ||
#[derive(Debug)] | ||
pub struct LocalFileUrl { | ||
pub url: Url, | ||
pub editable: bool, | ||
} | ||
|
||
/// A git repository url | ||
/// | ||
/// Examples: | ||
/// * `git+https://git.example.com/MyProject.git` | ||
/// * `git+https://git.example.com/[email protected]#egg=pkg&subdirectory=pkg_dir` | ||
#[derive(Debug)] | ||
pub struct DirectGitUrl { | ||
pub url: GitUrl, | ||
|
@@ -43,12 +48,6 @@ pub struct DirectArchiveUrl { | |
pub subdirectory: Option<PathBuf>, | ||
} | ||
|
||
impl From<&Url> for LocalFileUrl { | ||
fn from(url: &Url) -> Self { | ||
Self { url: url.clone() } | ||
} | ||
} | ||
|
||
impl TryFrom<&Url> for DirectGitUrl { | ||
type Error = Error; | ||
|
||
|
@@ -106,7 +105,10 @@ impl TryFrom<&Url> for DirectUrl { | |
))), | ||
} | ||
} else if url.scheme().eq_ignore_ascii_case("file") { | ||
Ok(Self::LocalFile(LocalFileUrl::from(url))) | ||
Ok(Self::LocalFile(LocalFileUrl { | ||
url: url.clone(), | ||
editable: false, | ||
})) | ||
} else { | ||
Ok(Self::Archive(DirectArchiveUrl::from(url))) | ||
} | ||
|
@@ -131,7 +133,9 @@ impl TryFrom<&LocalFileUrl> for pypi_types::DirectUrl { | |
fn try_from(value: &LocalFileUrl) -> Result<Self, Self::Error> { | ||
Ok(pypi_types::DirectUrl::LocalDirectory { | ||
url: value.url.clone(), | ||
dir_info: pypi_types::DirInfo { editable: None }, | ||
dir_info: pypi_types::DirInfo { | ||
editable: value.editable.then_some(true), | ||
}, | ||
}) | ||
} | ||
} | ||
|
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,33 @@ | ||
use std::fmt::{Display, Formatter}; | ||
use std::path::{Path, PathBuf}; | ||
use url::Url; | ||
|
||
use pep508_rs::VerbatimUrl; | ||
use requirements_txt::EditableRequirement; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct LocalEditable { | ||
pub requirement: EditableRequirement, | ||
/// Either the path to the editable or its checkout | ||
pub path: PathBuf, | ||
} | ||
|
||
impl LocalEditable { | ||
pub fn url(&self) -> &VerbatimUrl { | ||
self.requirement.url() | ||
} | ||
|
||
pub fn raw(&self) -> &Url { | ||
self.requirement.raw() | ||
} | ||
|
||
pub fn path(&self) -> &Path { | ||
&self.path | ||
} | ||
} | ||
|
||
impl Display for LocalEditable { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
self.requirement.fmt(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
Oops, something went wrong.