Skip to content

Commit 5857b91

Browse files
authored
Merge pull request #18 from LIHPC-Computational-Geometry/fix-pythonpath
Fix python path used by spack for cmake find_package(Python) directive
2 parents 092d1a9 + 75b95dc commit 5857b91

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

meshing/packages/pythonutil/package.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@ def cmake_args(self):
3131
args.append(self.define('USE_PYTHON_3', int(self.spec['python'].version[0]) >= 3))
3232
args.append(self.define('USE_PYTHON_2', int(self.spec['python'].version[0]) < 3))
3333

34+
# Fix cmake taking python3 even if `which python` is python2
35+
py = self.spec['python']
36+
args.extend([
37+
# find_package(PythonInterp) # Deprecated, but used by pybind11
38+
self.define('PYTHON_EXECUTABLE', py.command.path),
39+
# find_package(Python) under cmake_minimum_required < 3.15 (CMP0094)
40+
self.define('Python_EXECUTABLE', py.command.path),
41+
# find_package(Python2/3) under cmake_minimum_required < 3.15 (CMP0094)
42+
self.define('Python{}_EXECUTABLE'.format(py.version[0]), py.command.path),
43+
])
44+
3445
return args

meshing/packages/qtpython/package.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,15 @@ def cmake_args(self):
5252

5353
args.append('-DBUILD_PY_CONSOLE:BOOL=ON')
5454

55+
# Fix cmake taking python3 even if `which python` is python2
56+
py = self.spec['python']
57+
args.extend([
58+
# find_package(PythonInterp) # Deprecated, but used by pybind11
59+
self.define('PYTHON_EXECUTABLE', py.command.path),
60+
# find_package(Python) under cmake_minimum_required < 3.15 (CMP0094)
61+
self.define('Python_EXECUTABLE', py.command.path),
62+
# find_package(Python2/3) under cmake_minimum_required < 3.15 (CMP0094)
63+
self.define('Python{}_EXECUTABLE'.format(py.version[0]), py.command.path),
64+
])
65+
5566
return args

meshing/packages/tkutil/package.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ def cmake_args(self):
4747
args.append(self.define('USE_PYTHON_3', int(self.spec['python'].version[0]) >= 3))
4848
args.append(self.define('USE_PYTHON_2', int(self.spec['python'].version[0]) < 3))
4949

50+
# Fix cmake taking python3 even if `which python` is python2
51+
py = self.spec['python']
52+
args.extend([
53+
# find_package(PythonInterp) # Deprecated, but used by pybind11
54+
self.define('PYTHON_EXECUTABLE', py.command.path),
55+
# find_package(Python) under cmake_minimum_required < 3.15 (CMP0094)
56+
self.define('Python_EXECUTABLE', py.command.path),
57+
# find_package(Python2/3) under cmake_minimum_required < 3.15 (CMP0094)
58+
self.define('Python{}_EXECUTABLE'.format(py.version[0]), py.command.path),
59+
])
60+
5061
return args
51-
# def cmake_args(self):
52-
# spec = self.spec
53-
# return [
54-
# print(spec["libiconv"].libs)
55-
# return []

0 commit comments

Comments
 (0)