python-config-rs 0.1.2

Python distribution information via python3-config. This crate provides a Rust interface to your system's Python distribution information. Our goal is for this to be useful in build scripts, or in any application where getting the Python include directories, linker flags, or compile flags is necessary. This crate also provides a reimplementation of python3-config, the script, that can query configuration information about your distribution. The binary only needs a Python interpreter. We show that our binary is API compatible with existing `python3-config` scripts. See the repsitory for more project information.


API Documentation

The python-config-rs crate gives you the same insight as the python-config script bundled with your Python distribution. The crate is intended for build scripts that need

  • the Python include directories
  • flags for building / linking Python
  • ABI flags used when building your Python installation
  • any Python information already provided by python3-config
use python_config::PythonConfig;

let cfg = PythonConfig::new(); // Python 3 by default

// Print include directories
println!("Includes: {}", cfg.includes().unwrap());
// Print installation prefix
println!("Installation prefix: {}", cfg.prefix().unwrap());

This is Python 3 by default, but we provide a Python 2 interface. Note that the Python 2 interface has gone through significantly less testing.

Based on this library, we also provide a reimplementation of python3-config. Our automated tests show equivalence between our implementation and the normal python3-config script. The binary is Python 3 only.

python3-config API compatibility

The matrix belows shows our current compatibility with the default python3-config script based on the platform and Python distribution. A checkmark '✓' indicates that our test suite passed. A question mark '?' indicates that we have not conducted testing with this combination of host system and Python distribution. An 'X' indicates that we are not compatible on that system with that Python distribution.

Python macOS Debian Stretch
3.5 ?
3.7 ?

Some python3-config implementations return strings of flags that have more than one space between flags. These types of inconsistencies are acceptable in our testing.


Licensed under the Apache License, Version 2.0 (LICENSE-APACHE or available here) or the MIT license LICENSE-MIT or available here), at your option. All files in the project may not be copied, modified, or distributed except according to those terms.