Struct PythonConfig

Source
pub struct PythonConfig { /* private fields */ }
Expand description

Exposes Python configuration information

Implementations§

Source§

impl PythonConfig

Source

pub fn new() -> Self

Create a new PythonConfig that uses the system installed Python 3 interpreter to query configuration information.

Source

pub fn version(version: Version) -> Self

Create a new PythonConfig that uses the system installed Python of version version.

§Example
use python_config::{PythonConfig, Version};

// Use the system-wide Python2 interpreter
let cfg = PythonConfig::version(Version::Two);
Source

pub fn interpreter<P: AsRef<Path>>(interpreter: P) -> PyResult<Self>

Create a PythonConfig that uses the interpreter at the path interpreter.

This fails if the path cannot be represented as a string, or if a query for the Python version fails.

§Example
use python_config::PythonConfig;

let cfg = PythonConfig::interpreter("/usr/local/bin/python3");
assert!(cfg.is_ok());
Source

pub fn version_raw(&self) -> PyResult<String>

Returns the Python version string

This is the raw return of python --version. Consider using semantic_version for something more useful.

Source

pub fn semantic_version(&self) -> PyResult<Version>

Returns the Python version as a semver

Source

pub fn prefix(&self) -> PyResult<String>

Returns the installation prefix of the Python interpreter as a string

Source

pub fn prefix_path(&self) -> PyResult<PathBuf>

Like prefix, but returns the installation prefix as a PathBuf.

Source

pub fn exec_prefix(&self) -> PyResult<String>

Returns the executable path prefix for the Python interpreter as a string

Source

pub fn exec_prefix_path(&self) -> PyResult<PathBuf>

Like exec_prefix, but returns the executable prefix as a PathBuf.

Source

pub fn includes(&self) -> PyResult<String>

Returns a list of paths that represent the include paths for the distribution’s headers. This is a space-delimited string of paths prefixed with -I.

Source

pub fn include_paths(&self) -> PyResult<Vec<PathBuf>>

Returns a list of paths that represent the include paths for the distribution’s headers. Unlike includes, This is simply a collection of paths.

Source

pub fn cflags(&self) -> PyResult<String>

All the flags useful for C compilation. This includes the include paths (see includes) as well as other compiler flags for this target. The return is a string with spaces separating the flags.

Source

pub fn libs(&self) -> PyResult<String>

Returns linker flags required for linking this Python distribution. All libraries / frameworks have the appropriate -l or -framework prefixes.

Source

pub fn ldflags(&self) -> PyResult<String>

Returns linker flags required for creating a shared library for this Python distribution. All libraries / frameworks have the appropriate -l or -framework prefixes.

Source

pub fn extension_suffix(&self) -> Py3Only<String>

Returns a string that represents the file extension for this distribution’s library

This is only available when your interpreter is a Python 3 interpreter! This is for feature parity with the python3-config script.

Source

pub fn abi_flags(&self) -> Py3Only<String>

The ABI flags specified when building this Python distribution

This is only available when your interpreter is a Python 3 interpreter! This is for feature parity with the python3-config script.

Source

pub fn config_dir(&self) -> Py3Only<String>

The location of the distribution’s actual python3-config script

This is only available when your interpreter is a Python 3 interpreter! This is for feature parity with the python3-config script.

Source

pub fn config_dir_path(&self) -> Py3Only<PathBuf>

Like config_dir, but returns the path to the distribution’s python-config script as a PathBuf.

This is only available when your interpreter is a Python 3 interpreter! This is for feature parity with the python3-config script.

Trait Implementations§

Source§

impl Default for PythonConfig

Source§

fn default() -> PythonConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.