Skip to content

Commit

Permalink
Pass Manylinux by value
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed May 6, 2021
1 parent 6d181e9 commit 4c6cde2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
22 changes: 9 additions & 13 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ impl BuildContext {
fn write_binding_wheel_abi3(
&self,
artifact: &Path,
manylinux: &Manylinux,
manylinux: Manylinux,
major: u8,
min_minor: u8,
) -> Result<BuiltWheelMetadata> {
let platform = self.target.get_platform_tag(&manylinux, self.universal2);
let platform = self.target.get_platform_tag(manylinux, self.universal2);
let tag = format!("cp{}{}-abi3-{}", major, min_minor, platform);

let mut writer = WheelWriter::new(
Expand Down Expand Up @@ -277,7 +277,7 @@ impl BuildContext {
let artifact = self.compile_cdylib(python_interpreter, Some(&self.module_name))?;
let policy = self.auditwheel(python_interpreter, &artifact, self.manylinux)?;
let (wheel_path, tag) =
self.write_binding_wheel_abi3(&artifact, &policy.manylinux_tag(), major, min_minor)?;
self.write_binding_wheel_abi3(&artifact, policy.manylinux_tag(), major, min_minor)?;

println!(
"📦 Built wheel for abi3 Python ≥ {}.{} to {}",
Expand All @@ -294,7 +294,7 @@ impl BuildContext {
&self,
python_interpreter: &PythonInterpreter,
artifact: &Path,
manylinux: &Manylinux,
manylinux: Manylinux,
) -> Result<BuiltWheelMetadata> {
let tag = python_interpreter.get_tag(manylinux, self.universal2);

Expand Down Expand Up @@ -338,7 +338,7 @@ impl BuildContext {
self.compile_cdylib(Some(&python_interpreter), Some(&self.module_name))?;
let policy = self.auditwheel(Some(&python_interpreter), &artifact, self.manylinux)?;
let (wheel_path, tag) =
self.write_binding_wheel(python_interpreter, &artifact, &policy.manylinux_tag())?;
self.write_binding_wheel(python_interpreter, &artifact, policy.manylinux_tag())?;
println!(
"📦 Built wheel for {} {}.{}{} to {}",
python_interpreter.interpreter_kind,
Expand Down Expand Up @@ -385,7 +385,7 @@ impl BuildContext {
fn write_cffi_wheel(
&self,
artifact: &Path,
manylinux: &Manylinux,
manylinux: Manylinux,
) -> Result<BuiltWheelMetadata> {
let (tag, tags) = self.target.get_universal_tags(manylinux, self.universal2);

Expand All @@ -411,19 +411,15 @@ impl BuildContext {
let mut wheels = Vec::new();
let artifact = self.compile_cdylib(None, None)?;
let policy = self.auditwheel(None, &artifact, self.manylinux)?;
let (wheel_path, tag) = self.write_cffi_wheel(&artifact, &policy.manylinux_tag())?;
let (wheel_path, tag) = self.write_cffi_wheel(&artifact, policy.manylinux_tag())?;

println!("📦 Built wheel to {}", wheel_path.display());
wheels.push((wheel_path, tag));

Ok(wheels)
}

fn write_bin_wheel(
&self,
artifact: &Path,
manylinux: &Manylinux,
) -> Result<BuiltWheelMetadata> {
fn write_bin_wheel(&self, artifact: &Path, manylinux: Manylinux) -> Result<BuiltWheelMetadata> {
let (tag, tags) = self.target.get_universal_tags(manylinux, self.universal2);

if !self.scripts.is_empty() {
Expand Down Expand Up @@ -471,7 +467,7 @@ impl BuildContext {

let policy = self.auditwheel(None, &artifact, self.manylinux)?;

let (wheel_path, tag) = self.write_bin_wheel(&artifact, &policy.manylinux_tag())?;
let (wheel_path, tag) = self.write_bin_wheel(&artifact, policy.manylinux_tag())?;
println!("📦 Built wheel to {}", wheel_path.display());
wheels.push((wheel_path, tag));

Expand Down
6 changes: 3 additions & 3 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ pub fn develop(
// We skip running auditwheel and simply tag as linux
let tags = match build_context.bridge {
BridgeModel::Bindings(_) => {
vec![build_context.interpreter[0].get_tag(&Manylinux::Off, build_context.universal2)]
vec![build_context.interpreter[0].get_tag(Manylinux::Off, build_context.universal2)]
}
BridgeModel::BindingsAbi3(major, minor) => {
let platform = target.get_platform_tag(&Manylinux::Off, build_context.universal2);
let platform = target.get_platform_tag(Manylinux::Off, build_context.universal2);
vec![format!("cp{}{}-abi3-{}", major, minor, platform)]
}
BridgeModel::Bin | BridgeModel::Cffi => {
build_context
.target
.get_universal_tags(&Manylinux::Off, build_context.universal2)
.get_universal_tags(Manylinux::Off, build_context.universal2)
.1
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,18 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
// Since afaik all other PEP 517 backends also return linux tagged wheels, we do so too
let tags = match context.bridge {
BridgeModel::Bindings(_) => {
vec![context.interpreter[0].get_tag(&Manylinux::Off, context.universal2)]
vec![context.interpreter[0].get_tag(Manylinux::Off, context.universal2)]
}
BridgeModel::BindingsAbi3(major, minor) => {
let platform = context
.target
.get_platform_tag(&Manylinux::Off, context.universal2);
.get_platform_tag(Manylinux::Off, context.universal2);
vec![format!("cp{}{}-abi3-{}", major, minor, platform)]
}
BridgeModel::Bin | BridgeModel::Cffi => {
context
.target
.get_universal_tags(&Manylinux::Off, context.universal2)
.get_universal_tags(Manylinux::Off, context.universal2)
.1
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/python_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl PythonInterpreter {
/// Don't ask me why or how, this is just what setuptools uses so I'm also going to use
///
/// If abi3 is true, cpython wheels use the generic abi3 with the given version as minimum
pub fn get_tag(&self, manylinux: &Manylinux, universal2: bool) -> String {
pub fn get_tag(&self, manylinux: Manylinux, universal2: bool) -> String {
match self.interpreter_kind {
InterpreterKind::CPython => {
let platform = self.target.get_platform_tag(manylinux, universal2);
Expand Down
14 changes: 7 additions & 7 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ impl Target {
})
}

/// Returns the platform part of the tag for the wheel name for cffi wheels
pub fn get_platform_tag(&self, manylinux: &Manylinux, universal2: bool) -> String {
/// Returns the platform part of the tag for the wheel name
pub fn get_platform_tag(&self, manylinux: Manylinux, universal2: bool) -> String {
match (&self.os, &self.arch) {
(Os::FreeBsd, Arch::X86_64) => {
let info = match PlatformInfo::new() {
Expand Down Expand Up @@ -256,10 +256,10 @@ impl Target {
}

/// Returns the tags for the WHEEL file for cffi wheels
pub fn get_py3_tags(&self, manylinux: &Manylinux, universal2: bool) -> Vec<String> {
pub fn get_py3_tags(&self, manylinux: Manylinux, universal2: bool) -> Vec<String> {
vec![format!(
"py3-none-{}",
self.get_platform_tag(&manylinux, universal2)
self.get_platform_tag(manylinux, universal2)
)]
}

Expand Down Expand Up @@ -324,14 +324,14 @@ impl Target {
/// Returns the tags for the platform without python version
pub fn get_universal_tags(
&self,
manylinux: &Manylinux,
manylinux: Manylinux,
universal2: bool,
) -> (String, Vec<String>) {
let tag = format!(
"py3-none-{platform}",
platform = self.get_platform_tag(&manylinux, universal2)
platform = self.get_platform_tag(manylinux, universal2)
);
let tags = self.get_py3_tags(&manylinux, universal2);
let tags = self.get_py3_tags(manylinux, universal2);
(tag, tags)
}
}
Expand Down

0 comments on commit 4c6cde2

Please sign in to comment.