Repository: spack/spack

Issue:
py-cutadapt: depends_on version range not handled properly
@glennpj I'm rusty on my package writing, but I think this is okay form to indicate a range of package dependency:

https://github.com/spack/spack/blob/09aae616c760a3abb782aa3353c3476851b6a590/var/spack/repos/builtin/packages/py-cutadapt/package.py#L32

(this `@x.y.1:x.y.999` workaround is condoned in #8957)

But when I try to install py-cutadapt, it fails:
```
⟫ spack install py-cutadapt@2.10                                                                                                                                                         
==> Warning: Missing a source id for py-xopen@0.8.999
==> Installing py-xopen-0.8.999-j7fo3zvjqzijaf5iapx5bkpt7m5jhyod
==> No binary for py-xopen-0.8.999-j7fo3zvjqzijaf5iapx5bkpt7m5jhyod found: installing from source
==> Warning: There is no checksum on file to fetch py-xopen@0.8.999 safely.
==>   Fetch anyway? [y/N] y
==> Fetching https://pypi.io/packages/source/x/xopen/xopen-0.8.999.tar.gz
######################################################################## 100.0%
curl: (22) The requested URL returned error: 404 Not Found
==> Error: FetchError: All fetchers failed
```

`py-xopen@0.8.999`, not surprisingly, is not a valid release number.  And the spec clearly shows it expects to find `py-xopen@0.8.999` (see last line):

```
⟫ spack spec py-cutadapt@2.10                                                                                                                                                        
Input spec
--------------------------------
py-cutadapt@2.10

Concretized
--------------------------------
py-cutadapt@2.10%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
    ^py-dnaio@0.4.2%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
        ^py-setuptools@50.3.2%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
            ^python@3.8.6%gcc@8.4.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib patches=0d98e93189bc278fbc37a50ed7f183bd8aaf249a8e1670a465f0db6bb4f8cf87 arch=linux-ubuntu14.04-broadwell
                ^bzip2@1.0.8%gcc@8.4.0+shared arch=linux-ubuntu14.04-broadwell
                    ^diffutils@3.7%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                        ^libiconv@1.16%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                ^expat@2.2.10%gcc@8.4.0+libbsd arch=linux-ubuntu14.04-broadwell
                    ^libbsd@0.10.0%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                ^gdbm@1.18.1%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                    ^readline@8.0%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                        ^ncurses@6.2%gcc@8.4.0~symlinks+termlib arch=linux-ubuntu14.04-broadwell
                            ^pkgconf@1.7.3%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                ^gettext@0.21%gcc@8.4.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-ubuntu14.04-broadwell
                    ^libxml2@2.9.10%gcc@8.4.0~python arch=linux-ubuntu14.04-broadwell
                        ^xz@5.2.5%gcc@8.4.0~pic arch=linux-ubuntu14.04-broadwell
                        ^zlib@1.2.11%gcc@8.4.0+optimize+pic+shared arch=linux-ubuntu14.04-broadwell
                    ^tar@1.32%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                ^libffi@3.3%gcc@8.4.0 patches=26f26c6f29a7ce9bf370ad3ab2610f99365b4bdd7b82e7c31df41a3370d685c0 arch=linux-ubuntu14.04-broadwell
                ^libuuid@1.0.3%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                ^openssl@1.1.1h%gcc@8.4.0+systemcerts arch=linux-ubuntu14.04-broadwell
                    ^perl@5.32.0%gcc@8.4.0+cpanm+shared+threads arch=linux-ubuntu14.04-broadwell
                        ^berkeley-db@18.1.40%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
                ^sqlite@3.33.0%gcc@8.4.0+column_metadata+fts~functions~rtree arch=linux-ubuntu14.04-broadwell
        ^py-setuptools-scm@4.1.2%gcc@8.4.0~toml arch=linux-ubuntu14.04-broadwell
        ^py-xopen@0.8.999%gcc@8.4.0 arch=linux-ubuntu14.04-broadwell
```

Debug report:
```
⟫ spack debug report
* **Spack:** 0.16.0
* **Python:** 3.4.3
* **Platform:** linux-ubuntu14.04-broadwell
* **Concretizer:** original
```


Discussion:
PS. My usual shout out to @hartzell in hopes of an easy fix?
Oh, nevermind, I just realized my problem:

> ### Prerequisites
Spack has the following minimum requirements, which must be installed before Spack is run:
* Python 2 (2.6 or 2.7) or **3 (3.5 - 3.9)** to run Spack

sorry for the chatter!
Oh, double nevermind.  I still get the same error with a modern Python3.

```
$ spack debug report
* **Spack:** 0.16.0
* **Python:** 3.8.1
* **Platform:** linux-ubuntu14.04-broadwell
* **Concretizer:** original
```
If you didn't modify the `py-xopen` package locally, then it doesn't have any version in that range:

https://github.com/spack/spack/blob/badf3368ad863fd0b7b81a45e14d8302490a4e29/var/spack/repos/builtin/packages/py-xopen/package.py#L18-L21

Spack selects the highest possible version since there's not a known one that can satisfy the constraint. If that's the case I'd say this is not an issue.
Ah, I didn't notice the py-xopen lacked the right version to satisfy this py-cutadapt.  (I should have!)

I will submit a PR to add version 0.8.4 to py-xopen.

Thank you!

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-xopen/package.py b/var/spack/repos/builtin/packages/py-xopen/package.py
--- a/var/spack/repos/builtin/packages/py-xopen/package.py
+++ b/var/spack/repos/builtin/packages/py-xopen/package.py
@@ -15,7 +15,9 @@ class PyXopen(PythonPackage):
     homepage = "https://github.com/marcelm/xopen"
     url      = "https://pypi.io/packages/source/x/xopen/xopen-0.1.1.tar.gz"
 
+    version('1.0.1', sha256='79d7e425fb0930b0153eb6beba9a540ca3e07ac254ca828577ad2e8fa24105dc')
     version('0.9.0', sha256='1e3918c8a5cd2bd128ba05b3b883ee322349219c99c305e10114638478e3162a')
+    version('0.8.4', sha256='dcd8f5ef5da5564f514a990573a48a0c347ee1fdbb9b6374d31592819868f7ba')
     version('0.8.2', sha256='003749e09af74103a29e9c64c468c03e084aa6dfe6feff4fe22366679a6534f7')
     version('0.5.0', sha256='b097cd25e8afec42b6e1780c1f6315016171b5b6936100cdf307d121e2cbab9f')
     version('0.1.1', sha256='d1320ca46ed464a59db4c27c7a44caf5e268301e68319f0295d06bf6a9afa6f3')


Test patch: