pub struct PythonConfig { /* private fields */ }
Expand description
Exposes Python configuration information
Implementations§
Source§impl PythonConfig
impl PythonConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new PythonConfig
that uses the system installed Python 3
interpreter to query configuration information.
Sourcepub fn version(version: Version) -> Self
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);
Sourcepub fn interpreter<P: AsRef<Path>>(interpreter: P) -> PyResult<Self>
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());
Sourcepub fn version_raw(&self) -> PyResult<String>
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.
Sourcepub fn semantic_version(&self) -> PyResult<Version>
pub fn semantic_version(&self) -> PyResult<Version>
Returns the Python version as a semver
Sourcepub fn prefix(&self) -> PyResult<String>
pub fn prefix(&self) -> PyResult<String>
Returns the installation prefix of the Python interpreter as a string
Sourcepub fn prefix_path(&self) -> PyResult<PathBuf>
pub fn prefix_path(&self) -> PyResult<PathBuf>
Like prefix
, but returns
the installation prefix as a PathBuf
.
Sourcepub fn exec_prefix(&self) -> PyResult<String>
pub fn exec_prefix(&self) -> PyResult<String>
Returns the executable path prefix for the Python interpreter as a string
Sourcepub fn exec_prefix_path(&self) -> PyResult<PathBuf>
pub fn exec_prefix_path(&self) -> PyResult<PathBuf>
Like exec_prefix
, but
returns the executable prefix as a PathBuf
.
Sourcepub fn includes(&self) -> PyResult<String>
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
.
Sourcepub fn include_paths(&self) -> PyResult<Vec<PathBuf>>
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.
Sourcepub fn cflags(&self) -> PyResult<String>
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.
Sourcepub fn libs(&self) -> PyResult<String>
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.
Sourcepub fn ldflags(&self) -> PyResult<String>
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.
Sourcepub fn extension_suffix(&self) -> Py3Only<String>
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.
Sourcepub fn abi_flags(&self) -> Py3Only<String>
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.
Sourcepub fn config_dir(&self) -> Py3Only<String>
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.
Sourcepub fn config_dir_path(&self) -> Py3Only<PathBuf>
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.