Rename PYTHON_SYS_EXECUTABLE to PYO3_PYTHON

This commit is contained in:
David Hewitt 2020-07-13 22:38:45 +01:00
parent f2ba3e6da7
commit dc5c2a9b8f
4 changed files with 17 additions and 7 deletions

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Correct FFI definitions `Py_SetProgramName` and `Py_SetPythonHome` to take `*const` argument instead of `*mut`. [#1021](https://github.com/PyO3/pyo3/pull/1021)
- Rename `PyString::to_string` to `to_str`, change return type `Cow<str>` to `&str`. [#1023](https://github.com/PyO3/pyo3/pull/1023)
- Correct FFI definition `_PyLong_AsByteArray` `*mut c_uchar` argument instead of `*const c_uchar`. [#1029](https://github.com/PyO3/pyo3/pull/1029)
- Rename `PYTHON_SYS_EXECUTABLE` to `PYO3_PYTHON`. The old name will continue to work but will be undocumented, and will be removed in a future release. [#1039](https://github.com/PyO3/pyo3/pull/1039)
- `PyType::as_type_ptr` is no longer `unsafe`. [#1047](https://github.com/PyO3/pyo3/pull/1047)
- Change `PyIterator::from_object` to return `PyResult<PyIterator>` instead of `Result<PyIterator, PyDowncastError>`. [#1051](https://github.com/PyO3/pyo3/pull/1051)
- Implement `Send + Sync` for `PyErr`. `PyErr::new`, `PyErr::from_type`, `PyException::py_err` and `PyException::into` have had these bounds added to their arguments. [#1067](https://github.com/PyO3/pyo3/pull/1067)

View File

@ -386,7 +386,7 @@ fn get_rustc_link_lib(config: &InterpreterConfig) -> Result<String> {
///
/// The following locations are checked in the order listed:
///
/// 1. If `PYTHON_SYS_EXECUTABLE` is set, this intepreter is used and an error is raised if the
/// 1. If `PYO3_PYTHON` is set, this intepreter is used and an error is raised if the
/// version doesn't match.
/// 2. `python`
/// 3. `python{major version}`
@ -394,7 +394,10 @@ fn get_rustc_link_lib(config: &InterpreterConfig) -> Result<String> {
///
/// If none of the above works, an error is returned
fn find_interpreter_and_get_config() -> Result<(InterpreterConfig, HashMap<String, String>)> {
let python_interpreter = if let Some(exe) = env::var_os("PYTHON_SYS_EXECUTABLE") {
let python_interpreter = if let Some(exe) = env::var_os("PYO3_PYTHON") {
exe.into()
} else if let Some(exe) = env::var_os("PYTHON_SYS_EXECUTABLE") {
// Backwards-compatible name for PYO3_PYTHON; this may be removed at some point in the future.
exe.into()
} else {
PathBuf::from(
@ -506,7 +509,7 @@ fn configure(interpreter_config: &InterpreterConfig) -> Result<String> {
};
if interpreter_config.version.major == 2 {
// fail PYTHON_SYS_EXECUTABLE=python2 cargo ...
// fail PYO3_PYTHON=python2 cargo ...
bail!("Python 2 is not supported");
}
@ -637,7 +640,13 @@ fn main() -> Result<()> {
// TODO: Find out how we can set -undefined dynamic_lookup here (if this is possible)
}
let env_vars = ["LD_LIBRARY_PATH", "PATH", "PYTHON_SYS_EXECUTABLE", "LIB"];
let env_vars = [
"LD_LIBRARY_PATH",
"PATH",
"PYTHON_SYS_EXECUTABLE",
"PYO3_PYTHON",
"LIB",
];
for var in env_vars.iter() {
println!("cargo:rerun-if-env-changed={}", var);

View File

@ -2,7 +2,7 @@
## Python version
PyO3 uses a build script to determine the Python version and set the correct linker arguments. By default it uses the `python3` executable. You can override the Python interpreter by setting `PYTHON_SYS_EXECUTABLE`, e.g., `PYTHON_SYS_EXECUTABLE=python3.6`.
PyO3 uses a build script to determine the Python version and set the correct linker arguments. By default it uses the `python3` executable. You can override the Python interpreter by setting `PYO3_PYTHON`, e.g., `PYO3_PYTHON=python3.6`.
## Linking

View File

@ -6,9 +6,9 @@ Support is only provided for building Rust extension for code running under PyPy
This is a limitation of cpyext and support for embedding cpyext is not planned.
Compilation against PyPy is done by exporting the `PYTHON_SYS_EXECUTABLE` to point to a PyPy binary or by compiling in a PyPy virtualenv.
Compilation against PyPy is done by exporting `PYO3_PYTHON` to point to a PyPy binary or by compiling in a PyPy virtualenv.
For example, `PYTHON_SYS_EXECUTABLE="/path/to/pypy3" /path/to/pypy3 setup.py install`
For example, `PYO3_PYTHON="/path/to/pypy3" /path/to/pypy3 setup.py install`
## Unsupported features