Repository: spack/spack

Issue:
A spec for an external Trilinos package
I have a package called [DataTransferKit](https://github.com/ORNL-CEES/DataTransferKit). I'd like to add it to Spack as it is a part of an ECP project. However, there are some unusual challenges associated with this that I'm not sure how to address.

DataTransferKit, or DTK, is one of a few examples of an external package to Trilinos (another examples is [ForTrilinos](https://github.com/Trilinos/ForTrilinos)). What this means is that it lives in a separate repository from the main Trilinos, but depends on the Trilinos CMake build system for building. So to build it you need both the package *and* Trilinos repositories. The package may also have its own dependencies.

What would be the best way to write a spec for something like this? I can only see 2 ways, none of them are attractive:
1. Implement this as a variant to the trilinos package. Not sure how that would work with two repositories, but probably could be hacked via overloading some of the download and unpack functions.
2. Write a new spec (with a big similarity to existing Trilinos spec) that would install this package. Would this potentially lead to conflicts if both DTK and Trilinos modules are loaded? Probably yes, as they would both contain some of the similar Trilinos libraries.

I think an ideal way would be to somehow extend a Trilinos package to allow extensions to link in an external package that use its build system. I know that Spack has extensions (particularly, for Python), but not sure if it's applicable here in any form.


Discussion:
Separate repository/versions/URL -- IMO  (1) does not fit. So you certainly need a new package. You probably need a 'resource' to download additionally Trilinos (see Atlas for example). One may try deriving from Trilinos class to reuse some code.

You said it uses build system of Trilinos. Does it have everything Trilinos has (variants/dependencies) plus extra? 
> You said it uses build system of Trilinos. Does it have everything Trilinos has (variants/dependencies) plus extra?

The short answer is no. The long answer is that it uses a build system of Trilinos and depends on some of its packages. So it shares some of the dependencies (for instance, `boost`, `hdf5` and some), but certainly not all (no need for `swig`, for instance), and also has its own dependencies (`moab`).
It also does not need all variants of Trilinos (no need for a `python` variant), and may need its own variants/dependencies on Trilinos packages.
Then it's a different package whith Trilinos being an additional resouurce to download, if needed.
You could also add this as a resource for the trilinos package. See LLVM as an example.
@davydden Trilinos is always required. DTK is an external package of Trilinos. You can think of it as Tpetra but instead of living in the Trilinos repository, you need to download it separately. Then you need to tell Tribits where to find DTK so it can be installed at the same time as the rest of Trilinos. On top of that it depends on other packages in Trilinos like Kokkos and Tpetra. My problem with having two different packages is that I could install Trilinos and DTK separately but then when I load both of them how can I know which Tpetra (or any other Trilinos package) will be come from Trilinos and which will come from DTK. 
@Rombur thanks for clarification.

> Then you need to tell Tribits where to find DTK so it can be installed at the same time as the rest of Trilinos.

Looks like I misunderstood @aprokop, in this situation i would add `DTK` as a `variant` to Trilinos package (option 1) and use resource to download the archive, as noted by @adamjstewart (similar things happen in Atlas which downloads Lapack):
```
    resource(name='lapack',
             url='http://www.netlib.org/lapack/lapack-3.5.0.tgz',
             md5='b1d3e3e425b2e44a06760ff173104bdf',
             destination='spack-resource-lapack',
             when='@3:')
```
One can get to this file by
```
options.append('--with-netlib-lapack-tarfile=%s' %
                       self.stage[1].archive_file)
```


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/trilinos/package.py b/var/spack/repos/builtin/packages/trilinos/package.py
--- a/var/spack/repos/builtin/packages/trilinos/package.py
+++ b/var/spack/repos/builtin/packages/trilinos/package.py
@@ -87,14 +87,23 @@ class Trilinos(CMakePackage):
             description='Enables the build of shared libraries')
     variant('debug',        default=False,
             description='Builds a debug version of the libraries')
-    variant('boost',        default=True, description='Compile with Boost')
-    variant('tpetra',       default=True, description='Compile with Tpetra')
-    variant('exodus', default=False, description='Compile with Exodus from SEACAS')
+    variant('boost',        default=True,  description='Compile with Boost')
+    variant('tpetra',       default=True,  description='Compile with Tpetra')
+    variant('exodus',       default=False, description='Compile with Exodus from SEACAS')
+
+    variant('dtk',          default=False, description='Enable DataTransferKit')
+    resource(name='dtk',
+             git='https://github.com/ornl-cees/DataTransferKit',
+             tag='master',
+             placement='DataTransferKit',
+             when='+dtk')
+    conflicts('+dtk', when='~tpetra')
 
     # Everything should be compiled with -fpic
     depends_on('blas')
     depends_on('lapack')
     depends_on('boost', when='+boost')
+    depends_on('boost', when='+dtk')
     depends_on('matio')
     depends_on('glm')
     depends_on('metis@5:', when='+metis')
@@ -386,6 +395,13 @@ def cmake_args(self):
             '-DTrilinos_ENABLE_STK=OFF'
         ])
 
+        if '+dtk' in spec:
+            options.extend([
+                '-DTrilinos_EXTRA_REPOSITORIES:STRING=DataTransferKit',
+                '-DTpetra_INST_INT_UNSIGNED_LONG:BOOL=ON',
+                '-DTrilinos_ENABLE_DataTransferKit:BOOL=ON'
+            ])
+
         # exodus
         if '+exodus' in spec:
             options.extend([


Test patch: