From 252a5bd71b1e5edc977c16e6bc420eb2a791fc2c Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 10 May 2024 10:47:37 +0200 Subject: [PATCH] PythonExtension: fix issue where package does not extend python (#44109) --- lib/spack/spack/build_systems/python.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/spack/spack/build_systems/python.py b/lib/spack/spack/build_systems/python.py index c94e2db700..0f99fe536a 100644 --- a/lib/spack/spack/build_systems/python.py +++ b/lib/spack/spack/build_systems/python.py @@ -120,12 +120,6 @@ def skip_modules(self) -> Iterable[str]: """ return [] - @property - def python_spec(self): - """Get python-venv if it exists or python otherwise.""" - python, *_ = self.spec.dependencies("python-venv") or self.spec.dependencies("python") - return python - def view_file_conflicts(self, view, merge_map): """Report all file conflicts, excepting special cases for python. Specifically, this does not report errors for duplicate @@ -146,8 +140,12 @@ def view_file_conflicts(self, view, merge_map): def add_files_to_view(self, view, merge_map, skip_if_exists=True): # Patch up shebangs if the package extends Python and we put a Python interpreter in the # view. - python = self.python_spec - if not self.extendee_spec or python.external: + if not self.extendee_spec: + return super().add_files_to_view(view, merge_map, skip_if_exists) + + python, *_ = self.spec.dependencies("python-venv") or self.spec.dependencies("python") + + if python.external: return super().add_files_to_view(view, merge_map, skip_if_exists) # We only patch shebangs in the bin directory. @@ -368,6 +366,12 @@ def list_url(cls) -> Optional[str]: # type: ignore[override] return f"https://pypi.org/simple/{name}/" return None + @property + def python_spec(self): + """Get python-venv if it exists or python otherwise.""" + python, *_ = self.spec.dependencies("python-venv") or self.spec.dependencies("python") + return python + @property def headers(self) -> HeaderList: """Discover header files in platlib."""