Skip to content

Remove libpython dependency on standalone libqiskit build #14240

@mtreinish

Description

@mtreinish

What should we add?

Since #14006 merged the output libqiskit standalone dylib that we build from the cext crate now requires libpython. This is only because the CircuitData Rust struct is built with Python objects internally so libpython is needed for the definition of those objects in the data model. They're not exposed through any public interface and the GIL is never used or required for anything that can be called from the standalone C API as it only exposes the part of the data model that is Python free so you can't ever create something that has a dependency on Python. However, because there are still various components in the data model that depend on Python we still need libpython so those have definitions. While we're working to remove these last components in the data model which should be moved to Rust (see #13264). There will be an additional step to conditionally compile the PyGate, PyInstruction, and PyOperation types as those by definition have a dependency on Python (they're Rust space containers for objects defined in Python) so that code isn't included when building in standalone mode.

There will be later work (potentially for Qiskit 3.0 as I expect there will be potential backwards compatibility implications) to move the python definition of custom operations to internally create rust custom operations (which don't exist yet) to remove the hard dependency on Python for these objects, but in the medium term conditional compilation after #13264 is complete will likely be simpler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C APIRelated to the C APIRustThis PR or issue is related to Rust code in the repositorytype: feature requestNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions