summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-07-11 20:57:55 +0200
committeralalazo <massimiliano.culpo@googlemail.com>2016-07-11 20:57:55 +0200
commit5f861e075c74a6b89d33dab97595e7c1a766ad3e (patch)
tree3fb5e67309ef3e3f62cdb1e37bd46a49604bd18a /lib
parent6d988dde8dcc2d666631151e5dab429811ffed37 (diff)
parent255d05a9c123a6632c0ab496f2bde31a2917fdf4 (diff)
downloadspack-5f861e075c74a6b89d33dab97595e7c1a766ad3e.tar.gz
spack-5f861e075c74a6b89d33dab97595e7c1a766ad3e.tar.bz2
spack-5f861e075c74a6b89d33dab97595e7c1a766ad3e.tar.xz
spack-5f861e075c74a6b89d33dab97595e7c1a766ad3e.zip
Merged develop into branch
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/docs/basic_usage.rst270
-rw-r--r--lib/spack/docs/configuration.rst23
-rw-r--r--lib/spack/docs/packaging_guide.rst296
-rw-r--r--lib/spack/spack/__init__.py4
-rw-r--r--lib/spack/spack/build_environment.py42
-rw-r--r--lib/spack/spack/cmd/create.py2
-rw-r--r--lib/spack/spack/cmd/diy.py2
-rw-r--r--lib/spack/spack/cmd/install.py9
-rw-r--r--lib/spack/spack/cmd/setup.py91
-rw-r--r--lib/spack/spack/concretize.py6
-rw-r--r--lib/spack/spack/fetch_strategy.py3
-rw-r--r--lib/spack/spack/package.py226
-rw-r--r--lib/spack/spack/platforms/linux.py15
-rw-r--r--lib/spack/spack/test/mock_packages_test.py18
-rw-r--r--lib/spack/spack/test/versions.py39
-rw-r--r--lib/spack/spack/version.py27
16 files changed, 891 insertions, 182 deletions
diff --git a/lib/spack/docs/basic_usage.rst b/lib/spack/docs/basic_usage.rst
index d8d5a6a23a..dbad0a9f6d 100644
--- a/lib/spack/docs/basic_usage.rst
+++ b/lib/spack/docs/basic_usage.rst
@@ -114,13 +114,13 @@ that the packages is installed:
$ spack install mpileaks
==> Installing mpileaks
- ==> mpich is already installed in /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/mpich@3.0.4.
- ==> callpath is already installed in /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/callpath@1.0.2-5dce4318.
- ==> adept-utils is already installed in /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/adept-utils@1.0-5adef8da.
+ ==> mpich is already installed in /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/mpich@3.0.4.
+ ==> callpath is already installed in /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/callpath@1.0.2-5dce4318.
+ ==> adept-utils is already installed in /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/adept-utils@1.0-5adef8da.
==> Trying to fetch from https://github.com/hpc/mpileaks/releases/download/v1.0/mpileaks-1.0.tar.gz
######################################################################## 100.0%
- ==> Staging archive: /home/gamblin2/spack/var/spack/stage/mpileaks@1.0%gcc@4.4.7 arch=chaos_5_x86_64_ib-59f6ad23/mpileaks-1.0.tar.gz
- ==> Created stage in /home/gamblin2/spack/var/spack/stage/mpileaks@1.0%gcc@4.4.7 arch=chaos_5_x86_64_ib-59f6ad23.
+ ==> Staging archive: /home/gamblin2/spack/var/spack/stage/mpileaks@1.0%gcc@4.4.7 arch=linux-debian7-x86_64-59f6ad23/mpileaks-1.0.tar.gz
+ ==> Created stage in /home/gamblin2/spack/var/spack/stage/mpileaks@1.0%gcc@4.4.7 arch=linux-debian7-x86_64-59f6ad23.
==> No patches needed for mpileaks.
==> Building mpileaks.
@@ -128,7 +128,7 @@ that the packages is installed:
==> Successfully installed mpileaks.
Fetch: 2.16s. Build: 9.82s. Total: 11.98s.
- [+] /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/mpileaks@1.0-59f6ad23
+ [+] /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/mpileaks@1.0-59f6ad23
The last line, with the ``[+]``, indicates where the package is
installed.
@@ -230,7 +230,7 @@ Running ``spack find`` with no arguments lists installed packages:
$ spack find
==> 74 installed packages.
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
ImageMagick@6.8.9-10 libdwarf@20130729 py-dateutil@2.4.0
adept-utils@1.0 libdwarf@20130729 py-ipython@2.3.1
atk@2.14.0 libelf@0.8.12 py-matplotlib@1.4.2
@@ -256,7 +256,7 @@ Running ``spack find`` with no arguments lists installed packages:
lcms@2.6 pixman@0.32.6 xz@5.2.0
libdrm@2.4.33 py-dateutil@2.4.0 zlib@1.2.8
- -- chaos_5_x86_64_ib / gcc@4.9.2 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.9.2 --------------------------------
libelf@0.8.10 mpich@3.0.4
Packages are divided into groups according to their architecture and
@@ -279,7 +279,7 @@ in more detail using ``spack find -d``, and by asking only to show
$ spack find --deps libdwarf
==> 2 installed packages.
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
libdwarf@20130729-d9b90962
^libelf@0.8.12
libdwarf@20130729-b52fac98
@@ -295,7 +295,7 @@ want to know whether two packages' dependencies differ, you can use
$ spack find -l libdwarf
==> 2 installed packages.
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
libdwarf@20130729-d9b90962 libdwarf@20130729-b52fac98
Now the ``libwarf`` installs have hashes after their names. These are
@@ -309,14 +309,14 @@ use ``spack find -p``:
$ spack find -p
==> 74 installed packages.
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
- ImageMagick@6.8.9-10 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/ImageMagick@6.8.9-10-4df950dd
- adept-utils@1.0 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/adept-utils@1.0-5adef8da
- atk@2.14.0 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/atk@2.14.0-3d09ac09
- boost@1.55.0 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/boost@1.55.0
- bzip2@1.0.6 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/bzip2@1.0.6
- cairo@1.14.0 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/cairo@1.14.0-fcc2ab44
- callpath@1.0.2 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/callpath@1.0.2-5dce4318
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
+ ImageMagick@6.8.9-10 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/ImageMagick@6.8.9-10-4df950dd
+ adept-utils@1.0 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/adept-utils@1.0-5adef8da
+ atk@2.14.0 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/atk@2.14.0-3d09ac09
+ boost@1.55.0 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/boost@1.55.0
+ bzip2@1.0.6 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/bzip2@1.0.6
+ cairo@1.14.0 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/cairo@1.14.0-fcc2ab44
+ callpath@1.0.2 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/callpath@1.0.2-5dce4318
...
And, finally, you can restrict your search to a particular package
@@ -325,10 +325,10 @@ by supplying its name:
.. code-block:: sh
$ spack find -p libelf
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
- libelf@0.8.11 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/libelf@0.8.11
- libelf@0.8.12 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/libelf@0.8.12
- libelf@0.8.13 /home/gamblin2/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/libelf@0.8.13
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
+ libelf@0.8.11 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/libelf@0.8.11
+ libelf@0.8.12 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/libelf@0.8.12
+ libelf@0.8.13 /home/gamblin2/spack/opt/linux-debian7-x86_64/gcc@4.4.7/libelf@0.8.13
``spack find`` actually does a lot more than this. You can use
*specs* to query for specific configurations and builds of each
@@ -338,7 +338,7 @@ package. If you want to find only libelf versions greater than version
.. code-block:: sh
$ spack find libelf@0.8.12:
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
libelf@0.8.12 libelf@0.8.13
Finding just the versions of libdwarf built with a particular version
@@ -348,7 +348,7 @@ of libelf would look like this:
$ spack find -l libdwarf ^libelf@0.8.12
==> 1 installed packages.
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
libdwarf@20130729-d9b90962
We can also search for packages that have a certain attribute. For example,
@@ -359,6 +359,7 @@ will find every installed package with a 'debug' compile-time option enabled.
The full spec syntax is discussed in detail in :ref:`sec-specs`.
+.. _compiler-config:
Compiler configuration
-----------------------------------
@@ -445,7 +446,7 @@ If you want to see specifics on a particular compiler, you can run
fc = /usr/local/bin/ifort-15.0.090
This shows which C, C++, and Fortran compilers were detected by Spack.
-Notice also that we didn't have to be too specific about the
+Notice also that we didn\'t have to be too specific about the
version. We just said ``intel@15``, and information about the only
matching Intel compiler was displayed.
@@ -460,19 +461,17 @@ editing your ``~/.spack/compilers.yaml`` file. You can do this by running
Each compiler configuration in the file looks like this::
...
- chaos_5_x86_64_ib:
- ...
- intel@15.0.0:
+ compilers:
+ - compiler:
+ modules = []
+ operating_system: OS
+ paths:
cc: /usr/local/bin/icc-15.0.024-beta
cxx: /usr/local/bin/icpc-15.0.024-beta
f77: /usr/local/bin/ifort-15.0.024-beta
fc: /usr/local/bin/ifort-15.0.024-beta
- ...
-The chaos_5_x86_64_ib string is an architecture string, and multiple
-compilers can be listed underneath an architecture. The architecture
-string may be replaced with the string 'all' to signify compilers that
-work on all architectures.
+ spec: intel@15.0.0:
For compilers, like ``clang``, that do not support Fortran, put
``None`` for ``f77`` and ``fc``::
@@ -488,10 +487,11 @@ list displayed by ``spack compilers``.
You can also add compiler flags to manually configured compilers. The
valid flags are ``cflags``, ``cxxflags``, ``fflags``, ``cppflags``,
-``ldflags``, and ``ldlibs``. For example,::
+``ldflags``, and ``ldlibs``. For example::
...
- chaos_5_x86_64_ib:
+ compilers:
+ - compiler:
...
intel@15.0.0:
cc: /usr/local/bin/icc-15.0.024-beta
@@ -518,10 +518,10 @@ Spack, that descriptor is called a *spec*. Spack uses specs to refer
to a particular build configuration (or configurations) of a package.
Specs are more than a package name and a version; you can use them to
specify the compiler, compiler version, architecture, compile options,
-and dependency options for a build. In this section, we'll go over
+and dependency options for a build. In this section, we\'ll go over
the full syntax of specs.
-Here is an example of a much longer spec than we've seen thus far::
+Here is an example of a much longer spec than we\'ve seen thus far::
mpileaks @1.2:1.4 %gcc@4.7.5 +debug -qt arch=bgq_os ^callpath @1.1 %gcc@4.7.2
@@ -546,8 +546,8 @@ More formally, a spec consists of the following pieces:
boolean variants
* ``name=<value>`` Optional compiler flag specifiers. Valid flag names are
``cflags``, ``cxxflags``, ``fflags``, ``cppflags``, ``ldflags``, and ``ldlibs``.
-* ``arch=<value>`` Optional architecture specifier (``arch=bgq_os``)
-* ``^`` Dependency specs (``^callpath@1.1``)
+* ``target=<value> os=<value>`` Optional architecture specifier
+(``target=haswell os=CNL10``) * ``^`` Dependency specs (``^callpath@1.1``)
There are two things to notice here. The first is that specs are
recursively defined. That is, each dependency after ``^`` is a spec
@@ -626,7 +626,7 @@ compilers, variants, and architectures just like any other spec.
Specifiers are associated with the nearest package name to their left.
For example, above, ``@1.1`` and ``%gcc@4.7.2`` associates with the
``callpath`` package, while ``@1.2:1.4``, ``%gcc@4.7.5``, ``+debug``,
-``-qt``, and ``arch=bgq_os`` all associate with the ``mpileaks`` package.
+``-qt``, and ``target=haswell os=CNL10`` all associate with the ``mpileaks`` package.
In the diagram above, ``mpileaks`` depends on ``mpich`` with an
unspecified version, but packages can depend on other packages with
@@ -758,14 +758,18 @@ in gnu autotools. If all flags are set, the order is
Architecture specifiers
~~~~~~~~~~~~~~~~~~~~~~~
-.. Note::
+The architecture can be specified by using the reserved
+words ``target`` and/or ``os`` (``target=x86-64 os=debian7``). You can also
+use the triplet form of platform, operating system and processor.
- Architecture specifiers are part of specs but are not yet
- functional. They will be in Spack version 1.0, due in Q3 2015.
+.. code-block:: sh
+
+ spack install libelf arch=cray_xc-CNL10-haswell
-The architecture specifier looks identical to a variant specifier for a
-non-boolean variant. The architecture can be specified only using the
-reserved name ``arch`` (``arch=bgq_os``).
+Users on non-Cray systems won't have to worry about specifying the architecture.
+Spack will autodetect what kind of operating system is on your machine as well
+as the processor. For more information on how the architecture can be
+used on Cray machines, check here :ref:`spack-cray`
.. _sec-virtual-dependencies:
@@ -985,7 +989,7 @@ of installed packages.
$ module avail
- ------- /home/gamblin2/spack/share/spack/modules/chaos_5_x86_64_ib --------
+ ------- /home/gamblin2/spack/share/spack/modules/linux-debian7-x86_64 --------
adept-utils@1.0%gcc@4.4.7-5adef8da libelf@0.8.13%gcc@4.4.7
automaded@1.0%gcc@4.4.7-d9691bb0 libelf@0.8.13%intel@15.0.0
boost@1.55.0%gcc@4.4.7 mpc@1.0.2%gcc@4.4.7-559607f5
@@ -1056,7 +1060,7 @@ Spack. For example, this will add the ``mpich`` package built with
$ spack use mpich %gcc@4.4.7
Prepending: mpich@3.0.4%gcc@4.4.7 (ok)
$ which mpicc
- ~/src/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/mpich@3.0.4/bin/mpicc
+ ~/src/spack/opt/linux-debian7-x86_64/gcc@4.4.7/mpich@3.0.4/bin/mpicc
Or, similarly with modules, you could type:
@@ -1089,8 +1093,8 @@ than one installed package matches it), then Spack will warn you:
$ spack load libelf
==> Error: Multiple matches for spec libelf. Choose one:
- libelf@0.8.13%gcc@4.4.7 arch=chaos_5_x86_64_ib
- libelf@0.8.13%intel@15.0.0 arch=chaos_5_x86_64_ib
+ libelf@0.8.13%gcc@4.4.7 arch=linux-debian7-x86_64
+ libelf@0.8.13%intel@15.0.0 arch=linux-debian7-x86_64
You can either type the ``spack load`` command again with a fully
qualified argument, or you can add just enough extra constraints to
@@ -1150,7 +1154,7 @@ Modules may be loaded recursively with the command:
More than one spec may be placed on the command line here.
-Module Comamnds for Shell Scripts
+Module Commands for Shell Scripts
``````````````````````````````````
Although Spack is flexbile, the ``module`` command is much faster.
@@ -1543,7 +1547,7 @@ an *extension*. Suppose you have Python installed like so:
$ spack find python
==> 1 installed packages.
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
python@2.7.8
.. _spack-extensions:
@@ -1556,7 +1560,7 @@ You can find extensions for your Python installation like this:
.. code-block:: sh
$ spack extensions python
- ==> python@2.7.8%gcc@4.4.7 arch=chaos_5_x86_64_ib-703c7a96
+ ==> python@2.7.8%gcc@4.4.7 arch=linux-debian7-x86_64-703c7a96
==> 36 extensions:
geos py-ipython py-pexpect py-pyside py-sip
py-basemap py-libxml2 py-pil py-pytz py-six
@@ -1568,7 +1572,7 @@ You can find extensions for your Python installation like this:
py-h5py py-numpy py-pyqt py-shiboken
==> 12 installed:
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
py-dateutil@2.4.0 py-nose@1.3.4 py-pyside@1.2.2
py-dateutil@2.4.0 py-numpy@1.9.1 py-pytz@2014.10
py-ipython@2.3.1 py-pygments@2.0.1 py-setuptools@11.3.1
@@ -1584,8 +1588,8 @@ prefixes, and you can see this with ``spack find -p``:
$ spack find -p py-numpy
==> 1 installed packages.
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
- py-numpy@1.9.1 /g/g21/gamblin2/src/spack/opt/chaos_5_x86_64_ib/gcc@4.4.7/py-numpy@1.9.1-66733244
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
+ py-numpy@1.9.1 /g/g21/gamblin2/src/spack/opt/linux-debian7-x86_64/gcc@4.4.7/py-numpy@1.9.1-66733244
However, even though this package is installed, you cannot use it
directly when you run ``python``:
@@ -1646,9 +1650,9 @@ installation:
.. code-block:: sh
$ spack activate py-numpy
- ==> Activated extension py-setuptools@11.3.1%gcc@4.4.7 arch=chaos_5_x86_64_ib-3c74eb69 for python@2.7.8%gcc@4.4.7.
- ==> Activated extension py-nose@1.3.4%gcc@4.4.7 arch=chaos_5_x86_64_ib-5f70f816 for python@2.7.8%gcc@4.4.7.
- ==> Activated extension py-numpy@1.9.1%gcc@4.4.7 arch=chaos_5_x86_64_ib-66733244 for python@2.7.8%gcc@4.4.7.
+ ==> Activated extension py-setuptools@11.3.1%gcc@4.4.7 arch=linux-debian7-x86_64-3c74eb69 for python@2.7.8%gcc@4.4.7.
+ ==> Activated extension py-nose@1.3.4%gcc@4.4.7 arch=linux-debian7-x86_64-5f70f816 for python@2.7.8%gcc@4.4.7.
+ ==> Activated extension py-numpy@1.9.1%gcc@4.4.7 arch=linux-debian7-x86_64-66733244 for python@2.7.8%gcc@4.4.7.
Several things have happened here. The user requested that
``py-numpy`` be activated in the ``python`` installation it was built
@@ -1663,7 +1667,7 @@ packages listed as activated:
.. code-block:: sh
$ spack extensions python
- ==> python@2.7.8%gcc@4.4.7 arch=chaos_5_x86_64_ib-703c7a96
+ ==> python@2.7.8%gcc@4.4.7 arch=linux-debian7-x86_64-703c7a96
==> 36 extensions:
geos py-ipython py-pexpect py-pyside py-sip
py-basemap py-libxml2 py-pil py-pytz py-six
@@ -1675,14 +1679,14 @@ packages listed as activated:
py-h5py py-numpy py-pyqt py-shiboken
==> 12 installed:
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
py-dateutil@2.4.0 py-nose@1.3.4 py-pyside@1.2.2
py-dateutil@2.4.0 py-numpy@1.9.1 py-pytz@2014.10
py-ipython@2.3.1 py-pygments@2.0.1 py-setuptools@11.3.1
py-matplotlib@1.4.2 py-pyparsing@2.0.3 py-six@1.9.0
==> 3 currently activated:
- -- chaos_5_x86_64_ib / gcc@4.4.7 --------------------------------
+ -- linux-debian7-x86_64 / gcc@4.4.7 --------------------------------
py-nose@1.3.4 py-numpy@1.9.1 py-setuptools@11.3.1
@@ -1711,7 +1715,7 @@ dependencies, you can use ``spack activate -f``:
.. code-block:: sh
$ spack activate -f py-numpy
- ==> Activated extension py-numpy@1.9.1%gcc@4.4.7 arch=chaos_5_x86_64_ib-66733244 for python@2.7.8%gcc@4.4.7.
+ ==> Activated extension py-numpy@1.9.1%gcc@4.4.7 arch=linux-debian7-x86_64-66733244 for python@2.7.8%gcc@4.4.7.
.. _spack-deactivate:
@@ -1743,7 +1747,7 @@ Spack currently needs to be run from a filesystem that supports
``flock`` locking semantics. Nearly all local filesystems and recent
versions of NFS support this, but parallel filesystems may be mounted
without ``flock`` support enabled. You can determine how your
-filesystems are mounted with ``mount -p``. The output for a Lustre
+ filesystems are mounted with ``mount -p``. The output for a Lustre
filesystem might look like this:
.. code-block:: sh
@@ -1764,7 +1768,7 @@ This issue typically manifests with the error below:
Traceback (most recent call last):
File "./spack", line 176, in <module>
main()
- File "./spack", line 154, in main
+ File "./spack", line 154,' in main
return_val = command(parser, args)
File "./spack/lib/spack/spack/cmd/find.py", line 170, in find
specs = set(spack.installed_db.query(**q_args))
@@ -1782,6 +1786,142 @@ This issue typically manifests with the error below:
A nicer error message is TBD in future versions of Spack.
+
+.. _spack-cray:
+
+Spack on Cray
+-----------------------------
+
+Spack differs slightly when used on a Cray system. The architecture spec
+can differentiate between the front-end and back-end processor and operating system.
+For example, on Edison at NERSC, the back-end target processor
+is \"Ivy Bridge\", so you can specify to use the back-end this way:
+
+.. code-block:: sh
+
+ spack install zlib target=ivybridge
+
+You can also use the operating system to build against the back-end:
+
+.. code-block:: sh
+
+ spack install zlib os=CNL10
+
+Notice that the name includes both the operating system name and the major
+version number concatenated together.
+
+Alternatively, if you want to build something for the front-end,
+you can specify the front-end target processor. The processor for a login node
+on Edison is \"Sandy bridge\" so we specify on the command line like so:
+
+.. code-block:: sh
+
+ spack install zlib target=sandybridge
+
+And the front-end operating system is:
+
+.. code-block:: sh
+
+ spack install zlib os=SuSE11
+
+
+
+Cray compiler detection
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Spack can detect compilers using two methods. For the front-end, we treat
+everything the same. The difference lies in back-end compiler detection.
+Back-end compiler detection is made via the Tcl module avail command.
+Once it detects the compiler it writes the appropriate PrgEnv and compiler
+module name to compilers.yaml and sets the paths to each compiler with Cray\'s
+compiler wrapper names (i.e. cc, CC, ftn). During build time, Spack will load
+the correct PrgEnv and compiler module and will call appropriate wrapper.
+
+The compilers.yaml config file will also differ. There is a
+modules section that is filled with the compiler\'s Programming Environment
+and module name. On other systems, this field is empty []::
+
+ ...
+ - compiler:
+ modules:
+ - PrgEnv-intel
+ - intel/15.0.109
+ ...
+
+As mentioned earlier, the compiler paths will look different on a Cray system.
+Since most compilers are invoked using cc, CC and ftn, the paths for each
+compiler are replaced with their respective Cray compiler wrapper names::
+
+ ...
+ paths:
+ cc: cc
+ cxx: CC
+ f77: ftn
+ fc: ftn
+ ...
+
+As opposed to an explicit path to the compiler executable. This allows Spack
+to call the Cray compiler wrappers during build time.
+
+For more on compiler configuration, check out :ref:`compiler-config`.
+
+Setting defaults and using Cray modules
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you want to use default compilers for each PrgEnv and also be able
+to load cray external modules, you will need to set up a packages.yaml.
+
+Here\'s an example of an external configuration for cray modules:
+
+.. code-block:: yaml
+
+ packages:
+ mpi:
+ modules:
+ mpich@7.3.1%gcc@5.2.0 arch=cray_xc-haswell-CNL10: cray-mpich
+ mpich@7.3.1%intel@16.0.0.109 arch=cray_xc-haswell-CNL10: cray-mpich
+
+This tells Spack that for whatever package that depends on mpi, load the
+cray-mpich module into the environment. You can then be able to use whatever
+environment variables, libraries, etc, that are brought into the environment
+via module load.
+
+You can set the default compiler that Spack can use for each compiler type.
+If you want to use the Cray defaults, then set them under *all:* in packages.yaml.
+In the compiler field, set the compiler specs in your order of preference.
+Whenever you build with that compiler type, Spack will concretize to that version.
+
+Here is an example of a full packages.yaml used at NERSC
+
+.. code-block:: yaml
+
+ packages:
+ mpi:
+ modules:
+ mpich@7.3.1%gcc@5.2.0 arch=cray_xc-CNL10-ivybridge: cray-mpich
+ mpich@7.3.1%intel@16.0.0.109 arch=cray_xc-SuSE11-ivybridge: cray-mpich
+ buildable: False
+ netcdf:
+ modules:
+ netcdf@4.3.3.1%gcc@5.2.0 arch=cray_xc-CNL10-ivybridge: cray-netcdf
+ netcdf@4.3.3.1%intel@16.0.0.109 arch=cray_xc-CNL10-ivybridge: cray-netcdf
+ buildable: False
+ hdf5:
+ modules:
+ hdf5@1.8.14%gcc@5.2.0 arch=cray_xc-CNL10-ivybridge: cray-hdf5
+ hdf5@1.8.14%intel@16.0.0.109 arch=cray_xc-CNL10-ivybridge: cray-hdf5
+ buildable: False
+ all:
+ compiler: [gcc@5.2.0, intel@16.0.0.109]
+
+Here we tell spack that whenever we want to build with gcc use version 5.2.0 or
+if we want to build with intel compilers, use version 16.0.0.109. We add a spec
+for each compiler type for each cray modules. This ensures that for each
+compiler on our system we can use that external module.
+
+
+For more on external packages check out the section :ref:`sec-external_packages`.
+
Getting Help
-----------------------
diff --git a/lib/spack/docs/configuration.rst b/lib/spack/docs/configuration.rst
index a6f876b2aa..f2ffa07264 100644
--- a/lib/spack/docs/configuration.rst
+++ b/lib/spack/docs/configuration.rst
@@ -53,6 +53,7 @@ in the first directory it finds to which it has write access. Add
more elements to the list to indicate where your own site's temporary
directory is.
+.. _sec-external_packages:
External Packages
----------------------------
@@ -70,20 +71,20 @@ directory. Here's an example of an external configuration:
packages:
openmpi:
paths:
- openmpi@1.4.3%gcc@4.4.7 arch=chaos_5_x86_64_ib: /opt/openmpi-1.4.3
- openmpi@1.4.3%gcc@4.4.7 arch=chaos_5_x86_64_ib+debug: /opt/openmpi-1.4.3-debug
- openmpi@1.6.5%intel@10.1 arch=chaos_5_x86_64_ib: /opt/openmpi-1.6.5-intel
+ openmpi@1.4.3%gcc@4.4.7 arch=linux-x86_64-debian7: /opt/openmpi-1.4.3
+ openmpi@1.4.3%gcc@4.4.7 arch=linux-x86_64-debian7+debug: /opt/openmpi-1.4.3-debug
+ openmpi@1.6.5%intel@10.1 arch=linux-x86_64-debian7: /opt/openmpi-1.6.5-intel
This example lists three installations of OpenMPI, one built with gcc,
one built with gcc and debug information, and another built with Intel.
If Spack is asked to build a package that uses one of these MPIs as a
dependency, it will use the the pre-installed OpenMPI in
-the given directory.
+the given directory. Packages.yaml can also be used to specify modules
Each ``packages.yaml`` begins with a ``packages:`` token, followed
-by a list of package names. To specify externals, add a ``paths``
+by a list of package names. To specify externals, add a ``paths`` or ``modules``
token under the package name, which lists externals in a
-``spec : /path`` format. Each spec should be as
+``spec: /path`` or ``spec: module-name`` format. Each spec should be as
well-defined as reasonably possible. If a
package lacks a spec component, such as missing a compiler or
package version, then Spack will guess the missing component based
@@ -108,9 +109,9 @@ be:
packages:
openmpi:
paths:
- openmpi@1.4.3%gcc@4.4.7 arch=chaos_5_x86_64_ib: /opt/openmpi-1.4.3
- openmpi@1.4.3%gcc@4.4.7 arch=chaos_5_x86_64_ib+debug: /opt/openmpi-1.4.3-debug
- openmpi@1.6.5%intel@10.1 arch=chaos_5_x86_64_ib: /opt/openmpi-1.6.5-intel
+ openmpi@1.4.3%gcc@4.4.7 arch=linux-x86_64-debian7: /opt/openmpi-1.4.3
+ openmpi@1.4.3%gcc@4.4.7 arch=linux-x86_64-debian7+debug: /opt/openmpi-1.4.3-debug
+ openmpi@1.6.5%intel@10.1 arch=linux-x86_64-debian7: /opt/openmpi-1.6.5-intel
buildable: False
The addition of the ``buildable`` flag tells Spack that it should never build
@@ -118,6 +119,9 @@ its own version of OpenMPI, and it will instead always rely on a pre-built
OpenMPI. Similar to ``paths``, ``buildable`` is specified as a property under
a package name.
+If an external module is specified as not buildable, then Spack will load the
+external module into the build environment which can be used for linking.
+
The ``buildable`` does not need to be paired with external packages.
It could also be used alone to forbid packages that may be
buggy or otherwise undesirable.
@@ -181,7 +185,6 @@ concretization rules. A provider lists a value that packages may
dependency.
-
Profiling
------------------
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index 82f12cedda..e616581ca4 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -36,10 +36,11 @@ Creating & editing packages
``spack create``
~~~~~~~~~~~~~~~~~~~~~
-The ``spack create`` command generates a boilerplate package template
-from a URL. The URL should point to a tarball or other software
-archive. In most cases, ``spack create`` plus a few modifications is
-all you need to get a package working.
+The ``spack create`` command creates a directory with the package name and
+generates a ``package.py`` file with a boilerplate package template from a URL.
+The URL should point to a tarball or other software archive. In most cases,
+``spack create`` plus a few modifications is all you need to get a package
+working.
Here's an example:
@@ -47,12 +48,16 @@ Here's an example:
$ spack create http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
-Spack examines the tarball URL and tries to figure out the name of the
-package to be created. It also tries to determine what version strings
-look like for this package. Using this information, it will try to
-find *additional* versions by spidering the package's webpage. If it
-finds multiple versions, Spack prompts you to tell it how many
-versions you want to download and checksum:
+Spack examines the tarball URL and tries to figure out the name of the package
+to be created. Once the name is determined a directory in the appropriate
+repository is created with that name. Spack prefers, but does not require, that
+names be lower case so the directory name will be lower case when ``spack
+create`` generates it. In cases where it is desired to have mixed case or upper
+case simply rename the directory. Spack also tries to determine what version
+strings look like for this package. Using this information, it will try to find
+*additional* versions by spidering the package's webpage. If it finds multiple
+versions, Spack prompts you to tell it how many versions you want to download
+and checksum:
.. code-block:: sh
@@ -297,9 +302,10 @@ directories or files (like patches) that it needs to build.
Package Names
~~~~~~~~~~~~~~~~~~
-Packages are named after the directory containing ``package.py``. So,
-``libelf``'s ``package.py`` lives in a directory called ``libelf``.
-The ``package.py`` file defines a class called ``Libelf``, which
+Packages are named after the directory containing ``package.py``. It is
+preferred, but not required, that the directory, and thus the package name, are
+lower case. So, ``libelf``'s ``package.py`` lives in a directory called
+``libelf``. The ``package.py`` file defines a class called ``Libelf``, which
extends Spack's ``Package`` class. for example, here is
``$SPACK_ROOT/var/spack/repos/builtin/packages/libelf/package.py``:
@@ -377,6 +383,8 @@ add a line like this in the package class:
version('8.2.1', '4136d7b4c04df68b686570afa26988ac')
...
+Versions should be listed with the newest version first.
+
Version URLs
~~~~~~~~~~~~~~~~~
@@ -385,8 +393,21 @@ in the package. For example, Spack is smart enough to download
version ``8.2.1.`` of the ``Foo`` package above from
``http://example.com/foo-8.2.1.tar.gz``.
-If spack *cannot* extrapolate the URL from the ``url`` field, or if
-the package doesn't have a ``url`` field, you can add a URL explicitly
+If spack *cannot* extrapolate the URL from the ``url`` field by
+default, you can write your own URL generation algorithm in place of
+the ``url`` declaration. For example:
+
+.. code-block:: python
+ :linenos:
+
+ class Foo(Package):
+ def url_for_version(self, version):
+ return 'http://example.com/version_%s/foo-%s.tar.gz' \
+ % (version, version)
+ version('8.2.1', '4136d7b4c04df68b686570afa26988ac')
+ ...
+
+If a URL cannot be derived systematically, you can add an explicit URL
for a particular version:
.. code-block:: python
@@ -547,7 +568,7 @@ The package author is responsible for coming up with a sensible name
for each version to be fetched from a repository. For example, if
you're fetching from a tag like ``v1.0``, you might call that ``1.0``.
If you're fetching a nameless git commit or an older subversion
-revision, you might give the commit an intuitive name, like ``dev``
+revision, you might give the commit an intuitive name, like ``develop``
for a development version, or ``some-fancy-new-feature`` if you want
to be more specific.
@@ -557,6 +578,17 @@ branches move forward over time and you aren't guaranteed to get the
same thing every time you fetch a particular version. Life isn't
always simple, though, so this is not strictly enforced.
+When fetching from from the branch corresponding to the development version
+(often called ``master``,``trunk`` or ``dev``), it is recommended to
+call this version ``develop``. Spack has special treatment for this version so
+ that ``@develop`` will satisfy dependencies like
+``depends_on(abc, when="@x.y.z:")``. In other words, ``@develop`` is
+greater than any other version. The rationale is that certain features or
+options first appear in the development branch. Therefore if a package author
+wants to keep the package on the bleeding edge and provide support for new
+features, it is advised to use ``develop`` for such a version which will
+greatly simplify writing dependencies and version-related conditionals.
+
In some future release, Spack may support extrapolating repository
versions as it does for tarball URLs, but currently this is not
supported.
@@ -582,7 +614,7 @@ Default branch
class Example(Package):
...
- version('dev', git='https://github.com/example-project/example.git')
+ version('develop', git='https://github.com/example-project/example.git')
This is not recommended, as the contents of the default branch
change over time.
@@ -655,7 +687,7 @@ Default
.. code-block:: python
- version('hg-head', hg='https://jay.grs.rwth-aachen.de/hg/example')
+ version('develop', hg='https://jay.grs.rwth-aachen.de/hg/example')
Note that this is not recommended; try to fetch a particular
revision instead.
@@ -687,7 +719,7 @@ Fetching the head
.. code-block:: python
- version('svn-head', svn='https://outreach.scidac.gov/svn/libmonitor/trunk')
+ version('develop', svn='https://outreach.scidac.gov/svn/libmonitor/trunk')
This is not recommended, as the head will move forward over time.
@@ -697,7 +729,7 @@ Fetching a revision
.. code-block:: python
- version('svn-head', svn='https://outreach.scidac.gov/svn/libmonitor/trunk',
+ version('develop', svn='https://outreach.scidac.gov/svn/libmonitor/trunk',
revision=128)
Subversion branches are handled as part of the directory structure, so
@@ -1346,6 +1378,19 @@ Now, the ``py-numpy`` package can be used as an argument to ``spack
activate``. When it is activated, all the files in its prefix will be
symbolically linked into the prefix of the python package.
+Many packages produce Python extensions for *some* variants, but not
+others: they should extend ``python`` only if the apropriate
+variant(s) are selected. This may be accomplished with conditional
+``extends()`` declarations:
+
+.. code-block:: python
+
+ class FooLib(Package):
+ variant('python', default=True, description= \
+ 'Build the Python extension Module')
+ extends('python', when='+python')
+ ...
+
Sometimes, certain files in one package will conflict with those in
another, which means they cannot both be activated (symlinked) at the
same time. In this case, you can tell Spack to ignore those files
@@ -1632,21 +1677,21 @@ the user runs ``spack install`` and the time the ``install()`` method
is called. The concretized version of the spec above might look like
this::
- mpileaks@2.3%gcc@4.7.3 arch=linux-ppc64
- ^callpath@1.0%gcc@4.7.3+debug arch=linux-ppc64
- ^dyninst@8.1.2%gcc@4.7.3 arch=linux-ppc64
- ^libdwarf@20130729%gcc@4.7.3 arch=linux-ppc64
- ^libelf@0.8.11%gcc@4.7.3 arch=linux-ppc64
- ^mpich@3.0.4%gcc@4.7.3 arch=linux-ppc64
+ mpileaks@2.3%gcc@4.7.3 arch=linux-debian7-x86_64
+ ^callpath@1.0%gcc@4.7.3+debug arch=linux-debian7-x86_64
+ ^dyninst@8.1.2%gcc@4.7.3 arch=linux-debian7-x86_64
+ ^libdwarf@20130729%gcc@4.7.3 arch=linux-debian7-x86_64
+ ^libelf@0.8.11%gcc@4.7.3 arch=linux-debian7-x86_64
+ ^mpich@3.0.4%gcc@4.7.3 arch=linux-debian7-x86_64
.. graphviz::
digraph {
- "mpileaks@2.3\n%gcc@4.7.3\n arch=linux-ppc64" -> "mpich@3.0.4\n%gcc@4.7.3\n arch=linux-ppc64"
- "mpileaks@2.3\n%gcc@4.7.3\n arch=linux-ppc64" -> "callpath@1.0\n%gcc@4.7.3+debug\n arch=linux-ppc64" -> "mpich@3.0.4\n%gcc@4.7.3\n arch=linux-ppc64"
- "callpath@1.0\n%gcc@4.7.3+debug\n arch=linux-ppc64" -> "dyninst@8.1.2\n%gcc@4.7.3\n arch=linux-ppc64"
- "dyninst@8.1.2\n%gcc@4.7.3\n arch=linux-ppc64" -> "libdwarf@20130729\n%gcc@4.7.3\n arch=linux-ppc64" -> "libelf@0.8.11\n%gcc@4.7.3\n arch=linux-ppc64"
- "dyninst@8.1.2\n%gcc@4.7.3\n arch=linux-ppc64" -> "libelf@0.8.11\n%gcc@4.7.3\n arch=linux-ppc64"
+ "mpileaks@2.3\n%gcc@4.7.3\n arch=linux-debian7-x86_64" -> "mpich@3.0.4\n%gcc@4.7.3\n arch=linux-debian7-x86_64"
+ "mpileaks@2.3\n%gcc@4.7.3\n arch=linux-debian7-x86_64" -> "callpath@1.0\n%gcc@4.7.3+debug\n arch=linux-debian7-x86_64" -> "mpich@3.0.4\n%gcc@4.7.3\n arch=linux-debian7-x86_64"
+ "callpath@1.0\n%gcc@4.7.3+debug\n arch=linux-debian7-x86_64" -> "dyninst@8.1.2\n%gcc@4.7.3\n arch=linux-debian7-x86_64"
+ "dyninst@8.1.2\n%gcc@4.7.3\n arch=linux-debian7-x86_64" -> "libdwarf@20130729\n%gcc@4.7.3\n arch=linux-debian7-x86_64" -> "libelf@0.8.11\n%gcc@4.7.3\n arch=linux-debian7-x86_64"
+ "dyninst@8.1.2\n%gcc@4.7.3\n arch=linux-debian7-x86_64" -> "libelf@0.8.11\n%gcc@4.7.3\n arch=linux-debian7-x86_64"
}
Here, all versions, compilers, and platforms are filled in, and there
@@ -1675,9 +1720,9 @@ running ``spack spec``. For example:
^libdwarf
^libelf
- dyninst@8.0.1%gcc@4.7.3 arch=linux-ppc64
- ^libdwarf@20130729%gcc@4.7.3 arch=linux-ppc64
- ^libelf@0.8.13%gcc@4.7.3 arch=linux-ppc64
+ dyninst@8.0.1%gcc@4.7.3 arch=linux-debian7-x86_64
+ ^libdwarf@20130729%gcc@4.7.3 arch=linux-debian7-x86_64
+ ^libelf@0.8.13%gcc@4.7.3 arch=linux-debian7-x86_64
This is useful when you want to know exactly what Spack will do when
you ask for a particular spec.
@@ -1851,7 +1896,7 @@ discover its dependencies.
If you want to see the environment that a package will build with, or
if you want to run commands in that environment to test them out, you
-can use the :ref:```spack env`` <spack-env>` command, documented
+can use the :ref:`spack env <spack-env>` command, documented
below.
.. _compiler-wrappers:
@@ -2182,12 +2227,12 @@ example:
def install(self, prefix):
# Do default install
- @when('arch=chaos_5_x86_64_ib')
+ @when('arch=linux-debian7-x86_64')
def install(self, prefix):
# This will be executed instead of the default install if
# the package's sys_type() is chaos_5_x86_64_ib.
- @when('arch=bgqos_0")
+ @when('arch=linux-debian7-x86_64")
def install(self, prefix):
# This will be executed if the package's sys_type is bgqos_0
@@ -2315,7 +2360,7 @@ build system.
.. _sanity-checks:
-Sanity checking an intallation
+Sanity checking an installation
--------------------------------
By default, Spack assumes that a build has failed if nothing is
@@ -2531,6 +2576,59 @@ File functions
.. _package-lifecycle:
+Coding Style Guidelines
+---------------------------
+
+The following guidelines are provided, in the interests of making
+Spack packages work in a consistent manner:
+
+
+Variant Names
+~~~~~~~~~~~~~~
+
+Spack packages with variants similar to already-existing Spack
+packages should use the same name for their variants. Standard
+variant names are:
+
+======= ======== ========================
+Name Default Description
+------- -------- ------------------------
+shared True Build shared libraries
+static Build static libraries
+mpi Use MPI
+python Build Python extension
+------- -------- ------------------------
+
+If specified in this table, the corresponding default should be used
+when declaring a variant.
+
+
+Version Lists
+~~~~~~~~~~~~~~
+
+Spack packges should list supported versions with the newest first.
+
+Special Versions
+~~~~~~~~~~~~~~~~~
+
+The following *special* version names may be used when building a package:
+
+* *@system*: Indicates a hook to the OS-installed version of the
+ package. This is useful, for example, to tell Spack to use the
+ OS-installed version in ``packages.yaml``::
+
+ openssl:
+ paths:
+ openssl@system: /usr
+ buildable: False
+
+ Certain Spack internals look for the *@system* version and do
+ appropriate things in that case.
+
+* *@local*: Indicates the version was built manually from some source
+ tree of unknown provenance (see ``spack setup``).
+
+
Packaging workflow commands
---------------------------------
@@ -2625,15 +2723,15 @@ build process will start from scratch.
``spack purge``
~~~~~~~~~~~~~~~~~
-Cleans up all of Spack's temporary and cached files. This can be used to
-recover disk space if temporary files from interrupted or failed installs
-accumulate in the staging area.
+Cleans up all of Spack's temporary and cached files. This can be used to
+recover disk space if temporary files from interrupted or failed installs
+accumulate in the staging area.
When called with ``--stage`` or ``--all`` (or without arguments, in which case
-the default is ``--all``) this removes all staged files; this is equivalent to
+the default is ``--all``) this removes all staged files; this is equivalent to
running ``spack clean`` for every package you have fetched or staged.
-When called with ``--cache`` or ``--all`` this will clear all resources
+When called with ``--cache`` or ``--all`` this will clear all resources
:ref:`cached <caching>` during installs.
Keeping the stage directory on success
@@ -2782,11 +2880,11 @@ build it:
$ spack stage libelf
==> Trying to fetch from http://www.mr511.de/software/libelf-0.8.13.tar.gz
######################################################################## 100.0%
- ==> Staging archive: /Users/gamblin2/src/spack/var/spack/stage/libelf@0.8.13%gcc@4.8.3 arch=linux-ppc64/libelf-0.8.13.tar.gz
- ==> Created stage in /Users/gamblin2/src/spack/var/spack/stage/libelf@0.8.13%gcc@4.8.3 arch=linux-ppc64.
+ ==> Staging archive: /Users/gamblin2/src/spack/var/spack/stage/libelf@0.8.13%gcc@4.8.3 arch=linux-debian7-x86_64/libelf-0.8.13.tar.gz
+ ==> Created stage in /Users/gamblin2/src/spack/var/spack/stage/libelf@0.8.13%gcc@4.8.3 arch=linux-debian7-x86_64.
$ spack cd libelf
$ pwd
- /Users/gamblin2/src/spack/var/spack/stage/libelf@0.8.13%gcc@4.8.3 arch=linux-ppc64/libelf-0.8.13
+ /Users/gamblin2/src/spack/var/spack/stage/libelf@0.8.13%gcc@4.8.3 arch=linux-debian7-x86_64/libelf-0.8.13
``spack cd`` here changed he current working directory to the
directory containing the expanded ``libelf`` source code. There are a
@@ -2851,3 +2949,109 @@ might write:
DWARF_PREFIX = $(spack location -i libdwarf)
CXXFLAGS += -I$DWARF_PREFIX/include
CXXFLAGS += -L$DWARF_PREFIX/lib
+
+Build System Configuration Support
+----------------------------------
+
+Imagine a developer creating a CMake-based (or Autotools) project in a local
+directory, which depends on libraries A-Z. Once Spack has installed
+those dependencies, one would like to run ``cmake`` with appropriate
+command line and environment so CMake can find them. The ``spack
+setup`` command does this conveniently, producing a CMake
+configuration that is essentially the same as how Spack *would have*
+configured the project. This can be demonstrated with a usage
+example:
+
+.. code-block:: bash
+
+ cd myproject
+ spack setup myproject@local
+ mkdir build; cd build
+ ../spconfig.py ..
+ make
+ make install
+
+Notes:
+ * Spack must have ``myproject/package.py`` in its repository for
+ this to work.
+ * ``spack setup`` produces the executable script ``spconfig.py`` in
+ the local directory, and also creates the module file for the
+ package. ``spconfig.py`` is normally run from the user's
+ out-of-source build directory.
+ * The version number given to ``spack setup`` is arbitrary, just
+ like ``spack diy``. ``myproject/package.py`` does not need to
+ have any valid downloadable versions listed (typical when a
+ project is new).
+ * spconfig.py produces a CMake configuration that *does not* use the
+ Spack wrappers. Any resulting binaries *will not* use RPATH,
+ unless the user has enabled it. This is recommended for
+ development purposes, not production.
+ * ``spconfig.py`` is human readable, and can serve as a developer
+ reference of what dependencies are being used.
+ * ``make install`` installs the package into the Spack repository,
+ where it may be used by other Spack packages.
+ * CMake-generated makefiles re-run CMake in some circumstances. Use
+ of ``spconfig.py`` breaks this behavior, requiring the developer
+ to manually re-run ``spconfig.py`` when a ``CMakeLists.txt`` file
+ has changed.
+
+CMakePackage
+~~~~~~~~~~~~
+
+In order ot enable ``spack setup`` functionality, the author of
+``myproject/package.py`` must subclass from ``CMakePackage`` instead
+of the standard ``Package`` superclass. Because CMake is
+standardized, the packager does not need to tell Spack how to run
+``cmake; make; make install``. Instead the packager only needs to
+create (optional) methods ``configure_args()`` and ``configure_env()``, which
+provide the arguments (as a list) and extra environment variables (as
+a dict) to provide to the ``cmake`` command. Usually, these will
+translate variant flags into CMake definitions. For example:
+
+.. code-block:: python
+
+ def configure_args(self):
+ spec = self.spec
+ return [
+ '-DUSE_EVERYTRACE=%s' % ('YES' if '+everytrace' in spec else 'NO'),
+ '-DBUILD_PYTHON=%s' % ('YES' if '+python' in spec else 'NO'),
+ '-DBUILD_GRIDGEN=%s' % ('YES' if '+gridgen' in spec else 'NO'),
+ '-DBUILD_COUPLER=%s' % ('YES' if '+coupler' in spec else 'NO'),
+ '-DUSE_PISM=%s' % ('YES' if '+pism' in spec else 'NO')]
+
+If needed, a packager may also override methods defined in
+``StagedPackage`` (see below).
+
+
+StagedPackage
+~~~~~~~~~~~~~
+
+``CMakePackage`` is implemented by subclassing the ``StagedPackage``
+superclass, which breaks down the standard ``Package.install()``
+method into several sub-stages: ``setup``, ``configure``, ``build``
+and ``install``. Details:
+
+* Instead of implementing the standard ``install()`` method, package
+ authors implement the methods for the sub-stages
+ ``install_setup()``, ``install_configure()``,
+ ``install_build()``, and ``install_install()``.
+
+* The ``spack install`` command runs the sub-stages ``configure``,
+ ``build`` and ``install`` in order. (The ``setup`` stage is
+ not run by default; see below).
+* The ``spack setup`` command runs the sub-stages ``setup``
+ and a dummy install (to create the module file).
+* The sub-stage install methods take no arguments (other than
+ ``self``). The arguments ``spec`` and ``prefix`` to the standard
+ ``install()`` method may be accessed via ``self.spec`` and
+ ``self.prefix``.
+
+GNU Autotools
+~~~~~~~~~~~~~
+
+The ``setup`` functionality is currently only available for
+CMake-based packages. Extending this functionality to GNU
+Autotools-based packages would be easy (and should be done by a
+developer who actively uses Autotools). Packages that use
+non-standard build systems can gain ``setup`` functionality by
+subclassing ``StagedPackage`` directly.
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index 965e3a7f78..20c9934704 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -176,8 +176,10 @@ sys_type = None
# TODO: it's not clear where all the stuff that needs to be included in packages
# should live. This file is overloaded for spack core vs. for packages.
#
-__all__ = ['Package', 'Version', 'when', 'ver']
+__all__ = ['Package', 'StagedPackage', 'CMakePackage', \
+ 'Version', 'when', 'ver']
from spack.package import Package, ExtensionConflictError
+from spack.package import StagedPackage, CMakePackage
from spack.version import Version, ver
from spack.multimethod import when
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 99c4cae020..fe5186a7d7 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -224,9 +224,12 @@ def set_compiler_environment_variables(pkg, env):
return env
-def set_build_environment_variables(pkg, env):
+def set_build_environment_variables(pkg, env, dirty=False):
"""
- This ensures a clean install environment when we build packages
+ This ensures a clean install environment when we build packages.
+
+ Arguments:
+ dirty -- skip unsetting the user's environment settings.
"""
# Add spack build environment path with compiler wrappers first in
# the path. We add both spack.env_path, which includes default
@@ -262,12 +265,26 @@ def set_build_environment_variables(pkg, env):
# Install root prefix
env.set(SPACK_INSTALL, spack.install_path)
- # Remove these vars from the environment during build because they
- # can affect how some packages find libraries. We want to make
- # sure that builds never pull in unintended external dependencies.
- env.unset('LD_LIBRARY_PATH')
- env.unset('LD_RUN_PATH')
- env.unset('DYLD_LIBRARY_PATH')
+ # Stuff in here sanitizes the build environemnt to eliminate
+ # anything the user has set that may interfere.
+ if not dirty:
+ # Remove these vars from the environment during build because they
+ # can affect how some packages find libraries. We want to make
+ # sure that builds never pull in unintended external dependencies.
+ env.unset('LD_LIBRARY_PATH')
+ env.unset('LIBRARY_PATH')
+ env.unset('CPATH')
+ env.unset('LD_RUN_PATH')
+ env.unset('DYLD_LIBRARY_PATH')
+
+ # Remove any macports installs from the PATH. The macports ld can
+ # cause conflicts with the built-in linker on el capitan. Solves
+ # assembler issues, e.g.:
+ # suffix or operands invalid for `movq'"
+ path = get_path('PATH')
+ for p in path:
+ if '/macports/' in p:
+ env.remove_path('PATH', p)
# Add bin directories from dependencies to the PATH for the build.
bin_dirs = reversed(
@@ -405,7 +422,7 @@ def load_external_modules(pkg):
load_module(dep.external_module)
-def setup_package(pkg):
+def setup_package(pkg, dirty=False):
"""Execute all environment setup routines."""
spack_env = EnvironmentModifications()
run_env = EnvironmentModifications()
@@ -428,7 +445,7 @@ def setup_package(pkg):
s.package.spec = s
set_compiler_environment_variables(pkg, spack_env)
- set_build_environment_variables(pkg, spack_env)
+ set_build_environment_variables(pkg, spack_env, dirty)
load_external_modules(pkg)
# traverse in postorder so package can use vars from its dependencies
spec = pkg.spec
@@ -457,7 +474,7 @@ def setup_package(pkg):
spack_env.apply_modifications()
-def fork(pkg, function):
+def fork(pkg, function, dirty=False):
"""Fork a child process to do part of a spack build.
Arguments:
@@ -465,6 +482,7 @@ def fork(pkg, function):
pkg -- pkg whose environemnt we should set up the
forked process for.
function -- arg-less function to run in the child process.
+ dirty -- If True, do NOT clean the environment before building.
Usage:
def child_fun():
@@ -488,7 +506,7 @@ def fork(pkg, function):
if pid == 0:
# Give the child process the package's build environment.
- setup_package(pkg)
+ setup_package(pkg, dirty=dirty)
try:
# call the forked function.
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index f5f234d7a7..18c748e483 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -325,7 +325,7 @@ def create(parser, args):
# Figure out a name and repo for the package.
name, version = guess_name_and_version(url, args)
spec = Spec(name)
- name = spec.name # factors out namespace, if any
+ name = spec.name.lower() # factors out namespace, if any
repo = find_repository(spec, args)
tty.msg("This looks like a URL for %s version %s" % (name, version))
diff --git a/lib/spack/spack/cmd/diy.py b/lib/spack/spack/cmd/diy.py
index 39faf59a17..643e6374b2 100644
--- a/lib/spack/spack/cmd/diy.py
+++ b/lib/spack/spack/cmd/diy.py
@@ -50,7 +50,7 @@ def setup_parser(subparser):
help="Do not display verbose build output while installing.")
subparser.add_argument(
'spec', nargs=argparse.REMAINDER,
- help="specs to use for install. Must contain package AND verison.")
+ help="specs to use for install. Must contain package AND version.")
def diy(self, args):
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index 9d3175786b..4c076322a9 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -54,7 +54,14 @@ def setup_parser(subparser):
'--fake', action='store_true', dest='fake',
help="Fake install. Just remove the prefix and touch a fake file in it.")
subparser.add_argument(
+ '--dirty', action='store_true', dest='dirty',
+ help="Install a package *without* cleaning the environment.")
+ subparser.add_argument(
'packages', nargs=argparse.REMAINDER, help="specs of packages to install")
+ subparser.add_argument(
+ '--run-tests', action='store_true', dest='run_tests',
+ help="Run tests during installation of a package.")
+
def install(parser, args):
@@ -77,6 +84,8 @@ def install(parser, args):
keep_stage=args.keep_stage,
ignore_deps=args.ignore_deps,
make_jobs=args.jobs,
+ run_tests=args.run_tests,
verbose=args.verbose,
fake=args.fake,
+ dirty=args.dirty,
explicit=True)
diff --git a/lib/spack/spack/cmd/setup.py b/lib/spack/spack/cmd/setup.py
new file mode 100644
index 0000000000..02e9bfd281
--- /dev/null
+++ b/lib/spack/spack/cmd/setup.py
@@ -0,0 +1,91 @@
+##############################################################################
+# Copyright (c) 2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Written by Elizabeth Fischer
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the LICENSE file 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 General Public License (as published by
+# the Free Software Foundation) version 2.1 dated 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 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 sys
+import os
+import argparse
+
+import llnl.util.tty as tty
+
+import spack
+import spack.cmd
+from spack.cmd.edit import edit_package
+from spack.stage import DIYStage
+
+description = "Create a configuration script and module, but don't build."
+
+def setup_parser(subparser):
+ subparser.add_argument(
+ '-i', '--ignore-dependencies', action='store_true', dest='ignore_deps',
+ help="Do not try to install dependencies of requested packages.")
+ subparser.add_argument(
+ '-v', '--verbose', action='store_true', dest='verbose',
+ help="Display verbose build output while installing.")
+ subparser.add_argument(
+ 'spec', nargs=argparse.REMAINDER,
+ help="specs to use for install. Must contain package AND verison.")
+
+
+def setup(self, args):
+ if not args.spec:
+ tty.die("spack setup requires a package spec argument.")
+
+ specs = spack.cmd.parse_specs(args.spec)
+ if len(specs) > 1:
+ tty.die("spack setup only takes one spec.")
+
+ # Take a write lock before checking for existence.
+ with spack.installed_db.write_transaction():
+ spec = specs[0]
+ if not spack.repo.exists(spec.name):
+ tty.warn("No such package: %s" % spec.name)
+ create = tty.get_yes_or_no("Create this package?", default=False)
+ if not create:
+ tty.msg("Exiting without creating.")
+ sys.exit(1)
+ else:
+ tty.msg("Running 'spack edit -f %s'" % spec.name)
+ edit_package(spec.name, spack.repo.first_repo(), None, True)
+ return
+
+ if not spec.versions.concrete:
+ tty.die("spack setup spec must have a single, concrete version. Did you forget a package version number?")
+
+ spec.concretize()
+ package = spack.repo.get(spec)
+
+ # It's OK if the package is already installed.
+
+ # Forces the build to run out of the current directory.
+ package.stage = DIYStage(os.getcwd())
+
+ # TODO: make this an argument, not a global.
+ spack.do_checksum = False
+
+ package.do_install(
+ keep_prefix=True, # Don't remove install directory, even if you think you should
+ ignore_deps=args.ignore_deps,
+ verbose=args.verbose,
+ keep_stage=True, # don't remove source dir for SETUP.
+ install_phases = set(['setup', 'provenance']))
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index f792008c49..d9992a5680 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -166,7 +166,11 @@ class DefaultConcretizer(object):
valid_versions.sort(key=prefer_key, reverse=True)
if valid_versions:
- spec.versions = ver([valid_versions[0]])
+ # Disregard @develop and take the next valid version
+ if ver(valid_versions[0]) == ver('develop') and len(valid_versions) > 1:
+ spec.versions = ver([valid_versions[1]])
+ else:
+ spec.versions = ver([valid_versions[0]])
else:
# We don't know of any SAFE versions that match the given
# spec. Grab the spec's versions and grab the highest
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 69c04f7920..38133ee0ca 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -307,9 +307,6 @@ class URLFetchStrategy(FetchStrategy):
if not self.archive_file:
raise NoArchiveFileError("Cannot call archive() before fetching.")
- if not extension(destination) == extension(self.archive_file):
- raise ValueError("Cannot archive without matching extensions.")
-
shutil.copy(self.archive_file, destination)
@_needs_stage
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index b73056fd30..74008c4dd9 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -37,6 +37,8 @@ import os
import re
import textwrap
import time
+import glob
+import string
import llnl.util.tty as tty
import spack
@@ -50,6 +52,8 @@ import spack.mirror
import spack.repository
import spack.url
import spack.util.web
+
+from urlparse import urlparse
from StringIO import StringIO
from llnl.util.filesystem import *
from llnl.util.lang import *
@@ -58,9 +62,11 @@ from llnl.util.tty.log import log_output
from spack.stage import Stage, ResourceStage, StageComposite
from spack.util.compression import allowed_archive
from spack.util.environment import dump_environment
-from spack.util.executable import ProcessError
+from spack.util.executable import ProcessError, Executable, which
from spack.version import *
+from spack import directory_layout
from urlparse import urlparse
+
"""Allowed URL schemes for spack packages."""
_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"]
@@ -305,6 +311,8 @@ class Package(object):
parallel = True
"""# jobs to use for parallel make. If set, overrides default of ncpus."""
make_jobs = None
+ """By default do not run tests within package's install()"""
+ run_tests = False
"""Most packages are NOT extendable. Set to True if you want extensions."""
extendable = False
"""List of prefix-relative file paths (or a single path). If these do
@@ -749,7 +757,7 @@ class Package(object):
self.stage.check()
self.stage.cache_local()
-
+
def do_stage(self, mirror_only=False):
"""Unpacks the fetched tarball, then changes into the expanded tarball
@@ -867,6 +875,7 @@ class Package(object):
resource_stage_folder = '-'.join(pieces)
return resource_stage_folder
+ install_phases = set(['configure', 'build', 'install', 'provenance'])
def do_install(self,
keep_prefix=False,
keep_stage=False,
@@ -874,8 +883,11 @@ class Package(object):
skip_patch=False,
verbose=False,
make_jobs=None,
+ run_tests=False,
fake=False,
- explicit=False):
+ explicit=False,
+ dirty=False,
+ install_phases = install_phases):
"""Called by commands to install a package and its dependencies.
Package implementations should override install() to describe
@@ -891,7 +903,9 @@ class Package(object):
fake -- Don't really build -- install fake stub files instead.
skip_patch -- Skip patch stage of build if True.
verbose -- Display verbose build output (by default, suppresses it)
+ dirty -- Don't clean the build environment before installing.
make_jobs -- Number of make jobs to use for install. Default is ncpus
+ run_tests -- Runn tests within the package's install()
"""
if not self.spec.concrete:
raise ValueError("Can only install concrete packages.")
@@ -903,7 +917,7 @@ class Package(object):
return
# Ensure package is not already installed
- if spack.install_layout.check_installed(self.spec):
+ if 'install' in install_phases and spack.install_layout.check_installed(self.spec):
tty.msg("%s is already installed in %s" % (self.name, self.prefix))
rec = spack.installed_db.get_record(self.spec)
if (not rec.explicit) and explicit:
@@ -922,7 +936,11 @@ class Package(object):
fake=fake,
skip_patch=skip_patch,
verbose=verbose,
- make_jobs=make_jobs)
+ make_jobs=make_jobs,
+ run_tests=run_tests)
+
+ # Set run_tests flag before starting build.
+ self.run_tests = run_tests
# Set parallelism before starting build.
self.make_jobs = make_jobs
@@ -942,6 +960,10 @@ class Package(object):
tty.msg("Building %s" % self.name)
self.stage.keep = keep_stage
+ self.install_phases = install_phases
+ self.build_directory = join_path(self.stage.path, 'spack-build')
+ self.source_directory = self.stage.source_path
+
with self.stage:
# Run the pre-install hook in the child process after
# the directory is created.
@@ -973,19 +995,29 @@ class Package(object):
raise e
# Ensure that something was actually installed.
- self.sanity_check_prefix()
+ if 'install' in self.install_phases:
+ self.sanity_check_prefix()
- # Copy provenance into the install directory on success
- log_install_path = spack.install_layout.build_log_path(
- self.spec)
- env_install_path = spack.install_layout.build_env_path(
- self.spec)
- packages_dir = spack.install_layout.build_packages_path(
- self.spec)
- install(log_path, log_install_path)
- install(env_path, env_install_path)
- dump_packages(self.spec, packages_dir)
+ # Copy provenance into the install directory on success
+ if 'provenance' in self.install_phases:
+ log_install_path = spack.install_layout.build_log_path(
+ self.spec)
+ env_install_path = spack.install_layout.build_env_path(
+ self.spec)
+ packages_dir = spack.install_layout.build_packages_path(
+ self.spec)
+
+ # Remove first if we're overwriting another build
+ # (can happen with spack setup)
+ try:
+ shutil.rmtree(packages_dir) # log_install_path and env_install_path are inside this
+ except:
+ pass
+
+ install(log_path, log_install_path)
+ install(env_path, env_install_path)
+ dump_packages(self.spec, packages_dir)
# Run post install hooks before build stage is removed.
spack.hooks.post_install(self)
@@ -1003,7 +1035,19 @@ class Package(object):
try:
# Create the install prefix and fork the build process.
spack.install_layout.create_install_directory(self.spec)
- spack.build_environment.fork(self, build_process)
+ except directory_layout.InstallDirectoryAlreadyExistsError:
+ if 'install' in install_phases:
+ # Abort install if install directory exists.
+ # But do NOT remove it (you'd be overwriting someon else's stuff)
+ tty.warn("Keeping existing install prefix in place.")
+ raise
+ else:
+ # We're not installing anyway, so don't worry if someone
+ # else has already written in the install directory
+ pass
+
+ try:
+ spack.build_environment.fork(self, build_process, dirty=dirty)
except:
# remove the install prefix if anything went wrong during install.
if not keep_prefix:
@@ -1013,7 +1057,7 @@ class Package(object):
"Spack will think this package is installed. " +
"Manually remove this directory to fix:",
self.prefix,
- wrap=True)
+ wrap=False)
raise
# note: PARENT of the build process adds the new package to
@@ -1485,6 +1529,152 @@ def _hms(seconds):
parts.append("%.2fs" % s)
return ' '.join(parts)
+class StagedPackage(Package):
+ """A Package subclass where the install() is split up into stages."""
+
+ def install_setup(self):
+ """Creates an spack_setup.py script to configure the package later if we like."""
+ raise InstallError("Package %s provides no install_setup() method!" % self.name)
+
+ def install_configure(self):
+ """Runs the configure process."""
+ raise InstallError("Package %s provides no install_configure() method!" % self.name)
+
+ def install_build(self):
+ """Runs the build process."""
+ raise InstallError("Package %s provides no install_build() method!" % self.name)
+
+ def install_install(self):
+ """Runs the install process."""
+ raise InstallError("Package %s provides no install_install() method!" % self.name)
+
+ def install(self, spec, prefix):
+ if 'setup' in self.install_phases:
+ self.install_setup()
+
+ if 'configure' in self.install_phases:
+ self.install_configure()
+
+ if 'build' in self.install_phases:
+ self.install_build()
+
+ if 'install' in self.install_phases:
+ self.install_install()
+ else:
+ # Create a dummy file so the build doesn't fail.
+ # That way, the module file will also be created.
+ with open(os.path.join(prefix, 'dummy'), 'w') as fout:
+ pass
+
+# stackoverflow.com/questions/12791997/how-do-you-do-a-simple-chmod-x-from-within-python
+def make_executable(path):
+ mode = os.stat(path).st_mode
+ mode |= (mode & 0o444) >> 2 # copy R bits to X
+ os.chmod(path, mode)
+
+
+
+class CMakePackage(StagedPackage):
+
+ def make_make(self):
+ import multiprocessing
+ # number of jobs spack will to build with.
+ jobs = multiprocessing.cpu_count()
+ if not self.parallel:
+ jobs = 1
+ elif self.make_jobs:
+ jobs = self.make_jobs
+
+ make = spack.build_environment.MakeExecutable('make', jobs)
+ return make
+
+ def configure_args(self):
+ """Returns package-specific arguments to be provided to the configure command."""
+ return list()
+
+ def configure_env(self):
+ """Returns package-specific environment under which the configure command should be run."""
+ return dict()
+
+ def spack_transitive_include_path(self):
+ return ';'.join(
+ os.path.join(dep, 'include')
+ for dep in os.environ['SPACK_DEPENDENCIES'].split(os.pathsep)
+ )
+
+ def install_setup(self):
+ cmd = [str(which('cmake'))] + \
+ spack.build_environment.get_std_cmake_args(self) + \
+ ['-DCMAKE_INSTALL_PREFIX=%s' % os.environ['SPACK_PREFIX'],
+ '-DCMAKE_C_COMPILER=%s' % os.environ['SPACK_CC'],
+ '-DCMAKE_CXX_COMPILER=%s' % os.environ['SPACK_CXX'],
+ '-DCMAKE_Fortran_COMPILER=%s' % os.environ['SPACK_FC']] + \
+ self.configure_args()
+
+ env = dict()
+ env['PATH'] = os.environ['PATH']
+ env['SPACK_TRANSITIVE_INCLUDE_PATH'] = self.spack_transitive_include_path()
+ env['CMAKE_PREFIX_PATH'] = os.environ['CMAKE_PREFIX_PATH']
+
+ setup_fname = 'spconfig.py'
+ with open(setup_fname, 'w') as fout:
+ fout.write(\
+r"""#!%s
+#
+
+import sys
+import os
+import subprocess
+
+def cmdlist(str):
+ return list(x.strip().replace("'",'') for x in str.split('\n') if x)
+env = dict(os.environ)
+""" % sys.executable)
+
+ env_vars = sorted(list(env.keys()))
+ for name in env_vars:
+ val = env[name]
+ if string.find(name, 'PATH') < 0:
+ fout.write('env[%s] = %s\n' % (repr(name),repr(val)))
+ else:
+ if name == 'SPACK_TRANSITIVE_INCLUDE_PATH':
+ sep = ';'
+ else:
+ sep = ':'
+
+ fout.write('env[%s] = "%s".join(cmdlist("""\n' % (repr(name),sep))
+ for part in string.split(val, sep):
+ fout.write(' %s\n' % part)
+ fout.write('"""))\n')
+
+ fout.write("env['CMAKE_TRANSITIVE_INCLUDE_PATH'] = env['SPACK_TRANSITIVE_INCLUDE_PATH'] # Deprecated\n")
+ fout.write('\ncmd = cmdlist("""\n')
+ fout.write('%s\n' % cmd[0])
+ for arg in cmd[1:]:
+ fout.write(' %s\n' % arg)
+ fout.write('""") + sys.argv[1:]\n')
+ fout.write('\nproc = subprocess.Popen(cmd, env=env)\nproc.wait()\n')
+ make_executable(setup_fname)
+
+
+ def install_configure(self):
+ cmake = which('cmake')
+ with working_dir(self.build_directory, create=True):
+ os.environ.update(self.configure_env())
+ os.environ['SPACK_TRANSITIVE_INCLUDE_PATH'] = self.spack_transitive_include_path()
+ options = self.configure_args() + spack.build_environment.get_std_cmake_args(self)
+ cmake(self.source_directory, *options)
+
+ def install_build(self):
+ make = self.make_make()
+ with working_dir(self.build_directory, create=False):
+ make()
+
+ def install_install(self):
+ make = self.make_make()
+ with working_dir(self.build_directory, create=False):
+ make('install')
+
class FetchError(spack.error.SpackError):
"""Raised when something goes wrong during fetch."""
diff --git a/lib/spack/spack/platforms/linux.py b/lib/spack/spack/platforms/linux.py
index 4d8adac384..4d3f59c320 100644
--- a/lib/spack/spack/platforms/linux.py
+++ b/lib/spack/spack/platforms/linux.py
@@ -1,16 +1,23 @@
import subprocess
+import platform
from spack.architecture import Platform, Target
from spack.operating_systems.linux_distro import LinuxDistro
class Linux(Platform):
priority = 90
- front_end = 'x86_64'
- back_end = 'x86_64'
- default = 'x86_64'
def __init__(self):
super(Linux, self).__init__('linux')
- self.add_target(self.default, Target(self.default))
+ self.add_target('x86_64', Target('x86_64'))
+ self.add_target('ppc64le', Target('ppc64le'))
+
+ self.default = platform.machine()
+ self.front_end = platform.machine()
+ self.back_end = platform.machine()
+
+ if self.default not in self.targets:
+ self.add_target(self.default, Target(self.default))
+
linux_dist = LinuxDistro()
self.default_os = str(linux_dist)
self.front_os = self.default_os
diff --git a/lib/spack/spack/test/mock_packages_test.py b/lib/spack/spack/test/mock_packages_test.py
index e1acc32cb7..c8b06cd7d7 100644
--- a/lib/spack/spack/test/mock_packages_test.py
+++ b/lib/spack/spack/test/mock_packages_test.py
@@ -84,15 +84,6 @@ compilers:
modules: 'None'
- compiler:
spec: clang@3.3
- operating_system: redhat6
- paths:
- cc: /path/to/clang
- cxx: /path/to/clang++
- f77: None
- fc: None
- modules: 'None'
-- compiler:
- spec: clang@3.3
operating_system: yosemite
paths:
cc: /path/to/clang
@@ -124,15 +115,6 @@ compilers:
cxx: /path/to/g++
f77: /path/to/gfortran
fc: /path/to/gfortran
- operating_system: redhat6
- spec: gcc@4.5.0
- modules: 'None'
-- compiler:
- paths:
- cc: /path/to/gcc
- cxx: /path/to/g++
- f77: /path/to/gfortran
- fc: /path/to/gfortran
operating_system: yosemite
spec: gcc@4.5.0
modules: 'None'
diff --git a/lib/spack/spack/test/versions.py b/lib/spack/spack/test/versions.py
index 4624f901c8..41d72e7c34 100644
--- a/lib/spack/spack/test/versions.py
+++ b/lib/spack/spack/test/versions.py
@@ -92,6 +92,9 @@ class VersionsTest(unittest.TestCase):
self.assert_ver_eq('1.0', '1.0')
self.assert_ver_lt('1.0', '2.0')
self.assert_ver_gt('2.0', '1.0')
+ self.assert_ver_eq('develop', 'develop')
+ self.assert_ver_lt('1.0', 'develop')
+ self.assert_ver_gt('develop', '1.0')
def test_three_segments(self):
self.assert_ver_eq('2.0.1', '2.0.1')
@@ -389,3 +392,39 @@ class VersionsTest(unittest.TestCase):
self.assertEqual(v.dotted, '1.2.3')
self.assertEqual(v.dashed, '1-2-3')
self.assertEqual(v.underscored, '1_2_3')
+
+ def test_repr_and_str(self):
+
+ def check_repr_and_str(vrs):
+ a = Version(vrs)
+ self.assertEqual(repr(a), 'Version(\'' + vrs + '\')')
+ b = eval(repr(a))
+ self.assertEqual(a, b)
+ self.assertEqual(str(a), vrs)
+ self.assertEqual(str(a), str(b))
+
+ check_repr_and_str('1.2.3')
+ check_repr_and_str('R2016a')
+ check_repr_and_str('R2016a.2-3_4')
+
+ def test_get_item(self):
+ a = Version('0.1_2-3')
+ self.assertTrue(isinstance(a[1], int))
+ # Test slicing
+ b = a[0:2]
+ self.assertTrue(isinstance(b, Version))
+ self.assertEqual(b, Version('0.1'))
+ self.assertEqual(repr(b), 'Version(\'0.1\')')
+ self.assertEqual(str(b), '0.1')
+ b = a[0:3]
+ self.assertTrue(isinstance(b, Version))
+ self.assertEqual(b, Version('0.1_2'))
+ self.assertEqual(repr(b), 'Version(\'0.1_2\')')
+ self.assertEqual(str(b), '0.1_2')
+ b = a[1:]
+ self.assertTrue(isinstance(b, Version))
+ self.assertEqual(b, Version('1_2-3'))
+ self.assertEqual(repr(b), 'Version(\'1_2-3\')')
+ self.assertEqual(str(b), '1_2-3')
+ # Raise TypeError on tuples
+ self.assertRaises(TypeError, b.__getitem__, 1, 2)
diff --git a/lib/spack/spack/version.py b/lib/spack/spack/version.py
index 858d581472..6f6c83b3d8 100644
--- a/lib/spack/spack/version.py
+++ b/lib/spack/spack/version.py
@@ -44,6 +44,7 @@ be called on any of the types::
concrete
"""
import re
+import numbers
from bisect import bisect_left
from functools import wraps
@@ -194,10 +195,24 @@ class Version(object):
return iter(self.version)
def __getitem__(self, idx):
- return tuple(self.version[idx])
+ cls = type(self)
+ if isinstance(idx, numbers.Integral):
+ return self.version[idx]
+ elif isinstance(idx, slice):
+ # Currently len(self.separators) == len(self.version) - 1
+ extendend_separators = self.separators + ('',)
+ string_arg = []
+ for token, sep in zip(self.version, extendend_separators)[idx]:
+ string_arg.append(str(token))
+ string_arg.append(str(sep))
+ string_arg.pop() # We don't need the last separator
+ string_arg = ''.join(string_arg)
+ return cls(string_arg)
+ message = '{cls.__name__} indices must be integers'
+ raise TypeError(message.format(cls=cls))
def __repr__(self):
- return self.string
+ return 'Version(' + repr(self.string) + ')'
def __str__(self):
return self.string
@@ -221,6 +236,14 @@ class Version(object):
if self.version == other.version:
return False
+ # dev is __gt__ than anything but itself.
+ if other.string == 'develop':
+ return True
+
+ # If lhs is dev then it can't be < than anything
+ if self.string == 'develop':
+ return False
+
for a, b in zip(self.version, other.version):
if a == b:
continue