Repository: spack/spack

Issue:
Installation issue: zfp install fails due to use of system python
When trying to build zfp on my system, I encountered a bunch of odd python errors.  Upon deeper investigation, it appears that the CMake configuration tool zfp was using found/decided to use the system installed python instead of the spack installed python.  Looking at the zfp recipe, it had dependencies on py-numpy and py-cython, but no explicit dependency on python.

I confess that might understanding of the different spack dependency types is still a bit vague, and I thought zfp's dependency on py-numpy should pick up py-numpy's dependency on python, and indeed I am seeing paths for the spack-installed python in the PATH, PYTHONHOME, and PYTHONPATH env variables in spack-build-env.txt, but for some reason CMake is using the system python, perhaps because spack-installed python is not in CMAKE_PREFIX_PATH???

(I also see the system python in SPACK_PYTHON env var --- I assume this means the python under which spack itself is running?) 

Adding an explicit dependency on python in the zfp recipe resolves the issue for me (it seems that this adds the spack-installed python to CMAKE_PREFIX_PATH).  I can provide a patch for such, but I am unsure if that is the best solution or not.

### Steps to reproduce the issue


```console
$ spack install zfp
...
-- Found PythonLibs: /usr/lib64/libpython3.6m.so (found version "3.6.8")
-- Found PythonInterp: /usr/bin/python3.6
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f8e898a2b80 (most recent call first):
CMake Error at python/scikit-build-cmake/FindPythonExtensions.cmake:299 (list):
  list GET given empty list
Call Stack (most recent call first):
  python/CMakeLists.txt:4 (include)
...
```

The spack-installed python is version 3.7.7, and has a much longer path.

### Information on your system

```console
$ spack debug report
* **Spack:** 0.16.1-2432-16111354aa
* **Python:** 3.6.8
* **Platform:** linux-rhel8-x86_64
* **Concretizer:** original
```



### Additional information


* [spack-build-env.txt](https://github.com/spack/spack/files/6424165/spack-build-env.txt)
* [spack-build-out.txt](https://github.com/spack/spack/files/6424166/spack-build-out.txt)

Maintainers of the zfp package: @GarrettDMorrison  @lindstro


### 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
- [x ] 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:
@payerle I must confess myself to not having a complete understanding of how these Python dependencies work.  I did not run into this issue myself when I last updated the zfp spack recipe, but I will take a look.  It seems reasonable to adopt the solution you propose, but before we do so I'd like to get some feedback from the spack folks.
@lindstro I suspect that the issue might manifest itself differently on different linux distros.  IIRC, I encountered a bunch of subtle python dependency issues in various packages when rebuilding a RHEL7 sw stack on RHEL8 last year.  If you have opportunity to easily rebuild zfp (perhaps changing a variant), keeping the stage directory, and see what PythonLib and PythonInterp CMake is reporting back, that would be interesting.  Was it using system python or spack-installed?

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/zfp/package.py b/var/spack/repos/builtin/packages/zfp/package.py
--- a/var/spack/repos/builtin/packages/zfp/package.py
+++ b/var/spack/repos/builtin/packages/zfp/package.py
@@ -78,6 +78,7 @@ class Zfp(CMakePackage, CudaPackage):
     # Dependencies
     depends_on('cmake@3.4.0:', type='build')
     depends_on('cuda@7:',      type=('build', 'test', 'run'), when='+cuda')
+    depends_on('python',     type=('build', 'test', 'run'), when='+python')
     depends_on('py-numpy',     type=('build', 'test', 'run'), when='+python')
     depends_on('py-cython',    type='build',                  when='+python')
 


Test patch: