bin+lib python-config-rs

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.

3 releases

0.1.2 Feb 3, 2019
0.1.1 Feb 2, 2019
0.1.0 Feb 2, 2019

#231 in Build Utils

Download history 228/week @ 2022-06-10 145/week @ 2022-06-17 436/week @ 2022-06-24 154/week @ 2022-07-01 248/week @ 2022-07-08 156/week @ 2022-07-15 270/week @ 2022-07-22 109/week @ 2022-07-29 165/week @ 2022-08-05 262/week @ 2022-08-12 179/week @ 2022-08-19 138/week @ 2022-08-26 103/week @ 2022-09-02 205/week @ 2022-09-09 70/week @ 2022-09-16 253/week @ 2022-09-23

646 downloads per month


322 lines


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.