From 0393486c36a24d7880356c79cb1a9e1cebc0ec78 Mon Sep 17 00:00:00 2001 From: jmansour Date: Sun, 11 Oct 2020 13:33:35 +1100 Subject: [PATCH] Tweak for Python config script. --- CHANGES.md | 1 + .../libUnderworld/config/packages/Python.py | 28 ++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f54514158..b049ed26e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ Release 2.11.0 [] ----------------- Changes * Enabled user defined Gauss integration swarms for all systems. +* Cleaner Python compile time configuration. New: * Added `underworld.function.count()` method, which counts function calls. diff --git a/underworld/libUnderworld/config/packages/Python.py b/underworld/libUnderworld/config/packages/Python.py index 2177bc029..514f02baf 100644 --- a/underworld/libUnderworld/config/packages/Python.py +++ b/underworld/libUnderworld/config/packages/Python.py @@ -1,9 +1,14 @@ from config import Package +from distutils.sysconfig import get_python_inc, get_python_lib, get_python_version import os class Python(Package): def gen_locations(self): + python_inc = get_python_inc() + python_base = os.path.dirname(os.path.dirname(get_python_inc())) + python_lib = os.path.join(python_base,"lib") + yield ( python_base, [python_inc,], [python_lib,] ) yield ('/usr/local', ['/usr/local/include'], ['/usr/local/lib']) yield ('/opt/local', ['/opt/local/include'], ['/opt/local/lib']) @@ -13,19 +18,10 @@ def gen_envs(self, loc): if self.find_libraries(loc[2], 'python'): env.PrependUnique(LIBS=['python']) yield env - if self.find_libraries(loc[2], 'python3.5m'): - env.AppendUnique(CPPPATH=[os.path.join(self.location[1][0],'python3.5m')]) - env.PrependUnique(LIBS=['python3.5m']) - yield env - if self.find_libraries(loc[2], 'python3.6m'): - env.AppendUnique(CPPPATH=[os.path.join(self.location[1][0],'python3.6m')]) - env.PrependUnique(LIBS=['python3.6m']) - yield env - if self.find_libraries(loc[2], 'python3.7m'): - env.AppendUnique(CPPPATH=[os.path.join(self.location[1][0],'python3.7m')]) - env.PrependUnique(LIBS=['python3.7m']) - yield env - if self.find_libraries(loc[2], 'python3.8'): - env.AppendUnique(CPPPATH=[os.path.join(self.location[1][0],'python3.8')]) - env.PrependUnique(LIBS=['python3.8']) - yield env + ver = "python"+ get_python_version() + for ver in [ver, ver+"m"]: + if self.find_libraries(loc[2], ver ): + env.AppendUnique(CPPPATH=[os.path.join(self.location[1][0],ver)]) + env.PrependUnique(LIBS=[ver]) + yield env +