From 8d0758fc4cf863ed82d6d4bacd9819e5fd69b3a4 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 8 Jul 2016 14:36:54 -0500 Subject: [PATCH] Allow py-meep to link properly --- .../repos/builtin/packages/meep/package.py | 5 ++++ .../repos/builtin/packages/py-meep/package.py | 26 +++++++++++++++---- .../builtin/packages/py-numpy/package.py | 13 ++++++++++ .../repos/builtin/packages/swig/package.py | 3 ++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/var/spack/repos/builtin/packages/meep/package.py b/var/spack/repos/builtin/packages/meep/package.py index cf4b72663d..e651d80a0b 100644 --- a/var/spack/repos/builtin/packages/meep/package.py +++ b/var/spack/repos/builtin/packages/meep/package.py @@ -61,6 +61,11 @@ def url_for_version(self, version): return "{0}/old/meep-{1}.tar.gz".format(base_url, version) def install(self, spec, prefix): + # Must be compiled with -fPIC for py-meep + env['CFLAGS'] = '-fPIC' + env['CXXFLAGS'] = '-fPIC' + env['FFLAGS'] = '-fPIC' + config_args = ['--prefix={0}'.format(prefix)] if '+blas' in spec: diff --git a/var/spack/repos/builtin/packages/py-meep/package.py b/var/spack/repos/builtin/packages/py-meep/package.py index 311d94b6bd..9582c81878 100644 --- a/var/spack/repos/builtin/packages/py-meep/package.py +++ b/var/spack/repos/builtin/packages/py-meep/package.py @@ -37,18 +37,34 @@ class PyMeep(Package): variant('mpi', default=True, description='Enable MPI support') extends('python') - depends_on('mpi', when='+mpi') # OpenMPI 1.3.3 is recommended - depends_on('meep@1.1.1') # must be compiled with -fPIC - depends_on('meep+mpi', when='+mpi') - depends_on('swig@1.3.39:') depends_on('py-numpy') depends_on('py-scipy') depends_on('py-matplotlib') + depends_on('mpi', when='+mpi') # OpenMPI 1.3.3 is recommended + depends_on('meep') # must be compiled with -fPIC + depends_on('meep+mpi', when='+mpi') + + # As of SWIG 3.0.3, Python-style comments are now treated as + # pre-processor directives. Use older SWIG. But not too old, + # or else it can't handle newer C++ compilers and flags. + depends_on('swig@1.3.39:3.0.2') + def install(self, spec, prefix): setup = 'setup-mpi.py' if '+mpi' in spec else 'setup.py' + include_dirs = [ + spec['meep'].prefix.include, + spec['py-numpy'].include + ] + + library_dirs = [ + spec['meep'].prefix.lib + ] + python(setup, 'clean', '--all') - python(setup, 'build_ext') + python(setup, 'build_ext', + '-I{0}'.format(','.join(include_dirs)), + '-L{0}'.format(','.join(library_dirs))) python(setup, 'install', '--prefix={0}'.format(prefix)) python(setup, 'bdist') diff --git a/var/spack/repos/builtin/packages/py-numpy/package.py b/var/spack/repos/builtin/packages/py-numpy/package.py index 2febdac658..f800b5e834 100644 --- a/var/spack/repos/builtin/packages/py-numpy/package.py +++ b/var/spack/repos/builtin/packages/py-numpy/package.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * +import platform class PyNumpy(Package): @@ -48,6 +49,18 @@ class PyNumpy(Package): depends_on('blas', when='+blas') depends_on('lapack', when='+lapack') + def setup_dependent_package(self, module, dep_spec): + python_version = self.spec['python'].version.up_to(2) + arch = '{0}-{1}'.format(platform.system().lower(), platform.machine()) + + self.spec.include = join_path( + self.prefix.lib, + 'python{0}'.format(python_version), + 'site-packages', + 'numpy-{0}-py{1}-{2}.egg'.format( + self.spec.version, python_version, arch), + 'numpy/core/include') + def install(self, spec, prefix): libraries = [] library_dirs = [] diff --git a/var/spack/repos/builtin/packages/swig/package.py b/var/spack/repos/builtin/packages/swig/package.py index f552621821..b43246dcee 100644 --- a/var/spack/repos/builtin/packages/swig/package.py +++ b/var/spack/repos/builtin/packages/swig/package.py @@ -22,9 +22,9 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## - from spack import * + class Swig(Package): """SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, @@ -38,6 +38,7 @@ class Swig(Package): homepage = "http://www.swig.org" url = "http://prdownloads.sourceforge.net/swig/swig-3.0.8.tar.gz" + version('3.0.10', 'bb4ab8047159469add7d00910e203124') version('3.0.8', 'c96a1d5ecb13d38604d7e92148c73c97') version('3.0.2', '62f9b0d010cef36a13a010dc530d0d41') version('2.0.12', 'c3fb0b2d710cc82ed0154b91e43085a4')