Repository: spack/spack

Issue:
Installation issue:  aocl-sparse  - inconsistent dependency logic
### Steps to reproduce the issue

@amd-toolchain-support, I found an issue with the dependencies of the aocl-sparse package. That causes it to fail when installing aocl-sparse@4.0 now that 4.1 is available. 

To reproduce: 
```
# spack install aocl-sparse@4.0
```






### Error message

<details><summary>Error: KeyError: 'No spec with name amdblis in aocl-sparse@=4.0</summary>
<pre>
==> aocl-sparse: Executing phase: 'cmake'                                                                                       
==> Error: KeyError: 'No spec with name amdblis in aocl-sparse@=4.0%gcc@=13.1.0~benchmarks~examples~ilp64~ipo+shared~unit_tests 
build_system=cmake build_type=Release generator=make arch=linux-rhel9-zen2 ^[deptypes=build] cmake@=3.27.7%gcc@=13.1.0~doc+ncurs
es+ownlibs build_system=generic build_type=Release arch=linux-rhel9-zen2 ^[deptypes=build,link] curl@=8.4.0%gcc@=11.3.1~gssapi~l
dap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-rhel9-zen2 ^[deptype
s=build] gmake@=4.3%gcc@=11.3.1~guile build_system=generic patches=599f134 arch=linux-rhel9-zen2 ^[deptypes=build] gmake@=4.3%gc
c@=13.1.0~guile build_system=generic patches=599f134 arch=linux-rhel9-zen2 ^[deptypes=build,link] ncurses@=6.4%gcc@=13.1.0~symli
nks+termlib abi=none build_system=autotools arch=linux-rhel9-zen2 ^[deptypes=build,link] nghttp2@=1.57.0%gcc@=11.3.1 build_syste
m=autotools arch=linux-rhel9-zen2 ^[deptypes=build,link] openssl@=3.0.7%aocc@=4.1.0~docs+shared build_system=generic certs=mozil
la arch=linux-rhel9-zen2 ^[deptypes=build virtuals=pkgconfig] pkgconf@=1.7.3%gcc@=11.3.1 build_system=autotools arch=linux-rhel9
-zen2 ^[deptypes=build,link virtuals=zlib-api] zlib-ng@=2.1.4%gcc@=13.1.0+compat+opt build_system=autotools arch=linux-rhel9-zen
2'                                                                                                                              
                                                                                                                                
/usr/lynx/spack/var/spack/repos/builtin/packages/aocl-sparse/package.py:101, in cmake_args:                                     
         98            args.append(self.define_from_variant("BUILD_ILP64", "ilp64"))                                            
         99                                                                                                                     
        100        if self.spec.satisfies("@4.0:"):                                                                             
  >>    101            args.append("-DAOCL_BLIS_LIB=" + str(self.spec["amdblis"].libs))                                         
        102            args.append(                                                                                             
        103                "-DAOCL_BLIS_INCLUDE_DIR={0}/blis".format(self.spec["amdblis"].prefix.include)                       
        104            )        

See build log for details:      
  /tmp/root/spack-stage/spack-stage-aocl-sparse-4.0-pcmiqzth5p7qob5dwle6zlhixrbjr56h/spack-build-out.txt
</pre></details>


### Information on your system

* **Spack:** 0.21.1 (e30fedab102f9281a220fb4fae82e3f8c43a82ac)
* **Python:** 3.9.16
* **Platform:** linux-rhel9-zen2
* **Concretizer:** clingo
 


### Additional information

With the help of @scheibelp, we found there is an inconsistency with the depedency logic in the package.py file. 


In one spot, it specifies @4.1:

```
depends_on("amdblis", when="@4.1:")
```

But  then later on there's related code that depends on @4.0: instead: 

```
if self.spec.satisfies("@4.0:"):
            args.append("-DAOCL_BLIS_LIB=" + str(self.spec["amdblis"].libs))
            args.append(
                "-DAOCL_BLIS_INCLUDE_DIR={0}/blis".format(self.spec["amdblis"].prefix.include)
            )
            args.append("-DAOCL_LIBFLAME=" + str(self.spec["amdlibflame"].libs))
            args.append(
                "-DAOCL_LIBFLAME_INCLUDE_DIR={0}".format(self.spec["amdlibflame"].prefix.include)
            )
```

Changing the argument of self.spec.satisfies from @4.0 to @4.1 fixes the problem. Here's the patch of my fix: 

diff --git a/var/spack/repos/builtin/packages/aocl-sparse/package.py b/var/spack/repos/builtin/packages/aocl-sparse/package.py
index 7adf7eda..37c9090b 100644
--- a/var/spack/repos/builtin/packages/aocl-sparse/package.py
+++ b/var/spack/repos/builtin/packages/aocl-sparse/package.py
@@ -97,7 +97,7 @@ def cmake_args(self):
         if spec.satisfies("@3.0:"):
             args.append(self.define_from_variant("BUILD_ILP64", "ilp64"))
 
-        if self.spec.satisfies("@4.0:"):
+        if self.spec.satisfies("@4.1:"):
             args.append("-DAOCL_BLIS_LIB=" + str(self.spec["amdblis"].libs))
             args.append(
                 "-DAOCL_BLIS_INCLUDE_DIR={0}/blis".format(self.spec["amdblis"].prefix.include)



[spack-build-env.txt](https://github.com/spack/spack/files/14604807/spack-build-env.txt)
[spack-build-env-mods.txt](https://github.com/spack/spack/files/14604808/spack-build-env-mods.txt)
[spack-build-01-cmake-out.txt](https://github.com/spack/spack/files/14604809/spack-build-01-cmake-out.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/14604810/spack-build-out.txt)

### 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:
Should have put pre tags around that patch so it rendered correctly. Here it s again: 

  ```
  diff --git a/var/spack/repos/builtin/packages/aocl-sparse/package.py b/var/spack/repos/builtin/packages/aocl-sparse/package.py
index 7adf7eda..37c9090b 100644
--- a/var/spack/repos/builtin/packages/aocl-sparse/package.py
+++ b/var/spack/repos/builtin/packages/aocl-sparse/package.py
@@ -97,7 +97,7 @@ def cmake_args(self):
         if spec.satisfies("@3.0:"):
             args.append(self.define_from_variant("BUILD_ILP64", "ilp64"))
 
-        if self.spec.satisfies("@4.0:"):
+        if self.spec.satisfies("@4.1:"):
             args.append("-DAOCL_BLIS_LIB=" + str(self.spec["amdblis"].libs))
             args.append(
                 "-DAOCL_BLIS_INCLUDE_DIR={0}/blis".format(self.spec["amdblis"].prefix.include)
```



Resolving patch:
diff --git a/var/spack/repos/builtin/packages/aocl-sparse/package.py b/var/spack/repos/builtin/packages/aocl-sparse/package.py
--- a/var/spack/repos/builtin/packages/aocl-sparse/package.py
+++ b/var/spack/repos/builtin/packages/aocl-sparse/package.py
@@ -108,7 +108,7 @@ def cmake_args(self):
         if spec.satisfies("@3.0:"):
             args.append(self.define_from_variant("BUILD_ILP64", "ilp64"))
 
-        if self.spec.satisfies("@4.0:"):
+        if self.spec.satisfies("@4.1:"):
             args.append(f"-DAOCL_BLIS_LIB={self.spec['amdblis'].libs}")
             args.append(
                 "-DAOCL_BLIS_INCLUDE_DIR={0}/blis".format(self.spec["amdblis"].prefix.include)


Test patch: