Repository: spack/spack

Issue:
Installation issue: rdma-core: cannot find PythonLibs
I'm trying to build an environment that includes a dependency on `mvapich2@2.3.5` that fails to build due to `rdma-core` reportedly `missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS`.  

### Steps to reproduce the issue

I can reproduce the problem using the concretized spec output shown below.  The same error is reported when I try to install `rdma-core@33.1` with the same constraints.

```console
$ spack install rdma-core@34.0%gcc@8.3.1~ipo build_type=RelWithDebInfo arch=linux-rhel7-broadwell
...
==> Installing rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd
==> No binary for rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd found: installing from source
==> Warning: Missing a source id for flex@2.5.37
==> Warning: Missing a source id for m4@1.4.16
==> Warning: Missing a source id for pkg-config@0.27.1
==> Fetching https://spack-llnl-mirror.s3-us-west-2.amazonaws.com/_source-cache/archive/d1/d179b102bec551ce62265ed463d1095fb2ae9baff604261ad63327fcd20650e5.tar.gz
######################################################################## 100.0%
==> No patches needed for rdma-core
==> rdma-core: Executing phase: 'cmake'
==> Error: ProcessError: Command exited with status 1:
    'cmake' '-G' 'Unix Makefiles' '-DCMAKE_INSTALL_PREFIX:STRING=$SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd' '-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo' '-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=OFF' '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF' '-DCMAKE_INSTALL_RPATH:STRING=$SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd/lib;$SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd/lib64;$SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/libnl-3.3.0-cbtknyw7adogpeaajchy2wli2h3ygqbt/lib' '-DCMAKE_PREFIX_PATH:STRING=/usr/tce;$SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/py-docutils-0.15.2-u6qexghiferbmlnilc4xf4ywb2l5uiea;$SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/libnl-3.3.0-cbtknyw7adogpeaajchy2wli2h3ygqbt' '-DCMAKE_INSTALL_SYSCONFDIR=$SPACK_ROOT/opt/spack/linux-rhel7-broadwell/gcc-8.3.1/rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd/etc' '-DCMAKE_INSTALL_RUNDIR=/var/run' '/var/tmp/dahlgren/spack-stage/spack-stage-rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd/spack-src'

1 error found in build log:
     60    -- Performing Test SUPPORTS_AS_NEEDED - Success
     61    -- Performing Test SUPPORTS_NO_UNDEFINED
     62    -- Performing Test SUPPORTS_NO_UNDEFINED - Success
     63    -- Performing Test _LDSYMVER_SUCCESS
     64    -- Performing Test _LDSYMVER_SUCCESS - Success
     65    -- Found LDSymVer: GNU
  >> 66    CMake Error at /usr/tce/packages/cmake/cmake-3.14.5/share/cmake/Modu
           les/FindPackageHandleStandardArgs.cmake:137 (message):
     67      Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUD
           E_DIRS)
     68      (Required is exact version "3.7")
     69    Call Stack (most recent call first):
     70      /usr/tce/packages/cmake/cmake-3.14.5/share/cmake/Modules/FindPacka
           geHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
     71      /usr/tce/packages/cmake/cmake-3.14.5/share/cmake/Modules/FindPytho
           nLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
     72      CMakeLists.txt:430 (FIND_PACKAGE)

See build log for details:
  /var/tmp/dahlgren/spack-stage/spack-stage-rdma-core-33.1-nezmakccs2uze4u6xbonf6d5ya3ipfcd/spack-build-out.txt
...
```

### Information on your system

* **Spack:** 0.16.1-2148-e21e26094e
* **Python:** 3.7.2
* **Platform:** linux-rhel7-broadwell
* **Concretizer:** original


### General information

- [x] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have run `spack maintainers <name-of-the-package>` and @mentioned any maintainers  (NONE)
- [ ] I have uploaded the build log and environment files
- [x] I have searched the issues of this repo and believe this is not a duplicate



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/rdma-core/package.py b/var/spack/repos/builtin/packages/rdma-core/package.py
--- a/var/spack/repos/builtin/packages/rdma-core/package.py
+++ b/var/spack/repos/builtin/packages/rdma-core/package.py
@@ -38,7 +38,11 @@ class RdmaCore(CMakePackage):
 #       system path) as a component in compile-time static strings such as
 #       IBACM_SERVER_PATH.
     def cmake_args(self):
-        cmake_args = ["-DCMAKE_INSTALL_SYSCONFDIR=" +
-                      self.spec.prefix.etc,
-                      "-DCMAKE_INSTALL_RUNDIR=/var/run"]
+        cmake_args = [
+            '-DCMAKE_INSTALL_SYSCONFDIR={0}'.format(self.spec.prefix.etc),
+            '-DCMAKE_INSTALL_RUNDIR=/var/run',
+            '-DPYTHON_LIBRARY={0}'.format(self.spec['python'].libs[0]),
+            '-DPYTHON_INCLUDE_DIR={0}'
+            .format(self.spec['python'].headers.directories[0])
+        ]
         return cmake_args


Test patch: