summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorRicardo Silva <ricardo.d.silva@gmail.com>2018-12-17 19:47:16 +0100
committerAdam J. Stewart <ajstewart426@gmail.com>2018-12-17 12:47:16 -0600
commitf979b974a5521e4595ea910e189668dbcab49c59 (patch)
treef778de90b140de4218c265bfc987c492da5b6f31 /var
parenta02cf107b5f0f4407a670365de77e286dc562cfa (diff)
downloadspack-f979b974a5521e4595ea910e189668dbcab49c59.tar.gz
spack-f979b974a5521e4595ea910e189668dbcab49c59.tar.bz2
spack-f979b974a5521e4595ea910e189668dbcab49c59.tar.xz
spack-f979b974a5521e4595ea910e189668dbcab49c59.zip
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
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/gdl/Always-build-antlr-as-shared-library.patch27
-rw-r--r--var/spack/repos/builtin/packages/gdl/package.py47
2 files changed, 69 insertions, 5 deletions
diff --git a/var/spack/repos/builtin/packages/gdl/Always-build-antlr-as-shared-library.patch b/var/spack/repos/builtin/packages/gdl/Always-build-antlr-as-shared-library.patch
new file mode 100644
index 0000000000..408258c95b
--- /dev/null
+++ b/var/spack/repos/builtin/packages/gdl/Always-build-antlr-as-shared-library.patch
@@ -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
+
diff --git a/var/spack/repos/builtin/packages/gdl/package.py b/var/spack/repos/builtin/packages/gdl/package.py
index ac49f17236..bcc01bec1e 100644
--- a/var/spack/repos/builtin/packages/gdl/package.py
+++ b/var/spack/repos/builtin/packages/gdl/package.py
@@ -2,7 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
+import os
from spack import *
@@ -27,7 +27,8 @@ class Gdl(CMakePackage):
variant('hdf5', default=True, description='Enable HDF5')
variant('openmp', default=True, description='Enable OpenMP')
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('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', when='~wx')
depends_on('proj', when='+proj')
- depends_on('py-numpy', type=('build', 'run'), when='+python')
- depends_on('python@2.7:2.8', 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='+embed_python')
depends_on('wx', when='+wx')
depends_on('eigen')
@@ -57,6 +58,21 @@ class Gdl(CMakePackage):
depends_on('pslib')
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):
args = []
@@ -92,11 +108,16 @@ class Gdl(CMakePackage):
else:
args += ['-DLIBPROJ4=OFF']
- if '+python' in self.spec:
+ if '+embed_python' in self.spec:
args += ['-DPYTHON=ON']
else:
args += ['-DPYTHON=OFF']
+ if '+python' in self.spec:
+ args += ['-DPYTHON_MODULE=ON']
+ else:
+ args += ['-DPYTHON_MODULE=OFF']
+
if '+wx' in self.spec:
args += ['-DWXWIDGETS=ON']
else:
@@ -108,3 +129,19 @@ class Gdl(CMakePackage):
args += ['-DX11=OFF']
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))