From e7112fbc6a87eed2c602fb2e7f615710715c832f Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 10 May 2024 10:47:37 +0200 Subject: 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 @@ class PythonExtension(spack.package_base.PackageBase): """ 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 @@ class PythonExtension(spack.package_base.PackageBase): 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 @@ class PythonPackage(PythonExtension): 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.""" -- cgit v1.2.3-70-g09d2