From 21a2f816fcd47ee5119d2841b5c490e6c348129e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Niederb=C3=BChl?= Date: Wed, 15 May 2019 23:22:24 +0200 Subject: [PATCH] build.rs: Handle `python` being Python 2 If `python` refers to Python 2 (as recommended in [1]) the build fails with: AttributeError: 'module' object has no attribute 'base_prefix' Since there is no `base_prefix` in Python 2, simply use `exec_prefix` if the AttributeError is raised. [1] https://www.python.org/dev/peps/pep-0394/ --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 8efff375..52685d04 100644 --- a/build.rs +++ b/build.rs @@ -503,7 +503,10 @@ if PYPY: else: print(sysconfig.get_config_var('Py_ENABLE_SHARED')) print(sysconfig.get_config_var('LDVERSION') or sysconfig.get_config_var('py_version_short')) -print(sys.base_prefix) +try: + print(sys.base_prefix) +except AttributeError: + print(sys.exec_prefix) print(platform.python_implementation()) "#; let out = run_python_script(interpreter, script)?;