We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `var/spack/repos/builtin/packages/zfp/package.py`
Content:
```
1 # Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
2 # Spack Project Developers. See the top-level COPYRIGHT file for details.
3 #
4 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
5 
6 from spack import *
7 
8 
9 class Zfp(CMakePackage, CudaPackage):
10     """zfp is a compressed number format for multidimensional floating-point
11        and integer arrays.
12 
13        zfp provides compressed-array classes that support high throughput
14        read and write random access to individual array elements. zfp also
15        supports serial and parallel (OpenMP and CUDA) compression of whole
16        arrays.
17     """
18 
19     # Package info
20     homepage    = 'https://zfp.llnl.gov'
21     url         = 'https://github.com/LLNL/zfp/releases/download/0.5.5/zfp-0.5.5.tar.gz'
22     git         = 'https://github.com/LLNL/zfp.git'
23     maintainers = ['lindstro', 'GarrettDMorrison']
24 
25     # Versions
26     version('develop', branch='develop')
27     version('0.5.5', sha256='fdf7b948bab1f4e5dccfe2c2048fd98c24e417ad8fb8a51ed3463d04147393c5')
28     version('0.5.4', sha256='746e17aaa401c67dcffd273d6e6f95c76adfbbd5cf523dcad56d09e9d3b71196')
29     version('0.5.3', sha256='a5d2f8e5b47a7c92e2a5775b82cbfb3a76c87d0ac83d25abb4ac10ea75a2856e')
30     version('0.5.2', sha256='9c738ec525cc76b4bb80b2b3f7c9f07507eeda3a341470e5942cda97efbe9a4f', url='https://github.com/LLNL/zfp/archive/0.5.2/zfp-0.5.2.tar.gz')
31     version('0.5.1', sha256='f255dd1708c9ae4dc6a56dd2614e8b47a10d833c87fd349cbd47545a19c2b779', url='https://github.com/LLNL/zfp/archive/0.5.1/zfp-0.5.1.tar.gz')
32 
33     # Build targets
34     # TODO: variant('utilities', default=True,  description='Build utilities')
35     variant('shared',    default=True,  description='Build shared libraries')
36 
37     # Language bindings
38     variant('c',       default=False, description='Enable C bindings')
39     variant('python',  default=False, description='Enable Python bindings')
40     variant('fortran', default=False, description='Enable Fortran bindings')
41 
42     # Execution policies
43     variant('openmp', default=False, description='Enable OpenMP execution')
44     variant('cuda',   default=False, description='Enable CUDA execution')
45 
46     # Advanced options
47     variant('bsws', default='64', values=('8', '16', '32', '64'), multi=False,
48             description='Bit stream word size: '
49             'use smaller for finer rate granularity. '
50             'Use 8 for H5Z-ZFP filter.')
51     variant('strided', default=False,
52             description='Enable strided access for progressive zfp streams')
53     variant('aligned', default=False,
54             description='Enable aligned memory allocation')
55     variant('twoway', default=False,
56             description='Use two-way skew-associative cache')
57     variant('fasthash', default=False,
58             description='Use a faster but more collision prone hash function')
59     variant('profile', default=False,
60             description='Count cache misses')
61 
62     # Conflicts
63     conflicts('+c',        when='@:0.5.3',
64               msg='+c requires zfp 0.5.4 or later')
65     conflicts('+python',   when='@:0.5.4',
66               msg='+python requires zfp 0.5.5 or later')
67     conflicts('+fortran',  when='@:0.5.4',
68               msg='+fortran requires zfp 0.5.5 or later')
69     conflicts('+openmp',   when='@:0.5.2',
70               msg='+openmp requires zfp 0.5.3 or later')
71     conflicts('+cuda',     when='@:0.5.3',
72               msg='+cuda requires zfp 0.5.4 or later')
73     conflicts('+fasthash', when='@:0.5.1',
74               msg='+fasthash requires zfp 0.5.2 or later')
75     conflicts('+profile',  when='@:0.5.1',
76               msg='+profile requires zfp 0.5.2 or later')
77 
78     # Dependencies
79     depends_on('cmake@3.4.0:', type='build')
80     depends_on('cuda@7:',      type=('build', 'test', 'run'), when='+cuda')
81     depends_on('py-numpy',     type=('build', 'test', 'run'), when='+python')
82     depends_on('py-cython',    type='build',                  when='+python')
83 
84     def cmake_args(self):
85         spec = self.spec
86 
87         # CMake options
88         args = [
89             # TODO: self.define_from_variant('BUILD_UTILITIES', 'utilities'),
90             self.define('BUILD_TESTING', self.run_tests),
91             self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
92             self.define_from_variant('BUILD_CFP', 'c'),
93             self.define_from_variant('BUILD_ZFPY', 'python'),
94             self.define_from_variant('BUILD_ZFORP', 'fortran'),
95             self.define('ZFP_BIT_STREAM_WORD_SIZE',
96                         spec.variants['bsws'].value),
97             self.define_from_variant('ZFP_WITH_BIT_STREAM_STRIDED', 'strided'),
98             self.define_from_variant('ZFP_WITH_ALIGNED_ALLOC', 'aligned'),
99             self.define_from_variant('ZFP_WITH_CACHE_TWOWAY', 'twoway'),
100             self.define_from_variant('ZFP_WITH_CACHE_FAST_HASH', 'fasthash'),
101             self.define_from_variant('ZFP_WITH_CACHE_PROFILE', 'profile')
102         ]
103 
104         return args
105
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
     # 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')

{"golden_diff": "diff --git a/var/spack/repos/builtin/packages/zfp/package.py b/var/spack/repos/builtin/packages/zfp/package.py\n--- a/var/spack/repos/builtin/packages/zfp/package.py\n+++ b/var/spack/repos/builtin/packages/zfp/package.py\n@@ -78,6 +78,7 @@\n     # Dependencies\n     depends_on('cmake@3.4.0:', type='build')\n     depends_on('cuda@7:',      type=('build', 'test', 'run'), when='+cuda')\n+    depends_on('python',     type=('build', 'test', 'run'), when='+python')\n     depends_on('py-numpy',     type=('build', 'test', 'run'), when='+python')\n     depends_on('py-cython',    type='build',                  when='+python')\n", "issue": "Installation issue: zfp install fails due to use of system python\nWhen 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.\r\n\r\nI 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???\r\n\r\n(I also see the system python in SPACK_PYTHON env var --- I assume this means the python under which spack itself is running?) \r\n\r\nAdding 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.\r\n\r\n### Steps to reproduce the issue\r\n\r\n\r\n```console\r\n$ spack install zfp\r\n...\r\n-- Found PythonLibs: /usr/lib64/libpython3.6m.so (found version \"3.6.8\")\r\n-- Found PythonInterp: /usr/bin/python3.6\r\nFatal Python error: Py_Initialize: Unable to get the locale encoding\r\nModuleNotFoundError: No module named 'encodings'\r\n\r\nCurrent thread 0x00007f8e898a2b80 (most recent call first):\r\nCMake Error at python/scikit-build-cmake/FindPythonExtensions.cmake:299 (list):\r\n  list GET given empty list\r\nCall Stack (most recent call first):\r\n  python/CMakeLists.txt:4 (include)\r\n...\r\n```\r\n\r\nThe spack-installed python is version 3.7.7, and has a much longer path.\r\n\r\n### Information on your system\r\n\r\n```console\r\n$ spack debug report\r\n* **Spack:** 0.16.1-2432-16111354aa\r\n* **Python:** 3.6.8\r\n* **Platform:** linux-rhel8-x86_64\r\n* **Concretizer:** original\r\n```\r\n\r\n\r\n\r\n### Additional information\r\n\r\n\r\n* [spack-build-env.txt](https://github.com/spack/spack/files/6424165/spack-build-env.txt)\r\n* [spack-build-out.txt](https://github.com/spack/spack/files/6424166/spack-build-out.txt)\r\n\r\nMaintainers of the zfp package: @GarrettDMorrison  @lindstro\r\n\r\n\r\n### General information\r\n\r\n- [x ] I have run `spack debug report` and reported the version of Spack/Python/Platform\r\n- [x ] I have run `spack maintainers <name-of-the-package>` and @mentioned any maintainers\r\n- [x ] I have uploaded the build log and environment files\r\n- [x ] I have searched the issues of this repo and believe this is not a duplicate\r\n\n", "before_files": [{"content": "# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other\n# Spack Project Developers. See the top-level COPYRIGHT file for details.\n#\n# SPDX-License-Identifier: (Apache-2.0 OR MIT)\n\nfrom spack import *\n\n\nclass Zfp(CMakePackage, CudaPackage):\n    \"\"\"zfp is a compressed number format for multidimensional floating-point\n       and integer arrays.\n\n       zfp provides compressed-array classes that support high throughput\n       read and write random access to individual array elements. zfp also\n       supports serial and parallel (OpenMP and CUDA) compression of whole\n       arrays.\n    \"\"\"\n\n    # Package info\n    homepage    = 'https://zfp.llnl.gov'\n    url         = 'https://github.com/LLNL/zfp/releases/download/0.5.5/zfp-0.5.5.tar.gz'\n    git         = 'https://github.com/LLNL/zfp.git'\n    maintainers = ['lindstro', 'GarrettDMorrison']\n\n    # Versions\n    version('develop', branch='develop')\n    version('0.5.5', sha256='fdf7b948bab1f4e5dccfe2c2048fd98c24e417ad8fb8a51ed3463d04147393c5')\n    version('0.5.4', sha256='746e17aaa401c67dcffd273d6e6f95c76adfbbd5cf523dcad56d09e9d3b71196')\n    version('0.5.3', sha256='a5d2f8e5b47a7c92e2a5775b82cbfb3a76c87d0ac83d25abb4ac10ea75a2856e')\n    version('0.5.2', sha256='9c738ec525cc76b4bb80b2b3f7c9f07507eeda3a341470e5942cda97efbe9a4f', url='https://github.com/LLNL/zfp/archive/0.5.2/zfp-0.5.2.tar.gz')\n    version('0.5.1', sha256='f255dd1708c9ae4dc6a56dd2614e8b47a10d833c87fd349cbd47545a19c2b779', url='https://github.com/LLNL/zfp/archive/0.5.1/zfp-0.5.1.tar.gz')\n\n    # Build targets\n    # TODO: variant('utilities', default=True,  description='Build utilities')\n    variant('shared',    default=True,  description='Build shared libraries')\n\n    # Language bindings\n    variant('c',       default=False, description='Enable C bindings')\n    variant('python',  default=False, description='Enable Python bindings')\n    variant('fortran', default=False, description='Enable Fortran bindings')\n\n    # Execution policies\n    variant('openmp', default=False, description='Enable OpenMP execution')\n    variant('cuda',   default=False, description='Enable CUDA execution')\n\n    # Advanced options\n    variant('bsws', default='64', values=('8', '16', '32', '64'), multi=False,\n            description='Bit stream word size: '\n            'use smaller for finer rate granularity. '\n            'Use 8 for H5Z-ZFP filter.')\n    variant('strided', default=False,\n            description='Enable strided access for progressive zfp streams')\n    variant('aligned', default=False,\n            description='Enable aligned memory allocation')\n    variant('twoway', default=False,\n            description='Use two-way skew-associative cache')\n    variant('fasthash', default=False,\n            description='Use a faster but more collision prone hash function')\n    variant('profile', default=False,\n            description='Count cache misses')\n\n    # Conflicts\n    conflicts('+c',        when='@:0.5.3',\n              msg='+c requires zfp 0.5.4 or later')\n    conflicts('+python',   when='@:0.5.4',\n              msg='+python requires zfp 0.5.5 or later')\n    conflicts('+fortran',  when='@:0.5.4',\n              msg='+fortran requires zfp 0.5.5 or later')\n    conflicts('+openmp',   when='@:0.5.2',\n              msg='+openmp requires zfp 0.5.3 or later')\n    conflicts('+cuda',     when='@:0.5.3',\n              msg='+cuda requires zfp 0.5.4 or later')\n    conflicts('+fasthash', when='@:0.5.1',\n              msg='+fasthash requires zfp 0.5.2 or later')\n    conflicts('+profile',  when='@:0.5.1',\n              msg='+profile requires zfp 0.5.2 or later')\n\n    # Dependencies\n    depends_on('cmake@3.4.0:', type='build')\n    depends_on('cuda@7:',      type=('build', 'test', 'run'), when='+cuda')\n    depends_on('py-numpy',     type=('build', 'test', 'run'), when='+python')\n    depends_on('py-cython',    type='build',                  when='+python')\n\n    def cmake_args(self):\n        spec = self.spec\n\n        # CMake options\n        args = [\n            # TODO: self.define_from_variant('BUILD_UTILITIES', 'utilities'),\n            self.define('BUILD_TESTING', self.run_tests),\n            self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),\n            self.define_from_variant('BUILD_CFP', 'c'),\n            self.define_from_variant('BUILD_ZFPY', 'python'),\n            self.define_from_variant('BUILD_ZFORP', 'fortran'),\n            self.define('ZFP_BIT_STREAM_WORD_SIZE',\n                        spec.variants['bsws'].value),\n            self.define_from_variant('ZFP_WITH_BIT_STREAM_STRIDED', 'strided'),\n            self.define_from_variant('ZFP_WITH_ALIGNED_ALLOC', 'aligned'),\n            self.define_from_variant('ZFP_WITH_CACHE_TWOWAY', 'twoway'),\n            self.define_from_variant('ZFP_WITH_CACHE_FAST_HASH', 'fasthash'),\n            self.define_from_variant('ZFP_WITH_CACHE_PROFILE', 'profile')\n        ]\n\n        return args\n", "path": "var/spack/repos/builtin/packages/zfp/package.py"}], "after_files": [{"content": "# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other\n# Spack Project Developers. See the top-level COPYRIGHT file for details.\n#\n# SPDX-License-Identifier: (Apache-2.0 OR MIT)\n\nfrom spack import *\n\n\nclass Zfp(CMakePackage, CudaPackage):\n    \"\"\"zfp is a compressed number format for multidimensional floating-point\n       and integer arrays.\n\n       zfp provides compressed-array classes that support high throughput\n       read and write random access to individual array elements. zfp also\n       supports serial and parallel (OpenMP and CUDA) compression of whole\n       arrays.\n    \"\"\"\n\n    # Package info\n    homepage    = 'https://zfp.llnl.gov'\n    url         = 'https://github.com/LLNL/zfp/releases/download/0.5.5/zfp-0.5.5.tar.gz'\n    git         = 'https://github.com/LLNL/zfp.git'\n    maintainers = ['lindstro', 'GarrettDMorrison']\n\n    # Versions\n    version('develop', branch='develop')\n    version('0.5.5', sha256='fdf7b948bab1f4e5dccfe2c2048fd98c24e417ad8fb8a51ed3463d04147393c5')\n    version('0.5.4', sha256='746e17aaa401c67dcffd273d6e6f95c76adfbbd5cf523dcad56d09e9d3b71196')\n    version('0.5.3', sha256='a5d2f8e5b47a7c92e2a5775b82cbfb3a76c87d0ac83d25abb4ac10ea75a2856e')\n    version('0.5.2', sha256='9c738ec525cc76b4bb80b2b3f7c9f07507eeda3a341470e5942cda97efbe9a4f', url='https://github.com/LLNL/zfp/archive/0.5.2/zfp-0.5.2.tar.gz')\n    version('0.5.1', sha256='f255dd1708c9ae4dc6a56dd2614e8b47a10d833c87fd349cbd47545a19c2b779', url='https://github.com/LLNL/zfp/archive/0.5.1/zfp-0.5.1.tar.gz')\n\n    # Build targets\n    # TODO: variant('utilities', default=True,  description='Build utilities')\n    variant('shared',    default=True,  description='Build shared libraries')\n\n    # Language bindings\n    variant('c',       default=False, description='Enable C bindings')\n    variant('python',  default=False, description='Enable Python bindings')\n    variant('fortran', default=False, description='Enable Fortran bindings')\n\n    # Execution policies\n    variant('openmp', default=False, description='Enable OpenMP execution')\n    variant('cuda',   default=False, description='Enable CUDA execution')\n\n    # Advanced options\n    variant('bsws', default='64', values=('8', '16', '32', '64'), multi=False,\n            description='Bit stream word size: '\n            'use smaller for finer rate granularity. '\n            'Use 8 for H5Z-ZFP filter.')\n    variant('strided', default=False,\n            description='Enable strided access for progressive zfp streams')\n    variant('aligned', default=False,\n            description='Enable aligned memory allocation')\n    variant('twoway', default=False,\n            description='Use two-way skew-associative cache')\n    variant('fasthash', default=False,\n            description='Use a faster but more collision prone hash function')\n    variant('profile', default=False,\n            description='Count cache misses')\n\n    # Conflicts\n    conflicts('+c',        when='@:0.5.3',\n              msg='+c requires zfp 0.5.4 or later')\n    conflicts('+python',   when='@:0.5.4',\n              msg='+python requires zfp 0.5.5 or later')\n    conflicts('+fortran',  when='@:0.5.4',\n              msg='+fortran requires zfp 0.5.5 or later')\n    conflicts('+openmp',   when='@:0.5.2',\n              msg='+openmp requires zfp 0.5.3 or later')\n    conflicts('+cuda',     when='@:0.5.3',\n              msg='+cuda requires zfp 0.5.4 or later')\n    conflicts('+fasthash', when='@:0.5.1',\n              msg='+fasthash requires zfp 0.5.2 or later')\n    conflicts('+profile',  when='@:0.5.1',\n              msg='+profile requires zfp 0.5.2 or later')\n\n    # Dependencies\n    depends_on('cmake@3.4.0:', type='build')\n    depends_on('cuda@7:',      type=('build', 'test', 'run'), when='+cuda')\n    depends_on('python',     type=('build', 'test', 'run'), when='+python')\n    depends_on('py-numpy',     type=('build', 'test', 'run'), when='+python')\n    depends_on('py-cython',    type='build',                  when='+python')\n\n    def cmake_args(self):\n        spec = self.spec\n\n        # CMake options\n        args = [\n            # TODO: self.define_from_variant('BUILD_UTILITIES', 'utilities'),\n            self.define('BUILD_TESTING', self.run_tests),\n            self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),\n            self.define_from_variant('BUILD_CFP', 'c'),\n            self.define_from_variant('BUILD_ZFPY', 'python'),\n            self.define_from_variant('BUILD_ZFORP', 'fortran'),\n            self.define('ZFP_BIT_STREAM_WORD_SIZE',\n                        spec.variants['bsws'].value),\n            self.define_from_variant('ZFP_WITH_BIT_STREAM_STRIDED', 'strided'),\n            self.define_from_variant('ZFP_WITH_ALIGNED_ALLOC', 'aligned'),\n            self.define_from_variant('ZFP_WITH_CACHE_TWOWAY', 'twoway'),\n            self.define_from_variant('ZFP_WITH_CACHE_FAST_HASH', 'fasthash'),\n            self.define_from_variant('ZFP_WITH_CACHE_PROFILE', 'profile')\n        ]\n\n        return args\n", "path": "var/spack/repos/builtin/packages/zfp/package.py"}]}