#python #build-script #information #distribution #flags #interface #binary

build 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

#526 in Build Utils

Download history 296/week @ 2024-05-28 252/week @ 2024-06-04 175/week @ 2024-06-11 236/week @ 2024-06-18 282/week @ 2024-06-25 164/week @ 2024-07-02 207/week @ 2024-07-09 223/week @ 2024-07-16 229/week @ 2024-07-23 229/week @ 2024-07-30 154/week @ 2024-08-06 211/week @ 2024-08-13 134/week @ 2024-08-20 225/week @ 2024-08-27 213/week @ 2024-09-03 116/week @ 2024-09-10

698 downloads per month
Used in 2 crates

MIT/Apache

24KB
322 lines

python-config-rs

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.

License

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.

Dependencies

~180KB