Struct maturin::PythonInterpreter
source · pub struct PythonInterpreter {
pub config: InterpreterConfig,
pub executable: PathBuf,
pub platform: Option<String>,
pub runnable: bool,
pub implmentation_name: String,
pub soabi: Option<String>,
}
Expand description
The location and version of an interpreter
Fields
config: InterpreterConfig
Python’s sysconfig Python’s major version
executable: PathBuf
Path to the python interpreter, e.g. /usr/bin/python3.6
Just the name of the binary in PATH does also work, e.g. python3.5
platform: Option<String>
Comes from sysconfig.get_platform()
Note that this can be None
when cross compiling
runnable: bool
Is this interpreter runnable
When cross compile the target interpreter isn’t runnable,
and it’s executable
is empty
implmentation_name: String
Comes from sys.platform.name
soabi: Option<String>
Comes from sysconfig var SOABI
Implementations
sourceimpl PythonInterpreter
impl PythonInterpreter
sourcepub fn has_stable_api(&self) -> bool
pub fn has_stable_api(&self) -> bool
Does this interpreter have PEP 384 stable api aka. abi3 support?
sourcepub fn get_tag(
&self,
target: &Target,
platform_tags: &[PlatformTag],
universal2: bool
) -> Result<String>
pub fn get_tag(
&self,
target: &Target,
platform_tags: &[PlatformTag],
universal2: bool
) -> Result<String>
Returns the supported python environment in the PEP 425 format used for the wheel filename: {python tag}-{abi tag}-{platform tag}
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
sourcepub fn get_library_name(&self, base: &str) -> String
pub fn get_library_name(&self, base: &str) -> String
Adds the ext_suffix we read from python or know (.pyd/.abi3.so) and adds it to the base name
For CPython, generate extensions as follows:
For python 3, there is PEP 3149, but that is only valid for 3.2 - 3.4. Since only 3.6+ is supported, the templates are adapted from the (also incorrect) release notes of CPython 3.5: https://docs.python.org/3/whatsnew/3.5.html#build-and-c-api-changes
Examples for 64-bit on CPython 3.6m: Linux: foobar.cpython-36m-x86_64-linux-gnu.so Windows: foobar.cp36-win_amd64.pyd Mac: foobar.cpython-36m-darwin.so FreeBSD: foobar.cpython-36m.so
For pypy3, we read importlib.machinery.EXTENSION_SUFFIXES[0].
sourcepub fn check_executable(
executable: impl AsRef<Path>,
target: &Target,
bridge: &BridgeModel
) -> Result<Option<PythonInterpreter>>
pub fn check_executable(
executable: impl AsRef<Path>,
target: &Target,
bridge: &BridgeModel
) -> Result<Option<PythonInterpreter>>
Checks whether the given command is a python interpreter and returns a PythonInterpreter if that is the case
sourcepub fn from_config(config: InterpreterConfig) -> Self
pub fn from_config(config: InterpreterConfig) -> Self
Construct a PythonInterpreter
from a sysconfig and target
sourcepub fn find_by_target(
target: &Target,
min_python_minor: Option<usize>
) -> Vec<PythonInterpreter>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn find_by_target(
target: &Target,
min_python_minor: Option<usize>
) -> Vec<PythonInterpreter>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Find all available python interpreters for a given target
sourcepub fn find_all(
target: &Target,
bridge: &BridgeModel,
min_python_minor: Option<usize>
) -> Result<Vec<PythonInterpreter>>
pub fn find_all(
target: &Target,
bridge: &BridgeModel,
min_python_minor: Option<usize>
) -> Result<Vec<PythonInterpreter>>
Tries to find all installed python versions using the heuristic for the given platform
sourcepub fn check_executables(
executables: &[PathBuf],
target: &Target,
bridge: &BridgeModel
) -> Result<Vec<PythonInterpreter>>
pub fn check_executables(
executables: &[PathBuf],
target: &Target,
bridge: &BridgeModel
) -> Result<Vec<PythonInterpreter>>
Checks that given list of executables are all valid python interpreters, determines the abiflags and versions of those interpreters and returns them as PythonInterpreter
sourcepub fn run_script(&self, script: &str) -> Result<String>
pub fn run_script(&self, script: &str) -> Result<String>
Run a python script using this Python interpreter.
sourcepub fn support_portable_wheels(&self) -> bool
pub fn support_portable_wheels(&self) -> bool
Whether this Python interpreter support portable manylinux/musllinux wheels
Returns true
if we can not decide
Trait Implementations
sourceimpl Clone for PythonInterpreter
impl Clone for PythonInterpreter
sourcefn clone(&self) -> PythonInterpreter
fn clone(&self) -> PythonInterpreter
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for PythonInterpreter
impl Debug for PythonInterpreter
sourceimpl Deref for PythonInterpreter
impl Deref for PythonInterpreter
sourceimpl Display for PythonInterpreter
impl Display for PythonInterpreter
sourceimpl PartialEq<PythonInterpreter> for PythonInterpreter
impl PartialEq<PythonInterpreter> for PythonInterpreter
sourcefn eq(&self, other: &PythonInterpreter) -> bool
fn eq(&self, other: &PythonInterpreter) -> bool
impl Eq for PythonInterpreter
impl StructuralEq for PythonInterpreter
impl StructuralPartialEq for PythonInterpreter
Auto Trait Implementations
impl RefUnwindSafe for PythonInterpreter
impl Send for PythonInterpreter
impl Sync for PythonInterpreter
impl Unpin for PythonInterpreter
impl UnwindSafe for PythonInterpreter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Container<T> for Twhere
T: Clone,
impl<T> Container<T> for Twhere
T: Clone,
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.