GDL: python integration fixes (#9936)
* GDL: python integration fixes * renamed python-related variants to follow the convention * building the Python module requires patches currently targetting 0.9.8 othwerwise asking for the Python module *only* builds the Pyhton module * building the python module also requires patching the vendored (with the GDL) antlr to be built as a shared library * Typo Co-Authored-By: rmsds <ricardo.d.silva@gmail.com> * Rename embed-python variant to embed_python
This commit is contained in:
parent
a02cf107b5
commit
f979b974a5
@ -0,0 +1,27 @@
|
|||||||
|
From: Ricardo Silva <ricardo.silva@epfl.ch>
|
||||||
|
Date: Wed, 3 Oct 2018 13:42:25 +0200
|
||||||
|
Subject: [PATCH] Always build antlr as shared library
|
||||||
|
|
||||||
|
---
|
||||||
|
src/antlr/CMakeLists.txt | 8 ++------
|
||||||
|
1 file changed, 2 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/antlr/CMakeLists.txt b/src/antlr/CMakeLists.txt
|
||||||
|
index 26a38e3..083e50d 100644
|
||||||
|
--- a/src/antlr/CMakeLists.txt
|
||||||
|
+++ b/src/antlr/CMakeLists.txt
|
||||||
|
@@ -2,9 +2,5 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} ANTLRSOURCES)
|
||||||
|
list(REMOVE_ITEM ANTLRSOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dll.cpp)
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/antlr)
|
||||||
|
|
||||||
|
-if(PYTHON_MODULE)
|
||||||
|
- add_library(antlr SHARED ${ANTLRSOURCES})
|
||||||
|
- install(TARGETS antlr DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
|
-else(PYTHON_MODULE)
|
||||||
|
- add_library(antlr STATIC ${ANTLRSOURCES})
|
||||||
|
-endif(PYTHON_MODULE)
|
||||||
|
+add_library(antlr SHARED ${ANTLRSOURCES})
|
||||||
|
+install(TARGETS antlr DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
import os
|
||||||
from spack import *
|
from spack import *
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +27,8 @@ class Gdl(CMakePackage):
|
|||||||
variant('hdf5', default=True, description='Enable HDF5')
|
variant('hdf5', default=True, description='Enable HDF5')
|
||||||
variant('openmp', default=True, description='Enable OpenMP')
|
variant('openmp', default=True, description='Enable OpenMP')
|
||||||
variant('proj', default=True, description='Enable LIBPROJ4')
|
variant('proj', default=True, description='Enable LIBPROJ4')
|
||||||
variant('python', default=False, description='Enable Python')
|
variant('embed_python', default=False, description='Ability to embed Python within GDL')
|
||||||
|
variant('python', default=False, description='Build the GDL Python module')
|
||||||
variant('wx', default=False, description='Enable WxWidgets')
|
variant('wx', default=False, description='Enable WxWidgets')
|
||||||
variant('x11', default=False, description='Enable X11')
|
variant('x11', default=False, description='Enable X11')
|
||||||
|
|
||||||
@ -41,8 +42,8 @@ class Gdl(CMakePackage):
|
|||||||
depends_on('plplot+wx+wxold', when='+wx@5.12:')
|
depends_on('plplot+wx+wxold', when='+wx@5.12:')
|
||||||
depends_on('plplot~wx', when='~wx')
|
depends_on('plplot~wx', when='~wx')
|
||||||
depends_on('proj', when='+proj')
|
depends_on('proj', when='+proj')
|
||||||
depends_on('py-numpy', type=('build', 'run'), when='+python')
|
depends_on('py-numpy', type=('build', 'run'), when='+embed_python')
|
||||||
depends_on('python@2.7:2.8', type=('build', 'run'), when='+python')
|
depends_on('python@2.7:2.8', type=('build', 'run'), when='+embed_python')
|
||||||
depends_on('wx', when='+wx')
|
depends_on('wx', when='+wx')
|
||||||
|
|
||||||
depends_on('eigen')
|
depends_on('eigen')
|
||||||
@ -57,6 +58,21 @@ class Gdl(CMakePackage):
|
|||||||
depends_on('pslib')
|
depends_on('pslib')
|
||||||
depends_on('readline')
|
depends_on('readline')
|
||||||
|
|
||||||
|
conflicts('+python', when='~embed_python')
|
||||||
|
|
||||||
|
# Building the Python module requires patches currently targetting 0.9.8
|
||||||
|
# othwerwise asking for the Python module *only* builds the Python module
|
||||||
|
conflicts('+python', when='@:0.9.7,0.9.9:')
|
||||||
|
|
||||||
|
# Allows building gdl as a shared library to in turn allow building
|
||||||
|
# both the executable and the Python module
|
||||||
|
patch('https://sources.debian.org/data/main/g/gnudatalanguage/0.9.8-7/debian/patches/Create-a-shared-library.patch',
|
||||||
|
sha256='bb380394c8ea2602404d8cd18047b93cf00fdb73b83d389f30100dd4b0e1a05c',
|
||||||
|
when='@0.9.8')
|
||||||
|
patch('Always-build-antlr-as-shared-library.patch',
|
||||||
|
sha256='f40c06e8a8f1977780787f58885590affd7e382007cb677d2fb4723aaadd415c',
|
||||||
|
when='@0.9.8')
|
||||||
|
|
||||||
def cmake_args(self):
|
def cmake_args(self):
|
||||||
args = []
|
args = []
|
||||||
|
|
||||||
@ -92,11 +108,16 @@ def cmake_args(self):
|
|||||||
else:
|
else:
|
||||||
args += ['-DLIBPROJ4=OFF']
|
args += ['-DLIBPROJ4=OFF']
|
||||||
|
|
||||||
if '+python' in self.spec:
|
if '+embed_python' in self.spec:
|
||||||
args += ['-DPYTHON=ON']
|
args += ['-DPYTHON=ON']
|
||||||
else:
|
else:
|
||||||
args += ['-DPYTHON=OFF']
|
args += ['-DPYTHON=OFF']
|
||||||
|
|
||||||
|
if '+python' in self.spec:
|
||||||
|
args += ['-DPYTHON_MODULE=ON']
|
||||||
|
else:
|
||||||
|
args += ['-DPYTHON_MODULE=OFF']
|
||||||
|
|
||||||
if '+wx' in self.spec:
|
if '+wx' in self.spec:
|
||||||
args += ['-DWXWIDGETS=ON']
|
args += ['-DWXWIDGETS=ON']
|
||||||
else:
|
else:
|
||||||
@ -108,3 +129,19 @@ def cmake_args(self):
|
|||||||
args += ['-DX11=OFF']
|
args += ['-DX11=OFF']
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
@run_after('install')
|
||||||
|
def post_install(self):
|
||||||
|
if '+python' in self.spec:
|
||||||
|
# gdl installs the python module into prefix/lib/site-python
|
||||||
|
# move it to the standard location
|
||||||
|
src = os.path.join(
|
||||||
|
self.spec.prefix.lib,
|
||||||
|
'site-python')
|
||||||
|
dst = site_packages_dir
|
||||||
|
if os.path.isdir(src):
|
||||||
|
if not os.path.isdir(dst):
|
||||||
|
mkdirp(dst)
|
||||||
|
for f in os.listdir(src):
|
||||||
|
os.rename(os.path.join(src, f),
|
||||||
|
os.path.join(dst, f))
|
||||||
|
Loading…
Reference in New Issue
Block a user