From 4c6cde2c5df4dab67d488eb8b9a6681ff4b3a0ea Mon Sep 17 00:00:00 2001
From: messense <messense@icloud.com>
Date: Thu, 6 May 2021 14:49:59 +0800
Subject: [PATCH] Pass Manylinux by value

---
 src/build_context.rs      | 22 +++++++++-------------
 src/develop.rs            |  6 +++---
 src/main.rs               |  6 +++---
 src/python_interpreter.rs |  2 +-
 src/target.rs             | 14 +++++++-------
 5 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/src/build_context.rs b/src/build_context.rs
index 18df8380e..9f9af6806 100644
--- a/src/build_context.rs
+++ b/src/build_context.rs
@@ -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(
@@ -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 {}",
@@ -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);
 
@@ -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,
@@ -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);
 
@@ -411,7 +411,7 @@ 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));
@@ -419,11 +419,7 @@ impl BuildContext {
         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() {
@@ -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));
 
diff --git a/src/develop.rs b/src/develop.rs
index e315ae17a..24a89227b 100644
--- a/src/develop.rs
+++ b/src/develop.rs
@@ -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
         }
     };
diff --git a/src/main.rs b/src/main.rs
index 6c894db10..57a9eaae3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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
                 }
             };
diff --git a/src/python_interpreter.rs b/src/python_interpreter.rs
index a9c2c86f2..535a31750 100644
--- a/src/python_interpreter.rs
+++ b/src/python_interpreter.rs
@@ -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);
diff --git a/src/target.rs b/src/target.rs
index f3df17fd9..1c5a473dc 100644
--- a/src/target.rs
+++ b/src/target.rs
@@ -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() {
@@ -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)
         )]
     }
 
@@ -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)
     }
 }