summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Davydov <davydden@gmail.com>2018-01-03 03:03:27 +0100
committerAdam J. Stewart <ajstewart426@gmail.com>2018-01-02 20:03:27 -0600
commit4b5fe75bc38b9e4f45d077aabb6909daca31a70f (patch)
tree689c0156e352c690e138b6bc46b9805def134d03
parentfd6b9ac3af077bd35a66dfd5aaf0fe48375304ff (diff)
downloadspack-4b5fe75bc38b9e4f45d077aabb6909daca31a70f.tar.gz
spack-4b5fe75bc38b9e4f45d077aabb6909daca31a70f.tar.bz2
spack-4b5fe75bc38b9e4f45d077aabb6909daca31a70f.tar.xz
spack-4b5fe75bc38b9e4f45d077aabb6909daca31a70f.zip
add OctavePackage (#6746)
* add OctavePackage 1. remove import CudaPackage which is not needed anymore 2. mention CudaPackage and OctavePackage in packaging guide 3. adjust OctavePackageTemplate 4. add clue file for Octave build 5. sanity check on self.prefix * use setup_environment
-rw-r--r--lib/spack/docs/packaging_guide.rst7
-rw-r--r--lib/spack/spack/__init__.py4
-rw-r--r--lib/spack/spack/build_systems/octave.py71
-rw-r--r--lib/spack/spack/cmd/create.py12
-rw-r--r--var/spack/repos/builtin/packages/bohrium/package.py1
-rw-r--r--var/spack/repos/builtin/packages/dealii/package.py1
-rw-r--r--var/spack/repos/builtin/packages/octave-optim/package.py15
-rw-r--r--var/spack/repos/builtin/packages/octave-splines/package.py11
-rw-r--r--var/spack/repos/builtin/packages/octave-struct/package.py15
9 files changed, 88 insertions, 49 deletions
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index 09bd2632b3..b46caa82e9 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -2240,6 +2240,10 @@ The classes that are currently provided by Spack are:
| :py:class:`.CMakePackage` | Specialized class for packages |
| | built using CMake |
+-------------------------------+----------------------------------+
+ | :py:class:`.CudaPackage` | A helper class for packages that |
+ | | use CUDA. It is intended to be |
+ | | used in combination with others |
+ +-------------------------------+----------------------------------+
| :py:class:`.QMakePackage` | Specialized class for packages |
| | build using QMake |
+-------------------------------+----------------------------------+
@@ -2252,6 +2256,9 @@ The classes that are currently provided by Spack are:
| :py:class:`.RPackage` | Specialized class for |
| | :py:class:`.R` extensions |
+-------------------------------+----------------------------------+
+ | :py:class:`.OctavePackage` | Specialized class for |
+ | | :py:class:`.Octave` packages |
+ +-------------------------------+----------------------------------+
| :py:class:`.PythonPackage` | Specialized class for |
| | :py:class:`.Python` extensions |
+-------------------------------+----------------------------------+
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index 03eee6daf6..f52dc8c2a7 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -184,9 +184,11 @@ from spack.build_systems.makefile import MakefilePackage
from spack.build_systems.aspell_dict import AspellDictPackage
from spack.build_systems.autotools import AutotoolsPackage
from spack.build_systems.cmake import CMakePackage
+from spack.build_systems.cuda import CudaPackage
from spack.build_systems.qmake import QMakePackage
from spack.build_systems.scons import SConsPackage
from spack.build_systems.waf import WafPackage
+from spack.build_systems.octave import OctavePackage
from spack.build_systems.python import PythonPackage
from spack.build_systems.r import RPackage
from spack.build_systems.perl import PerlPackage
@@ -201,9 +203,11 @@ __all__ += [
'AspellDictPackage',
'AutotoolsPackage',
'CMakePackage',
+ 'CudaPackage',
'QMakePackage',
'SConsPackage',
'WafPackage',
+ 'OctavePackage',
'PythonPackage',
'RPackage',
'PerlPackage',
diff --git a/lib/spack/spack/build_systems/octave.py b/lib/spack/spack/build_systems/octave.py
new file mode 100644
index 0000000000..af4651d1e1
--- /dev/null
+++ b/lib/spack/spack/build_systems/octave.py
@@ -0,0 +1,71 @@
+##############################################################################
+# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
+# 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
+#
+# For details, see https://github.com/spack/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
+#
+# 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
+##############################################################################
+import inspect
+
+from spack.directives import depends_on, extends
+from spack.package import PackageBase, run_after
+
+
+class OctavePackage(PackageBase):
+ """Specialized class for Octave packages. See
+ https://www.gnu.org/software/octave/doc/v4.2.0/Installing-and-Removing-Packages.html
+ for more information.
+
+ This class provides the following phases that can be overridden:
+
+ 1. :py:meth:`~.OctavePackage.install`
+
+ """
+ # Default phases
+ phases = ['install']
+
+ # To be used in UI queries that require to know which
+ # build-system class we are using
+ build_system_class = 'OctavePackage'
+
+ extends('octave')
+ depends_on('octave', type=('build', 'run'))
+
+ def setup_environment(self, spack_env, run_env):
+ """Set up the compile and runtime environments for a package."""
+ # octave does not like those environment variables to be set:
+ spack_env.unset('CC')
+ spack_env.unset('CXX')
+ spack_env.unset('FC')
+
+ def install(self, spec, prefix):
+ """Install the package from the archive file"""
+ inspect.getmodule(self).octave(
+ '--quiet',
+ '--norc',
+ '--built-in-docstrings-file=/dev/null',
+ '--texi-macros-file=/dev/null',
+ '--eval', 'pkg prefix %s; pkg install %s' %
+ (prefix, self.stage.archive_file))
+
+ # Testing
+
+ # Check that self.prefix is there after installation
+ run_after('install')(PackageBase.sanity_check_prefix)
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index 2e67b7648b..897355e807 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -332,21 +332,14 @@ class PerlbuildPackageTemplate(PerlmakePackageTemplate):
class OctavePackageTemplate(PackageTemplate):
"""Provides appropriate overrides for octave packages"""
+ base_class_name = 'OctavePackage'
+
dependencies = """\
extends('octave')
# FIXME: Add additional dependencies if required.
# depends_on('octave-foo', type=('build', 'run'))"""
- body = """\
- def install(self, spec, prefix):
- # FIXME: Add logic to build and install here.
- octave('--quiet', '--norc',
- '--built-in-docstrings-file=/dev/null',
- '--texi-macros-file=/dev/null',
- '--eval', 'pkg prefix {0}; pkg install {1}'.format(
- prefix, self.stage.archive_file))"""
-
def __init__(self, name, *args):
# If the user provided `--name octave-splines`, don't rename it
# octave-octave-splines
@@ -464,6 +457,7 @@ class BuildSystemGuesser:
(r'/Makefile\.PL$', 'perlmake'),
(r'/.*\.pro$', 'qmake'),
(r'/(GNU)?[Mm]akefile$', 'makefile'),
+ (r'/DESCRIPTION$', 'octave'),
]
# Peek inside the compressed file.
diff --git a/var/spack/repos/builtin/packages/bohrium/package.py b/var/spack/repos/builtin/packages/bohrium/package.py
index f54cb8a34d..91551e72c5 100644
--- a/var/spack/repos/builtin/packages/bohrium/package.py
+++ b/var/spack/repos/builtin/packages/bohrium/package.py
@@ -22,7 +22,6 @@
# 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.build_systems.cuda import CudaPackage
from spack import *
from spack.package_test import compare_output
from spack.util.executable import Executable
diff --git a/var/spack/repos/builtin/packages/dealii/package.py b/var/spack/repos/builtin/packages/dealii/package.py
index 593b9511ea..c64552478f 100644
--- a/var/spack/repos/builtin/packages/dealii/package.py
+++ b/var/spack/repos/builtin/packages/dealii/package.py
@@ -23,7 +23,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *
-from spack.build_systems.cuda import CudaPackage
class Dealii(CMakePackage, CudaPackage):
diff --git a/var/spack/repos/builtin/packages/octave-optim/package.py b/var/spack/repos/builtin/packages/octave-optim/package.py
index 2c676f28dc..0091e66496 100644
--- a/var/spack/repos/builtin/packages/octave-optim/package.py
+++ b/var/spack/repos/builtin/packages/octave-optim/package.py
@@ -23,10 +23,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *
-import os
-class OctaveOptim(Package):
+class OctaveOptim(OctavePackage):
"""Non-linear optimization toolkit for Octave."""
homepage = "https://octave.sourceforge.io/optim/"
@@ -35,16 +34,4 @@ class OctaveOptim(Package):
version('1.5.2', 'd3d77982869ea7c1807b13b24e044d44')
depends_on('octave-struct@1.0.12:')
-
extends('octave@3.6.0:')
-
- def install(self, spec, prefix):
- os.environ.pop('CC', '')
- os.environ.pop('CXX', '')
- os.environ.pop('FC', '')
- octave('--quiet',
- '--norc',
- '--built-in-docstrings-file=/dev/null',
- '--texi-macros-file=/dev/null',
- '--eval', 'pkg prefix %s; pkg install %s' %
- (prefix, self.stage.archive_file))
diff --git a/var/spack/repos/builtin/packages/octave-splines/package.py b/var/spack/repos/builtin/packages/octave-splines/package.py
index c9a5f7b01d..79341807c6 100644
--- a/var/spack/repos/builtin/packages/octave-splines/package.py
+++ b/var/spack/repos/builtin/packages/octave-splines/package.py
@@ -25,20 +25,11 @@
from spack import *
-class OctaveSplines(Package):
+class OctaveSplines(OctavePackage):
"""Additional spline functions."""
homepage = "http://octave.sourceforge.net/splines/index.html"
url = "http://downloads.sourceforge.net/octave/splines-1.3.1.tar.gz"
version('1.3.1', 'f9665d780c37aa6a6e17d1f424c49bdeedb89d1192319a4e39c08784122d18f9')
-
extends('octave@3.6.0:')
-
- def install(self, spec, prefix):
- octave('--quiet',
- '--norc',
- '--built-in-docstrings-file=/dev/null',
- '--texi-macros-file=/dev/null',
- '--eval', 'pkg prefix %s; pkg install %s' %
- (prefix, self.stage.archive_file))
diff --git a/var/spack/repos/builtin/packages/octave-struct/package.py b/var/spack/repos/builtin/packages/octave-struct/package.py
index 8a342507aa..0af7f572fd 100644
--- a/var/spack/repos/builtin/packages/octave-struct/package.py
+++ b/var/spack/repos/builtin/packages/octave-struct/package.py
@@ -23,26 +23,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
from spack import *
-import os
-class OctaveStruct(Package):
+class OctaveStruct(OctavePackage):
"""Additional structure manipulation functions for Octave."""
homepage = "https://octave.sourceforge.io/struct/"
url = "https://downloads.sourceforge.net/octave/struct-1.0.14.tar.gz"
version('1.0.14', '3589d5eb8000f18426e2178587eb82f4')
-
extends('octave@2.9.7:')
-
- def install(self, spec, prefix):
- os.environ.pop('CC', '')
- os.environ.pop('CXX', '')
- os.environ.pop('FC', '')
- octave('--quiet',
- '--norc',
- '--built-in-docstrings-file=/dev/null',
- '--texi-macros-file=/dev/null',
- '--eval', 'pkg prefix %s; pkg install %s' %
- (prefix, self.stage.archive_file))