Repository: spack/spack

Issue:
Error: KeyError: 'BINDIR' when installing package
### Steps to reproduce

```
spack --debug install -v wonton@1.3.2%gcc@7.4.0+jali~lapacke
```

### Error message

```
==> [2022-04-29-12:05:50.329930] Installing wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt
==> [2022-04-29-12:05:50.329968] Searching for binary cache of wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt
==> [2022-04-29-12:05:50.330136] Reading config file /projects/ngc/private/portage-deps/ci/wonton/spack/etc/spack/defaults/mirrors.yaml
==> [2022-04-29-12:05:50.730273] Did not find linux-rhel8-skylake_avx512-gcc-7.4.0-wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt.spec.json on https://mirror.spack.io/build_cache/linux-rhel8-skylake_avx512-gcc-7.4.0-wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt.spec.json
  Download failed: HTTP Error 404: Not Found
==> [2022-04-29-12:05:50.730325] Did not find linux-rhel8-skylake_avx512-gcc-7.4.0-wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt.spec.json on https://mirror.spack.io/build_cache/linux-rhel8-skylake_avx512-gcc-7.4.0-wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt.spec.yaml
  Download failed: HTTP Error 404: Not Found
==> [2022-04-29-12:05:50.730516] No binary for wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt found: installing from source
==> [2022-04-29-12:05:50.730590] Creating the installation directory /projects/ngc/private/portage-deps/ci/wonton/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-7.4.0/wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt
==> [2022-04-29-12:05:50.756212] '/usr/bin/git' '-C' '/projects/ngc/private/portage-deps/ci/wonton/spack' 'rev-parse' 'HEAD'
==> [2022-04-29-12:05:50.911107] module_cmd.load_module: gcc/7.4.0
==> [2022-04-29-12:05:51.348542] [TOOLCHAIN] MATCH Gcc
==> [2022-04-29-12:05:51.351579] Adding compiler bin/ paths: /projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/env /projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/env/case-insensitive /projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/env/gcc
==> [2022-04-29-12:05:51.370198] No headers found for xz
==> [2022-04-29-12:05:51.442695] '/projects/ngc/private/portage-deps/ci/wonton/spack/opt/spack/linux-rhel8-skylake_avx512/gcc-7.4.0/python-3.9.12-4e7rv3oeo3bzpivwsijoute3mpxifu5l/bin/python3.9' '-c' '
import json
from sysconfig import (
    get_config_vars,
    get_config_h_filename,
    get_makefile_filename,
    get_paths,
)

config = get_config_vars()
config['"'"'config_h_filename'"'"'] = get_config_h_filename()
config['"'"'makefile_filename'"'"'] = get_makefile_filename()
config.update(get_paths())

print(json.dumps(config))
'
==> [2022-04-29-12:05:51.468027] Error: KeyError: 'BINDIR'

/projects/ngc/private/portage-deps/ci/wonton/spack/var/spack/repos/builtin/packages/python/package.py:1044, in libs:
       1041
       1042        if '+shared' in self.spec:
       1043            ldlibrary = self.config_vars['LDLIBRARY']
  >>   1044            win_bin_dir = self.config_vars['BINDIR']
       1045            if os.path.exists(os.path.join(libdir, ldlibrary)):
       1046                return LibraryList(os.path.join(libdir, ldlibrary))
       1047            elif os.path.exists(os.path.join(libpl, ldlibrary)):


Traceback (most recent call last):
  File "/projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/spack/build_environment.py", line 1048, in _setup_pkg_and_run
    kwargs['env_modifications'] = setup_package(
  File "/projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/spack/build_environment.py", line 791, in setup_package
    set_wrapper_variables(pkg, env_mods)
  File "/projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/spack/build_environment.py", line 451, in set_wrapper_variables
    update_compiler_args_for_dep(dspec)
  File "/projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/spack/build_environment.py", line 423, in update_compiler_args_for_dep
    dep_link_dirs.extend(query.libs.directories)
  File "/projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/spack/spec.py", line 1060, in __get__
    value = f()
  File "/projects/ngc/private/portage-deps/ci/wonton/spack/lib/spack/spack/spec.py", line 1049, in <lambda>
    callbacks_chain.append(lambda: getattr(pkg, self.attribute_name))
  File "/projects/ngc/private/portage-deps/ci/wonton/spack/var/spack/repos/builtin/packages/python/package.py", line 1045, in libs
    if os.path.exists(os.path.join(libdir, ldlibrary)):
KeyError: 'BINDIR'
==> [2022-04-29-12:05:51.468317] Flagging wonton-1.3.2-vhxchjmeut54oavecflvd3qppcigz4bt as failed: KeyError: 'BINDIR'
==> [2022-04-29-12:05:51.489271] ChildError: KeyError: 'BINDIR'
```

### Information on your system

```
* **Spack:** 0.18.0.dev0 (49355fe5ba25771d3cc1e5e5e1f27a792cdefa40)
* **Python:** 3.9.5
* **Platform:** linux-rhel8-skylake_avx512
* **Concretizer:** clingo
```

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have searched the issues of this repo and believe this is not a duplicate
- [X] I have run the failing commands in debug mode and reported the output


Discussion:
@adamjstewart 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -943,6 +943,7 @@ def config_vars(self):
             version = self.version.up_to(2)
             config = {
                 # get_config_vars
+                'BINDIR': self.prefix.bin,
                 'CC': 'cc',
                 'CXX': 'c++',
                 'INCLUDEPY': self.prefix.include.join('python{}').format(version),


Test patch: