2016-05-11 21:22:25 -07:00
|
|
|
##############################################################################
|
2018-03-24 12:13:52 -07:00
|
|
|
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
|
2016-05-11 21:22:25 -07:00
|
|
|
# Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
#
|
|
|
|
# This file is part of Spack.
|
|
|
|
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
|
|
|
# LLNL-CODE-647188
|
|
|
|
#
|
2017-11-04 17:08:04 -07:00
|
|
|
# For details, see https://github.com/spack/spack
|
2017-06-24 22:22:55 -07:00
|
|
|
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
2016-05-11 21:22:25 -07:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License (as
|
|
|
|
# published by the Free Software Foundation) version 2.1, February 1999.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
|
|
|
# conditions of the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
##############################################################################
|
2015-03-12 08:49:45 -07:00
|
|
|
from spack import *
|
2016-05-16 11:09:44 -07:00
|
|
|
|
2015-03-12 08:49:45 -07:00
|
|
|
|
|
|
|
class Scotch(Package):
|
|
|
|
"""Scotch is a software package for graph and mesh/hypergraph
|
|
|
|
partitioning, graph clustering, and sparse matrix ordering."""
|
2016-04-22 14:50:19 -07:00
|
|
|
|
2015-03-12 08:49:45 -07:00
|
|
|
homepage = "http://www.labri.fr/perso/pelegrin/scotch/"
|
2017-04-03 17:34:16 -05:00
|
|
|
url = "http://gforge.inria.fr/frs/download.php/latestfile/298/scotch_6.0.4.tar.gz"
|
2015-03-12 08:49:45 -07:00
|
|
|
list_url = "http://gforge.inria.fr/frs/?group_id=248"
|
|
|
|
|
2018-07-15 15:54:28 -05:00
|
|
|
version('6.0.6', 'ef676a3118b5590c416176e402fac248')
|
2018-06-08 15:39:03 +02:00
|
|
|
version('6.0.5a', '8430dff7175a1dfd5a3258e75260cf71')
|
2016-12-10 19:23:03 -05:00
|
|
|
version('6.0.4', 'd58b825eb95e1db77efe8c6ff42d329f')
|
2015-03-12 08:49:45 -07:00
|
|
|
version('6.0.3', '10b0cc0f184de2de99859eafaca83cfc')
|
2016-05-20 00:31:12 +02:00
|
|
|
version('6.0.0', 'c50d6187462ba801f9a82133ee666e8e')
|
|
|
|
version('5.1.10b', 'f587201d6cf5cf63527182fbfba70753')
|
2015-03-13 13:32:24 -07:00
|
|
|
|
2016-12-16 12:49:02 -06:00
|
|
|
variant('mpi', default=True,
|
2016-08-10 01:50:00 -07:00
|
|
|
description='Activate the compilation of parallel libraries')
|
|
|
|
variant('compression', default=True,
|
|
|
|
description='Activate the posibility to use compressed files')
|
|
|
|
variant('esmumps', default=False,
|
|
|
|
description='Activate the compilation of esmumps needed by mumps')
|
|
|
|
variant('shared', default=True,
|
|
|
|
description='Build a shared version of the library')
|
|
|
|
variant('metis', default=True,
|
|
|
|
description='Build metis and parmetis wrapper libraries')
|
2017-03-27 14:48:14 +02:00
|
|
|
variant('int64', default=False,
|
|
|
|
description='Use int64_t for SCOTCH_Num typedef')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
2017-06-26 15:58:02 +01:00
|
|
|
# Does not build with flex 2.6.[23]
|
|
|
|
depends_on('flex@:2.6.1,2.6.4:', type='build')
|
2016-03-09 10:46:56 -05:00
|
|
|
depends_on('bison', type='build')
|
2016-04-22 14:50:19 -07:00
|
|
|
depends_on('mpi', when='+mpi')
|
|
|
|
depends_on('zlib', when='+compression')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
2017-03-27 14:48:14 +02:00
|
|
|
# Version-specific patches
|
|
|
|
patch('nonthreaded-6.0.4.patch', when='@6.0.4')
|
2017-06-21 18:36:18 +02:00
|
|
|
patch('esmumps-ldflags-6.0.4.patch', when='@6.0.4')
|
2018-06-08 15:39:03 +02:00
|
|
|
patch('metis-headers-6.0.4.patch', when='@6.0.4')
|
2017-03-27 14:48:14 +02:00
|
|
|
|
2018-07-13 15:51:04 -05:00
|
|
|
patch('libscotchmetis-return-6.0.5a.patch', when='@6.0.5a')
|
|
|
|
|
2017-02-22 20:04:14 +01:00
|
|
|
# NOTE: In cross-compiling environment parallel build
|
|
|
|
# produces weird linker errors.
|
|
|
|
parallel = False
|
|
|
|
|
2016-04-29 11:44:38 -07:00
|
|
|
# NOTE: Versions of Scotch up to version 6.0.0 don't include support for
|
|
|
|
# building with 'esmumps' in their default packages. In order to enable
|
|
|
|
# support for this feature, we must grab the 'esmumps' enabled archives
|
2016-05-16 11:09:44 -07:00
|
|
|
# from the Scotch hosting site. These alternative archives include a
|
2016-04-29 11:44:38 -07:00
|
|
|
# superset of the behavior in their default counterparts, so we choose to
|
|
|
|
# always grab these versions for older Scotch versions for simplicity.
|
2016-05-20 00:51:58 +02:00
|
|
|
@when('@:6.0.0')
|
2016-05-19 16:37:53 +02:00
|
|
|
def url_for_version(self, version):
|
2017-04-03 17:34:16 -05:00
|
|
|
url = "http://gforge.inria.fr/frs/download.php/latestfile/298/scotch_{0}_esmumps.tar.gz"
|
|
|
|
return url.format(version)
|
2016-04-29 11:44:38 -07:00
|
|
|
|
2017-06-21 18:36:18 +02:00
|
|
|
@property
|
|
|
|
def libs(self):
|
|
|
|
|
|
|
|
shared = '+shared' in self.spec
|
|
|
|
libraries = ['libscotch', 'libscotcherr']
|
2017-06-28 19:22:18 +01:00
|
|
|
zlibs = []
|
2017-06-21 18:36:18 +02:00
|
|
|
|
|
|
|
if '+mpi' in self.spec:
|
|
|
|
libraries = ['libptscotch', 'libptscotcherr'] + libraries
|
|
|
|
if '+esmumps' in self.spec:
|
|
|
|
libraries = ['libptesmumps'] + libraries
|
|
|
|
elif '~mpi+esmumps' in self.spec:
|
|
|
|
libraries = ['libesmumps'] + libraries
|
|
|
|
|
2017-06-28 19:22:18 +01:00
|
|
|
scotchlibs = find_libraries(
|
2017-08-03 17:21:40 +02:00
|
|
|
libraries, root=self.prefix, recursive=True, shared=shared
|
2017-06-21 18:36:18 +02:00
|
|
|
)
|
2017-06-28 19:22:18 +01:00
|
|
|
if '+compression' in self.spec:
|
|
|
|
zlibs = self.spec['zlib'].libs
|
|
|
|
|
|
|
|
return scotchlibs + zlibs
|
2017-06-21 18:36:18 +02:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
def patch(self):
|
2016-05-19 16:37:53 +02:00
|
|
|
self.configure()
|
2016-04-29 11:44:38 -07:00
|
|
|
|
2016-05-16 11:09:44 -07:00
|
|
|
# NOTE: Configuration of Scotch is achieved by writing a 'Makefile.inc'
|
|
|
|
# file that contains all of the configuration variables and their desired
|
|
|
|
# values for the installation. This function writes this file based on
|
|
|
|
# the given installation variants.
|
2016-04-29 11:44:38 -07:00
|
|
|
def configure(self):
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc = []
|
|
|
|
cflags = [
|
|
|
|
'-O3',
|
|
|
|
'-DCOMMON_RANDOM_FIXED_SEED',
|
|
|
|
'-DSCOTCH_DETERMINISTIC',
|
|
|
|
'-DSCOTCH_RENAME',
|
2017-03-27 14:48:14 +02:00
|
|
|
'-DIDXSIZE64', # SCOTCH_Idx typedef: indices for addressing
|
2016-05-16 11:09:44 -07:00
|
|
|
]
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2017-03-27 14:48:14 +02:00
|
|
|
# SCOTCH_Num typedef: size of integers in arguments
|
|
|
|
if '+int64' in self.spec:
|
|
|
|
cflags.append('-DINTSIZE64')
|
|
|
|
|
2016-11-27 01:48:50 +01:00
|
|
|
if self.spec.satisfies('platform=darwin'):
|
|
|
|
cflags.extend([
|
|
|
|
'-Drestrict=__restrict'
|
|
|
|
])
|
|
|
|
|
2016-05-16 11:09:44 -07:00
|
|
|
# Library Build Type #
|
2016-04-22 14:50:19 -07:00
|
|
|
if '+shared' in self.spec:
|
2016-11-27 01:48:50 +01:00
|
|
|
if self.spec.satisfies('platform=darwin'):
|
|
|
|
makefile_inc.extend([
|
|
|
|
'LIB = .dylib',
|
2017-08-04 18:21:43 +02:00
|
|
|
'CLIBFLAGS = -dynamiclib {0}'.format(
|
|
|
|
self.compiler.pic_flag
|
|
|
|
),
|
2016-11-27 01:48:50 +01:00
|
|
|
'RANLIB = echo',
|
|
|
|
'AR = $(CC)',
|
|
|
|
'ARFLAGS = -dynamiclib $(LDFLAGS) -Wl,-install_name -Wl,%s/$(notdir $@) -undefined dynamic_lookup -o ' % prefix.lib # noqa
|
|
|
|
])
|
|
|
|
else:
|
|
|
|
makefile_inc.extend([
|
|
|
|
'LIB = .so',
|
2017-08-04 18:21:43 +02:00
|
|
|
'CLIBFLAGS = -shared {0}'.format(self.compiler.pic_flag),
|
2016-11-27 01:48:50 +01:00
|
|
|
'RANLIB = echo',
|
|
|
|
'AR = $(CC)',
|
|
|
|
'ARFLAGS = -shared $(LDFLAGS) -o'
|
|
|
|
])
|
2017-08-04 18:21:43 +02:00
|
|
|
cflags.append(self.compiler.pic_flag)
|
2015-12-14 21:59:40 +01:00
|
|
|
else:
|
|
|
|
makefile_inc.extend([
|
2016-04-22 14:50:19 -07:00
|
|
|
'LIB = .a',
|
|
|
|
'CLIBFLAGS = ',
|
|
|
|
'RANLIB = ranlib',
|
2016-05-20 00:31:12 +02:00
|
|
|
'AR = ar',
|
2016-04-22 14:50:19 -07:00
|
|
|
'ARFLAGS = -ruv '
|
2016-05-16 11:09:44 -07:00
|
|
|
])
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-05-16 11:09:44 -07:00
|
|
|
# Compiler-Specific Options #
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
if self.compiler.name == 'gcc':
|
|
|
|
cflags.append('-Drestrict=__restrict')
|
|
|
|
elif self.compiler.name == 'intel':
|
2018-03-21 20:22:50 +01:00
|
|
|
cflags.append('-Drestrict=')
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-05-16 11:09:44 -07:00
|
|
|
mpicc_path = self.spec['mpi'].mpicc if '+mpi' in self.spec else 'mpicc'
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc.append('CCS = $(CC)')
|
2016-05-16 11:09:44 -07:00
|
|
|
makefile_inc.append('CCP = %s' % mpicc_path)
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc.append('CCD = $(CCS)')
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-05-16 11:09:44 -07:00
|
|
|
# Extra Features #
|
2015-12-14 21:59:40 +01:00
|
|
|
|
|
|
|
ldflags = []
|
2016-04-22 14:50:19 -07:00
|
|
|
|
2015-12-14 21:59:40 +01:00
|
|
|
if '+compression' in self.spec:
|
2016-04-22 14:50:19 -07:00
|
|
|
cflags.append('-DCOMMON_FILE_COMPRESS_GZ')
|
2017-06-21 18:36:18 +02:00
|
|
|
ldflags.append(' {0} '.format(self.spec['zlib'].libs.joined()))
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
cflags.append('-DCOMMON_PTHREAD')
|
2017-02-22 20:04:14 +01:00
|
|
|
|
|
|
|
# NOTE: bg-q platform needs -lpthread (and not -pthread)
|
|
|
|
# otherwise we get illegal instruction error during runtime
|
2016-11-27 01:48:50 +01:00
|
|
|
if self.spec.satisfies('platform=darwin'):
|
|
|
|
cflags.append('-DCOMMON_PTHREAD_BARRIER')
|
|
|
|
ldflags.append('-lm -pthread')
|
2017-02-22 20:04:14 +01:00
|
|
|
elif self.spec.satisfies('platform=bgq'):
|
|
|
|
ldflags.append('-lm -lrt -lpthread')
|
2016-11-27 01:48:50 +01:00
|
|
|
else:
|
|
|
|
ldflags.append('-lm -lrt -pthread')
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-04-22 14:50:19 -07:00
|
|
|
makefile_inc.append('LDFLAGS = %s' % ' '.join(ldflags))
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2016-05-16 11:09:44 -07:00
|
|
|
# General Features #
|
2015-12-14 21:59:40 +01:00
|
|
|
|
Python command, libraries, and headers (#3367)
## Motivation
Python installations are both important and unfortunately inconsistent. Depending on the Python version, OS, and the strength of the Earth's magnetic field when it was installed, the name of the Python executable, directory containing its libraries, library names, and the directory containing its headers can vary drastically.
I originally got into this mess with #3274, where I discovered that Boost could not be built with Python 3 because the executable is called `python3` and we were telling it to use `python`. I got deeper into this mess when I started hacking on #3140, where I discovered just how difficult it is to find the location and name of the Python libraries and headers.
Currently, half of the packages that depend on Python and need to know this information jump through hoops to determine the correct information. The other half are hard-coded to use `python`, `spec['python'].prefix.lib`, and `spec['python'].prefix.include`. Obviously, none of these packages would work for Python 3, and there's no reason to duplicate the effort. The Python package itself should contain all of the information necessary to use it properly. This is in line with the recent work by @alalazo and @davydden with respect to `spec['blas'].libs` and friends.
## Prefix
For most packages in Spack, we assume that the installation directory is `spec['python'].prefix`. This generally works for anything installed with Spack, but gets complicated when we include external packages. Python is a commonly used external package (it needs to be installed just to run Spack). If it was installed with Homebrew, `which python` would return `/usr/local/bin/python`, and most users would erroneously assume that `/usr/local` is the installation directory. If you peruse through #2173, you'll immediately see why this is not the case. Homebrew actually installs Python in `/usr/local/Cellar/python/2.7.12_2` and symlinks the executable to `/usr/local/bin/python`. `PYTHONHOME` (and presumably most things that need to know where Python is installed) needs to be set to the actual installation directory, not `/usr/local`.
Normally I would say, "sounds like user error, make sure to use the real installation directory in your `packages.yaml`". But I think we can make a special case for Python. That's what we decided in #2173 anyway. If we change our minds, I would be more than happy to simplify things.
To solve this problem, I created a `spec['python'].home` attribute that works the same way as `spec['python'].prefix` but queries Python to figure out where it was actually installed. @tgamblin Is there any way to overwrite `spec['python'].prefix`? I think it's currently immutable.
## Command
In general, Python 2 comes with both `python` and `python2` commands, while Python 3 only comes with a `python3` command. But this is up to the OS developers. For example, `/usr/bin/python` on Gentoo is actually Python 3. Worse yet, if someone is using an externally installed Python, all 3 commands may exist in the same directory! Here's what I'm thinking:
If the spec is for Python 3, try searching for the `python3` command.
If the spec is for Python 2, try searching for the `python2` command.
If neither are found, try searching for the `python` command.
## Libraries
Spack installs Python libraries in `spec['python'].prefix.lib`. Except on openSUSE 13, where it installs to `spec['python'].prefix.lib64` (see #2295 and #2253). On my CentOS 6 machine, the Python libraries are installed in `/usr/lib64`. Both need to work.
The libraries themselves change name depending on OS and Python version. For Python 2.7 on macOS, I'm seeing:
```
lib/libpython2.7.dylib
```
For Python 3.6 on CentOS 6, I'm seeing:
```
lib/libpython3.so
lib/libpython3.6m.so.1.0
lib/libpython3.6m.so -> lib/libpython3.6m.so.1.0
```
Notice the `m` after the version number. Yeah, that's a thing.
## Headers
In Python 2.7, I'm seeing:
```
include/python2.7/pyconfig.h
```
In Python 3.6, I'm seeing:
```
include/python3.6m/pyconfig.h
```
It looks like all Python 3 installations have this `m`. Tested with Python 3.2 and 3.6 on macOS and CentOS 6
Spack has really nice support for libraries (`find_libraries` and `LibraryList`), but nothing for headers. Fixed.
2017-04-29 19:24:13 -05:00
|
|
|
flex_path = self.spec['flex'].command.path
|
|
|
|
bison_path = self.spec['bison'].command.path
|
2015-12-14 21:59:40 +01:00
|
|
|
makefile_inc.extend([
|
|
|
|
'EXE =',
|
|
|
|
'OBJ = .o',
|
|
|
|
'MAKE = make',
|
|
|
|
'CAT = cat',
|
|
|
|
'LN = ln',
|
|
|
|
'MKDIR = mkdir',
|
|
|
|
'MV = mv',
|
|
|
|
'CP = cp',
|
2016-04-22 14:50:19 -07:00
|
|
|
'CFLAGS = %s' % ' '.join(cflags),
|
2016-05-16 11:09:44 -07:00
|
|
|
'LEX = %s -Pscotchyy -olex.yy.c' % flex_path,
|
|
|
|
'YACC = %s -pscotchyy -y -b y' % bison_path,
|
2016-04-22 14:50:19 -07:00
|
|
|
'prefix = %s' % self.prefix
|
2016-05-16 11:09:44 -07:00
|
|
|
])
|
2015-12-14 21:59:40 +01:00
|
|
|
|
2015-12-20 13:27:43 +01:00
|
|
|
with working_dir('src'):
|
2015-12-20 13:38:22 +01:00
|
|
|
with open('Makefile.inc', 'w') as fh:
|
|
|
|
fh.write('\n'.join(makefile_inc))
|
2016-04-22 14:50:19 -07:00
|
|
|
|
2015-03-12 08:49:45 -07:00
|
|
|
def install(self, spec, prefix):
|
2015-12-14 21:59:40 +01:00
|
|
|
targets = ['scotch']
|
|
|
|
if '+mpi' in self.spec:
|
|
|
|
targets.append('ptscotch')
|
|
|
|
|
2016-05-19 16:37:53 +02:00
|
|
|
if self.spec.version >= Version('6.0.0'):
|
|
|
|
if '+esmumps' in self.spec:
|
|
|
|
targets.append('esmumps')
|
|
|
|
if '+mpi' in self.spec:
|
|
|
|
targets.append('ptesmumps')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
|
|
|
with working_dir('src'):
|
2016-04-22 14:50:19 -07:00
|
|
|
for target in targets:
|
2016-05-20 00:31:12 +02:00
|
|
|
# It seams that building ptesmumps in parallel fails, for
|
|
|
|
# version prior to 6.0.0 there is no separated targets force
|
|
|
|
# ptesmumps, this library is built by the ptscotch target. This
|
|
|
|
# should explain the test for the can_make_parallel variable
|
2016-05-20 00:42:34 +02:00
|
|
|
can_make_parallel = \
|
|
|
|
not (target == 'ptesmumps' or
|
|
|
|
(self.spec.version < Version('6.0.0') and
|
|
|
|
target == 'ptscotch'))
|
2016-05-19 16:37:53 +02:00
|
|
|
make(target, parallel=can_make_parallel)
|
|
|
|
|
2016-05-22 18:55:29 +02:00
|
|
|
lib_ext = dso_suffix if '+shared' in self.spec else 'a'
|
2016-05-20 00:42:34 +02:00
|
|
|
# It seams easier to remove metis wrappers from the folder that will be
|
|
|
|
# installed than to tweak the Makefiles
|
2016-05-19 16:37:53 +02:00
|
|
|
if '+metis' not in self.spec:
|
|
|
|
with working_dir('lib'):
|
2016-05-22 18:55:29 +02:00
|
|
|
force_remove('libscotchmetis.{0}'.format(lib_ext))
|
|
|
|
force_remove('libptscotchparmetis.{0}'.format(lib_ext))
|
2016-05-19 16:37:53 +02:00
|
|
|
|
|
|
|
with working_dir('include'):
|
|
|
|
force_remove('metis.h')
|
|
|
|
force_remove('parmetis.h')
|
2015-03-12 08:49:45 -07:00
|
|
|
|
2016-05-20 00:31:12 +02:00
|
|
|
if '~esmumps' in self.spec and self.spec.version < Version('6.0.0'):
|
|
|
|
with working_dir('lib'):
|
2016-05-22 18:55:29 +02:00
|
|
|
force_remove('libesmumps.{0}'.format(lib_ext))
|
|
|
|
force_remove('libptesmumps.{0}'.format(lib_ext))
|
2016-05-20 00:31:12 +02:00
|
|
|
|
|
|
|
with working_dir('include'):
|
|
|
|
force_remove('esmumps.h')
|
|
|
|
|
2015-03-12 08:49:45 -07:00
|
|
|
install_tree('bin', prefix.bin)
|
|
|
|
install_tree('lib', prefix.lib)
|
|
|
|
install_tree('include', prefix.include)
|
2017-06-25 00:39:31 -05:00
|
|
|
install_tree('man/man1', prefix.share.man.man1)
|