Skip to content

Commit

Permalink
update PyO3 to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
orpuente-MS committed Jan 17, 2025
1 parent 294a3c5 commit aed465a
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 139 deletions.
91 changes: 47 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ regex-lite = "0.1"
rustc-hash = "1"
serde = { version = "1.0", features = [ "derive" ] }
serde-wasm-bindgen = "0.6"
wasm-bindgen = "0.2"
wasm-bindgen = "0.2.100"
wasm-bindgen-futures = "0.4"
rand = "0.8"
serde_json = "1.0"
pyo3 = "0.22"
pyo3 = "0.23.4"
quantum-sparse-sim = { git = "https://github.com/qir-alliance/qir-runner", rev = "562e2c11ad685dd01bfc1ae975e00d4133615995" }
async-trait = "0.1"
tokio = { version = "1.35", features = ["macros", "rt"] }
Expand Down
11 changes: 5 additions & 6 deletions pip/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ impl FileSystem for Py<'_> {
}

fn read_file(py: Python, read_file: &PyObject, path: &Path) -> PyResult<(Arc<str>, Arc<str>)> {
let read_file_result =
read_file.call1(py, PyTuple::new_bound(py, &[path.to_string_lossy()]))?;
let read_file_result = read_file.call1(py, PyTuple::new(py, &[path.to_string_lossy()])?)?;

let tuple = read_file_result.downcast_bound::<PyTuple>(py)?;

Expand All @@ -114,7 +113,7 @@ fn read_file(py: Python, read_file: &PyObject, path: &Path) -> PyResult<(Arc<str

fn list_directory(py: Python, list_directory: &PyObject, path: &Path) -> PyResult<Vec<Entry>> {
let list_directory_result =
list_directory.call1(py, PyTuple::new_bound(py, &[path.to_string_lossy()]))?;
list_directory.call1(py, PyTuple::new(py, &[path.to_string_lossy()])?)?;

list_directory_result
.downcast_bound::<PyList>(py)?
Expand Down Expand Up @@ -147,7 +146,7 @@ fn resolve_path(
) -> PyResult<PathBuf> {
let resolve_path_result = resolve_path.call1(
py,
PyTuple::new_bound(py, &[base.to_string_lossy(), path.to_string_lossy()]),
PyTuple::new(py, &[base.to_string_lossy(), path.to_string_lossy()])?,
)?;

Ok(PathBuf::from(
Expand All @@ -167,7 +166,7 @@ fn fetch_github(
path: &str,
) -> PyResult<Arc<str>> {
let fetch_github_result =
fetch_github.call1(py, PyTuple::new_bound(py, [owner, repo, r#ref, path]))?;
fetch_github.call1(py, PyTuple::new(py, [owner, repo, r#ref, path])?)?;

Ok(fetch_github_result
.downcast_bound::<PyString>(py)?
Expand All @@ -191,7 +190,7 @@ fn get_dict_string<'a>(dict: &Bound<'a, PyDict>, key: &'a str) -> PyResult<Bound
}

fn diagnostic_from(py: Python<'_>, err: &PyErr) -> miette::Report {
if let Some(traceback) = err.traceback_bound(py) {
if let Some(traceback) = err.traceback(py) {
match traceback.format() {
Ok(traceback) => miette!(format!("{err}\n{traceback}",)),
Err(traceback_err) => {
Expand Down
14 changes: 5 additions & 9 deletions pip/src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn run_qasm3(
) -> PyResult<PyObject> {
let mut receiver = OptionalCallbackReceiver { callback, py };

let kwargs = kwargs.unwrap_or_else(|| PyDict::new_bound(py));
let kwargs = kwargs.unwrap_or_else(|| PyDict::new(py));

let target = get_target_profile(&kwargs)?;
let operation_name = get_operation_name(&kwargs)?;
Expand Down Expand Up @@ -120,11 +120,7 @@ pub fn run_qasm3(
.map_err(|errors| map_entry_compilation_errors(errors, &signature))?;

match run_ast(&mut interpreter, &mut receiver, shots, seed) {
Ok(result) => Ok(PyList::new_bound(
py,
result.iter().map(|v| ValueWrapper(v.clone()).into_py(py)),
)
.into_py(py)),
Ok(result) => Ok(PyList::new(py, result.iter().map(|v| ValueWrapper(v.clone())))?.into()),
Err(errors) => Err(QSharpError::new_err(format_errors(errors))),
}
}
Expand Down Expand Up @@ -166,7 +162,7 @@ pub(crate) fn resource_estimate_qasm3(
fetch_github: Option<PyObject>,
kwargs: Option<Bound<'_, PyDict>>,
) -> PyResult<String> {
let kwargs = kwargs.unwrap_or_else(|| PyDict::new_bound(py));
let kwargs = kwargs.unwrap_or_else(|| PyDict::new(py));

let operation_name = get_operation_name(&kwargs)?;
let search_path = get_search_path(&kwargs)?;
Expand Down Expand Up @@ -228,7 +224,7 @@ pub(crate) fn compile_qasm3_to_qir(
fetch_github: Option<PyObject>,
kwargs: Option<Bound<'_, PyDict>>,
) -> PyResult<String> {
let kwargs = kwargs.unwrap_or_else(|| PyDict::new_bound(py));
let kwargs = kwargs.unwrap_or_else(|| PyDict::new(py));

let target = get_target_profile(&kwargs)?;
let operation_name = get_operation_name(&kwargs)?;
Expand Down Expand Up @@ -367,7 +363,7 @@ pub(crate) fn compile_qasm3_to_qsharp(
fetch_github: Option<PyObject>,
kwargs: Option<Bound<'_, PyDict>>,
) -> PyResult<String> {
let kwargs = kwargs.unwrap_or_else(|| PyDict::new_bound(py));
let kwargs = kwargs.unwrap_or_else(|| PyDict::new(py));

let operation_name = get_operation_name(&kwargs)?;
let search_path = get_search_path(&kwargs)?;
Expand Down
Loading

0 comments on commit aed465a

Please sign in to comment.