-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uhh trying Fork on... Add heuristic Gate to local versions Remove KnownMarkers Add required platform support
- Loading branch information
1 parent
ddc290f
commit eeb249d
Showing
26 changed files
with
1,181 additions
and
375 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::fmt::{Display, Formatter}; | ||
|
||
use uv_pep508::{MarkerExpression, MarkerOperator, MarkerTree, MarkerValueString}; | ||
|
||
/// A platform for which the resolver is solving. | ||
#[derive(Debug, Clone, Copy)] | ||
pub enum KnownPlatform { | ||
Linux, | ||
Windows, | ||
MacOS, | ||
} | ||
|
||
impl KnownPlatform { | ||
/// Return the platform's `sys.platform` value. | ||
pub fn sys_platform(self) -> &'static str { | ||
match self { | ||
KnownPlatform::Linux => "linux", | ||
KnownPlatform::Windows => "win32", | ||
KnownPlatform::MacOS => "darwin", | ||
} | ||
} | ||
|
||
/// Return a [`MarkerTree`] for the platform. | ||
pub fn marker(self) -> MarkerTree { | ||
MarkerTree::expression(MarkerExpression::String { | ||
key: MarkerValueString::SysPlatform, | ||
operator: MarkerOperator::Equal, | ||
value: self.sys_platform().to_string(), | ||
}) | ||
} | ||
|
||
/// Determine the [`KnownPlatform`] from a marker tree. | ||
pub fn from_marker(marker: MarkerTree) -> Option<KnownPlatform> { | ||
if marker == KnownPlatform::Linux.marker() { | ||
Some(KnownPlatform::Linux) | ||
} else if marker == KnownPlatform::Windows.marker() { | ||
Some(KnownPlatform::Windows) | ||
} else if marker == KnownPlatform::MacOS.marker() { | ||
Some(KnownPlatform::MacOS) | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
impl Display for KnownPlatform { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
KnownPlatform::Linux => write!(f, "Linux"), | ||
KnownPlatform::Windows => write!(f, "Windows"), | ||
KnownPlatform::MacOS => write!(f, "macOS"), | ||
} | ||
} | ||
} |
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
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.