From b66a92579ce12a65d218f65b64f6d1d3b1b64ce8 Mon Sep 17 00:00:00 2001 From: Rob Thatcher Date: Fri, 11 Sep 2020 16:57:49 +0100 Subject: [PATCH 1/2] treat Anaconda python as shared --- build.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 04ea5a47..9a61050e 100644 --- a/build.rs +++ b/build.rs @@ -680,9 +680,15 @@ import platform import struct import sys import sysconfig +import os.path PYPY = platform.python_implementation() == "PyPy" +# Anaconda based python distributions have a static python executable, but include +# the shared library. Use the shared library for embedding to avoid rust trying to +# LTO the static library (and failing with newer gcc's, because it is old). +ANACONDA = os.path.exists(os.path.join(sys.prefix, 'conda-meta')) + try: base_prefix = sys.base_prefix except AttributeError: @@ -697,7 +703,7 @@ if libdir is not None: print("libdir", libdir) print("ld_version", sysconfig.get_config_var('LDVERSION') or sysconfig.get_config_var('py_version_short')) print("base_prefix", base_prefix) -print("shared", PYPY or bool(sysconfig.get_config_var('Py_ENABLE_SHARED'))) +print("shared", PYPY or ANACONDA or bool(sysconfig.get_config_var('Py_ENABLE_SHARED'))) print("executable", sys.executable) print("calcsize_pointer", struct.calcsize("P")) "#; From 118646dd4a6de008ccf71da657247b8bb0e6da9f Mon Sep 17 00:00:00 2001 From: Rob Thatcher Date: Fri, 11 Sep 2020 17:31:41 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a0a9770..3014c019 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added +- Fix `build.rs` to work with Anaconda python - Add FFI definitions `Py_FinalizeEx`, `PyOS_getsig`, `PyOS_setsig`. [#1021](https://github.com/PyO3/pyo3/pull/1021) - Add `Python::with_gil` for executing a closure with the Python GIL. [#1037](https://github.com/PyO3/pyo3/pull/1037) - Implement `Debug` for `PyIterator`. [#1051](https://github.com/PyO3/pyo3/pull/1051)