-
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 users to mark platforms as "required" for wheel coverage (#10067)
## Summary This PR revives #10017, which might be viable now that we _don't_ enforce any platforms by default. The basic idea here is that users can mark certain platforms as required (empty, by default). When resolving, we ensure that the specified platforms have wheel coverage, backtracking if not. For example, to require that we include a version of PyTorch that supports Intel macOS: ```toml [project] name = "project" version = "0.1.0" requires-python = ">=3.11" dependencies = ["torch>1.13"] [tool.uv] required-platforms = [ "sys_platform == 'darwin' and platform_machine == 'x86_64'" ] ``` Other than that, the forking is identical to past iterations of this PR. This would give users a way to resolve the tail of issues in #9711, but with manual opt-in to supporting specific platforms.
- Loading branch information
1 parent
9cdfad1
commit 172305a
Showing
29 changed files
with
1,231 additions
and
376 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,58 @@ | ||
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: match self { | ||
KnownPlatform::Linux => arcstr::literal!("linux"), | ||
KnownPlatform::Windows => arcstr::literal!("win32"), | ||
KnownPlatform::MacOS => arcstr::literal!("darwin"), | ||
}, | ||
}) | ||
} | ||
|
||
/// 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
Oops, something went wrong.