[][src]Struct maturin::PythonInterpreter

pub struct PythonInterpreter {
    pub major: usize,
    pub minor: usize,
    pub abiflags: String,
    pub target: Target,
    pub executable: PathBuf,
    pub ext_suffix: Option<String>,
    pub interpreter: Interpreter,
    pub abi_tag: Option<String>,
}

The location and version of an interpreter

Fields

major: usize

Python's major version

minor: usize

Python's minor version

abiflags: String

For linux and mac, this contains the value of the abiflags, e.g. "m" for python3.5m or "dm" for python3.6dm. On windows, the value is always "".

See PEP 261 and PEP 393 for details

target: Target

Currently just the value of Target::os(), i.e. "windows", "linux", "macos" or "freebsd"

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

ext_suffix: Option<String>

Suffix to use for extension modules as given by sysconfig.

interpreter: Interpreter

cpython or pypy

abi_tag: Option<String>

Part of sysconfig's SOABI specifying {major}{minor}{abiflags}

Note that this always None on windows

Methods

impl PythonInterpreter[src]

pub fn get_tag(&self, manylinux: &Manylinux) -> String[src]

Returns the supported python environment in the PEP 425 format: {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

pub fn get_library_name(&self, base: &str) -> String[src]

Generates the correct suffix for shared libraries 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.5+ 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.5m: Linux: steinlaus.cpython-35m-x86_64-linux-gnu.so Windows: steinlaus.cp35-win_amd64.pyd Mac: steinlaus.cpython-35m-darwin.so FreeBSD: steinlaus.cpython-35m.so

For pypy3, we read sysconfig.get_config_var("EXT_SUFFIX").

The pypy3 value appears to be wrong for Windows: instead of e.g., ".pypy3-70-x86_64-linux-gnu.so", it is just ".pyd".

pub fn check_executable(
    executable: impl AsRef<Path>,
    target: &Target
) -> Result<Option<PythonInterpreter>, Error>
[src]

Checks whether the given command is a python interpreter and returns a PythonInterpreter if that is the case

pub fn find_all(target: &Target) -> Result<Vec<PythonInterpreter>, Error>[src]

Tries to find all installed python versions using the heuristic for the given platform

pub fn check_executables(
    executables: &[PathBuf],
    target: &Target
) -> Result<Vec<PythonInterpreter>, Error>
[src]

Checks that given list of executables are all valid python intepreters, determines the abiflags and versions of those interpreters and returns them as PythonInterpreter

Trait Implementations

impl PartialEq<PythonInterpreter> for PythonInterpreter[src]

impl Clone for PythonInterpreter[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Eq for PythonInterpreter[src]

impl Display for PythonInterpreter[src]

impl Debug for PythonInterpreter[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> Erased for T

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err