From 7e0e0e73c8077ce253f357b663359f287f335852 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 11 Sep 2024 17:04:17 -0400 Subject: [PATCH] Fix ABI3 issues identified during 1.3.0b1 release attempt (#13136) We recently tried to publish the 1.3.0b1 release unsucessfully. During the wheel build jobs abi3audit was failing because it correctly identified a couple of abi violations in the builds. The first was we were tagging the package incorrectly as being with a minimum level of Python 3.8 instead of the correct minimum of 3.9. This commit updates the setup.py tag to match the package metadata with the binary. The second issue is we were creating `PyInit_*` symbols for submodules which goes against the abi3 naming recomendations and abi3 audit flags it as a violation. We had this issue previously in 1.2.0 but was fixed for that release. However since 1.2.0 and now several stray usages of `#[pymodule]` on submodules slipped in during development. This commit fixes those so the bad symbol names won't be created anymore. Once this commit merges we should tag the new commit as 1.3.0b1. Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com> --- crates/accelerate/src/circuit_library/mod.rs | 1 - crates/accelerate/src/commutation_analysis.rs | 3 +-- crates/accelerate/src/commutation_cancellation.rs | 3 +-- crates/accelerate/src/commutation_checker.rs | 1 - crates/accelerate/src/gate_direction.rs | 1 - crates/accelerate/src/remove_diagonal_gates_before_measure.rs | 1 - setup.py | 2 +- 7 files changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/accelerate/src/circuit_library/mod.rs b/crates/accelerate/src/circuit_library/mod.rs index d0444c484dc8..9df16a04fc6c 100644 --- a/crates/accelerate/src/circuit_library/mod.rs +++ b/crates/accelerate/src/circuit_library/mod.rs @@ -14,7 +14,6 @@ use pyo3::prelude::*; mod entanglement; -#[pymodule] pub fn circuit_library(m: &Bound) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(entanglement::get_entangler_map))?; Ok(()) diff --git a/crates/accelerate/src/commutation_analysis.rs b/crates/accelerate/src/commutation_analysis.rs index 2da8cfce931e..0a9a2304df54 100644 --- a/crates/accelerate/src/commutation_analysis.rs +++ b/crates/accelerate/src/commutation_analysis.rs @@ -12,7 +12,7 @@ use pyo3::exceptions::PyValueError; use pyo3::prelude::PyModule; -use pyo3::{pyfunction, pymodule, wrap_pyfunction, Bound, PyResult, Python}; +use pyo3::{pyfunction, wrap_pyfunction, Bound, PyResult, Python}; use qiskit_circuit::Qubit; use crate::commutation_checker::CommutationChecker; @@ -185,7 +185,6 @@ pub(crate) fn analyze_commutations( Ok(out_dict.unbind()) } -#[pymodule] pub fn commutation_analysis(m: &Bound) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(analyze_commutations))?; Ok(()) diff --git a/crates/accelerate/src/commutation_cancellation.rs b/crates/accelerate/src/commutation_cancellation.rs index dc2d4436d83a..7ae7d3d7ce1a 100644 --- a/crates/accelerate/src/commutation_cancellation.rs +++ b/crates/accelerate/src/commutation_cancellation.rs @@ -15,7 +15,7 @@ use std::f64::consts::PI; use hashbrown::{HashMap, HashSet}; use pyo3::exceptions::PyRuntimeError; use pyo3::prelude::*; -use pyo3::{pyfunction, pymodule, wrap_pyfunction, Bound, PyResult, Python}; +use pyo3::{pyfunction, wrap_pyfunction, Bound, PyResult, Python}; use rustworkx_core::petgraph::stable_graph::NodeIndex; use smallvec::{smallvec, SmallVec}; @@ -273,7 +273,6 @@ pub(crate) fn cancel_commutations( Ok(()) } -#[pymodule] pub fn commutation_cancellation(m: &Bound) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(cancel_commutations))?; Ok(()) diff --git a/crates/accelerate/src/commutation_checker.rs b/crates/accelerate/src/commutation_checker.rs index b00d7c624c92..c7fbd03a2afe 100644 --- a/crates/accelerate/src/commutation_checker.rs +++ b/crates/accelerate/src/commutation_checker.rs @@ -767,7 +767,6 @@ fn hashable_params(params: &[Param]) -> PyResult> { .collect() } -#[pymodule] pub fn commutation_checker(m: &Bound) -> PyResult<()> { m.add_class::()?; m.add_class::()?; diff --git a/crates/accelerate/src/gate_direction.rs b/crates/accelerate/src/gate_direction.rs index aee5ca097322..e7fef8456238 100644 --- a/crates/accelerate/src/gate_direction.rs +++ b/crates/accelerate/src/gate_direction.rs @@ -142,7 +142,6 @@ where Ok(true) } -#[pymodule] pub fn gate_direction(m: &Bound) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(py_check_with_coupling_map))?; m.add_wrapped(wrap_pyfunction!(py_check_with_target))?; diff --git a/crates/accelerate/src/remove_diagonal_gates_before_measure.rs b/crates/accelerate/src/remove_diagonal_gates_before_measure.rs index cf2c738f131a..e510d73666cc 100644 --- a/crates/accelerate/src/remove_diagonal_gates_before_measure.rs +++ b/crates/accelerate/src/remove_diagonal_gates_before_measure.rs @@ -102,7 +102,6 @@ fn run_remove_diagonal_before_measure(dag: &mut DAGCircuit) -> PyResult<()> { Ok(()) } -#[pymodule] pub fn remove_diagonal_gates_before_measure(m: &Bound) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(run_remove_diagonal_before_measure))?; Ok(()) diff --git a/setup.py b/setup.py index 61168050547c..ad6d1f8ead86 100644 --- a/setup.py +++ b/setup.py @@ -51,5 +51,5 @@ features=features, ) ], - options={"bdist_wheel": {"py_limited_api": "cp38"}}, + options={"bdist_wheel": {"py_limited_api": "cp39"}}, )