Rename `--platform` to `--python-platform` (#3146)

## Summary

`--platform` is a flag that exists in `pip` and it has a different
meaning. (Not breaking as this hasn't been released yet anyway.)
This commit is contained in:
Charlie Marsh 2024-04-19 18:24:23 -04:00 committed by GitHub
parent 4046b2bcfa
commit 5e4e2fa0bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 20 deletions

View File

@ -529,7 +529,7 @@ pub(crate) struct PipCompileArgs {
/// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or /// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
/// `aaarch64-apple-darwin`. /// `aaarch64-apple-darwin`.
#[arg(long)] #[arg(long)]
pub(crate) platform: Option<TargetTriple>, pub(crate) python_platform: Option<TargetTriple>,
/// Limit candidate packages to those that were uploaded prior to the given date. /// Limit candidate packages to those that were uploaded prior to the given date.
/// ///

View File

@ -79,7 +79,7 @@ pub(crate) async fn pip_compile(
no_build_isolation: bool, no_build_isolation: bool,
no_build: NoBuild, no_build: NoBuild,
python_version: Option<PythonVersion>, python_version: Option<PythonVersion>,
target: Option<TargetTriple>, python_platform: Option<TargetTriple>,
exclude_newer: Option<ExcludeNewer>, exclude_newer: Option<ExcludeNewer>,
annotation_style: AnnotationStyle, annotation_style: AnnotationStyle,
link_mode: LinkMode, link_mode: LinkMode,
@ -195,16 +195,16 @@ pub(crate) async fn pip_compile(
}; };
// Determine the tags, markers, and interpreter to use for resolution. // Determine the tags, markers, and interpreter to use for resolution.
let tags = match (target, python_version.as_ref()) { let tags = match (python_platform, python_version.as_ref()) {
(Some(target), Some(python_version)) => Cow::Owned(Tags::from_env( (Some(python_platform), Some(python_version)) => Cow::Owned(Tags::from_env(
&target.platform(), &python_platform.platform(),
(python_version.major(), python_version.minor()), (python_version.major(), python_version.minor()),
interpreter.implementation_name(), interpreter.implementation_name(),
interpreter.implementation_tuple(), interpreter.implementation_tuple(),
interpreter.gil_disabled(), interpreter.gil_disabled(),
)?), )?),
(Some(target), None) => Cow::Owned(Tags::from_env( (Some(python_platform), None) => Cow::Owned(Tags::from_env(
&target.platform(), &python_platform.platform(),
interpreter.python_tuple(), interpreter.python_tuple(),
interpreter.implementation_name(), interpreter.implementation_name(),
interpreter.implementation_tuple(), interpreter.implementation_tuple(),
@ -221,11 +221,11 @@ pub(crate) async fn pip_compile(
}; };
// Apply the platform tags to the markers. // Apply the platform tags to the markers.
let markers = match (target, python_version) { let markers = match (python_platform, python_version) {
(Some(target), Some(python_version)) => { (Some(python_platform), Some(python_version)) => {
Cow::Owned(python_version.markers(&target.markers(interpreter.markers()))) Cow::Owned(python_version.markers(&python_platform.markers(interpreter.markers())))
} }
(Some(target), None) => Cow::Owned(target.markers(interpreter.markers())), (Some(python_platform), None) => Cow::Owned(python_platform.markers(interpreter.markers())),
(None, Some(python_version)) => Cow::Owned(python_version.markers(interpreter.markers())), (None, Some(python_version)) => Cow::Owned(python_version.markers(interpreter.markers())),
(None, None) => Cow::Borrowed(interpreter.markers()), (None, None) => Cow::Borrowed(interpreter.markers()),
}; };

View File

@ -255,7 +255,7 @@ async fn run() -> Result<ExitStatus> {
args.shared.no_build_isolation, args.shared.no_build_isolation,
no_build, no_build,
args.shared.python_version, args.shared.python_version,
args.platform, args.python_platform,
args.shared.exclude_newer, args.shared.exclude_newer,
args.shared.annotation_style, args.shared.annotation_style,
args.shared.link_mode, args.shared.link_mode,

View File

@ -75,7 +75,7 @@ pub(crate) struct PipCompileSettings {
pub(crate) src_file: Vec<PathBuf>, pub(crate) src_file: Vec<PathBuf>,
pub(crate) constraint: Vec<PathBuf>, pub(crate) constraint: Vec<PathBuf>,
pub(crate) r#override: Vec<PathBuf>, pub(crate) r#override: Vec<PathBuf>,
pub(crate) platform: Option<TargetTriple>, pub(crate) python_platform: Option<TargetTriple>,
pub(crate) refresh: bool, pub(crate) refresh: bool,
pub(crate) refresh_package: Vec<PackageName>, pub(crate) refresh_package: Vec<PackageName>,
pub(crate) upgrade: bool, pub(crate) upgrade: bool,
@ -136,7 +136,7 @@ impl PipCompileSettings {
only_binary, only_binary,
config_setting, config_setting,
python_version, python_version,
platform, python_platform,
exclude_newer, exclude_newer,
no_emit_package, no_emit_package,
emit_index_url, emit_index_url,
@ -155,7 +155,7 @@ impl PipCompileSettings {
src_file, src_file,
constraint, constraint,
r#override, r#override,
platform, python_platform,
refresh, refresh,
refresh_package: refresh_package.unwrap_or_default(), refresh_package: refresh_package.unwrap_or_default(),
upgrade, upgrade,

View File

@ -7892,7 +7892,7 @@ fn no_version_for_direct_dependency() -> Result<()> {
/// Compile against a dedicated platform, which may differ from the current platform. /// Compile against a dedicated platform, which may differ from the current platform.
#[test] #[test]
fn platform() -> Result<()> { fn python_platform() -> Result<()> {
let context = TestContext::new("3.12"); let context = TestContext::new("3.12");
let requirements_in = context.temp_dir.child("requirements.in"); let requirements_in = context.temp_dir.child("requirements.in");
@ -7902,13 +7902,13 @@ fn platform() -> Result<()> {
windows_filters=false, windows_filters=false,
context.compile() context.compile()
.arg("requirements.in") .arg("requirements.in")
.arg("--platform") .arg("--python-platform")
.arg("aarch64-unknown-linux-gnu"), @r###" .arg("aarch64-unknown-linux-gnu"), @r###"
success: true success: true
exit_code: 0 exit_code: 0
----- stdout ----- ----- stdout -----
# This file was autogenerated by uv via the following command: # This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2024-03-25T00:00:00Z requirements.in --platform aarch64-unknown-linux-gnu # uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2024-03-25T00:00:00Z requirements.in --python-platform aarch64-unknown-linux-gnu
black==24.3.0 black==24.3.0
click==8.1.7 click==8.1.7
# via black # via black
@ -7930,13 +7930,13 @@ fn platform() -> Result<()> {
windows_filters=false, windows_filters=false,
context.compile() context.compile()
.arg("requirements.in") .arg("requirements.in")
.arg("--platform") .arg("--python-platform")
.arg("x86_64-pc-windows-msvc"), @r###" .arg("x86_64-pc-windows-msvc"), @r###"
success: true success: true
exit_code: 0 exit_code: 0
----- stdout ----- ----- stdout -----
# This file was autogenerated by uv via the following command: # This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2024-03-25T00:00:00Z requirements.in --platform x86_64-pc-windows-msvc # uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2024-03-25T00:00:00Z requirements.in --python-platform x86_64-pc-windows-msvc
black==24.3.0 black==24.3.0
click==8.1.7 click==8.1.7
# via black # via black