Repository: spack/spack

Issue:
is py-sphinx being treated correctly?
Currently, there are some hard-coded dependencies that don't make sense to me.

1. `py-sphinxconrtrib-websupport` is only a dependency from 1.6 onward:

    > 1.6b3
    > 
    > 3588: No compact (p tag) html output in the i18n document build even when html_compact_lists is True.
    > The make latexpdf from 1.6b1 (for GNU/Linux and Mac OS, using latexmk) aborted earlier in case of LaTeX errors than was the case with 1.5 series, due to hard-coded usage of --halt-on-error option. (refs 3695)
    > [**3683: sphinx.websupport module is not provided by default**](https://github.com/sphinx-doc/sphinx/issues/3683)
    > 3683: Failed to build document if builder.css_file.insert() is called
    > 3714: viewcode extension not taking highlight_code='none' in account
    > 3698: Moving :doc: to std domain broke backwards compatibility
    > 3633: misdetect unreferenced citations

2. `typing` should not be installed unless it is needed; unless it is v1.6.1 (bug).  This library comes with python 3.5.2+.

    - I forget the state of affairs.  Can something like a backport library "self-destruct" if it shouldn't be installed (aka fail out saying "bad dependency backport not necessary") or is the policy to just rage duplicate these?  I've seen quite a few others, e.g. enum34.

3. 1.6.2 is out :smile:

So I'd like to patch with

```py
 # Sphinx 1.6 introduces modularity
 depends_on('py-sphinxcontrib-websupport', when='@1.6:',
            type=('build', 'run'))
# Build dep for 1.6.1 all python (bug), see:
# https://github.com/sphinx-doc/sphinx/pull/3789
depends_on('py-typing', when='@1.6.1', type=('build', 'run'))
depends_on('py-typing', when='@1.6.2:^python@2.7:3.4',
           type=('build', 'run'))
```

And add `version('1.6.2', 'a5f613e2b807c1f8c6cdd985a3d909f1')`, but I'm not sure what's going on with 1 and 2 (why `websupport` is gone now and how things move from `sphinx` to `sphinxcontrib`)...


Discussion:
1. Sounds good to me. A lot of people who add Python packages (myself included) add all dependencies for the latest version only. If the dependencies change or the minimum required version is bumped, we bump it for all versions, not just the latest version. Otherwise:
```python
depends_on('py-foo@1.2.3:')
```
becomes:
```python
depends_on('py-foo@1.2.3:', when='@2.4')
depends_on('py-foo@1.2.2:', when='@2.3')
depends_on('py-foo@1.2.1:', when='@2.2')
...
```
So your method is more correct, we've just been lazy about this in the past.

2. I'm not sure if this will work. This will probably end up being the same bug we've circled around before, where:
```python
depends_on('py-typing', when='^python@2.7:3.4')
```
will throw an error message. This is a known concretization bug. Spack looks at a package and determines its dependencies. Unfortunately, it doesn't decide on the version of those dependencies until after it decides what is required. So we won't know what version of `python` it is using until it is too late (at least that's my understanding). If you explicitly ask for `spack install py-sphinx ^python@2.7.12`, it will work, but if you don't specify the Python version it won't. To solve this, the new concretizer will have to backtrack the DAG multiple times, which we currently aren't doing. @tgamblin can explain more.

3. 👍 
Ok so basically I want to do

```py
# Sphinx 1.6 introduces modularity
# TODO: incorporate the proper dependencies when concretizer is capable
# depends_on('py-sphinxcontrib-websupport', when='@1.6:',
#             type=('build', 'run'))
# Build dep for 1.6.1 all python (bug), see:
# https://github.com/sphinx-doc/sphinx/pull/3789
# depends_on('py-typing', when='@1.6.1', type=('build', 'run'))
# depends_on('py-typing', when='@1.6.2:^python@2.7:3.4',
#            type=('build', 'run'))
depends_on('py-sphinxcontrib-websupport', type=('build', 'run'))
depends_on('py-typing', type=('build', 'run'))
```

???

Also I'm going to skip 1.6.2 in lieu of 1.6.3 which is the current version `pip` will install.
You can still incorporate the websupport logic. I think it's only dependencies of dependencies that the concretizer can't handle.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-sphinx/package.py b/var/spack/repos/builtin/packages/py-sphinx/package.py
--- a/var/spack/repos/builtin/packages/py-sphinx/package.py
+++ b/var/spack/repos/builtin/packages/py-sphinx/package.py
@@ -40,6 +40,7 @@ class PySphinx(PythonPackage):
         'sphinx.environment.collectors', 'sphinx.environment.adapters'
     ]
 
+    version('1.6.3', 'c5ad61f4e0974375ca2c2b58ef8d5411')
     version('1.6.1', '26cb1cdca7aa4afc8c925d926b6268e7')
     version('1.5.5', 'f9581b3556df9722143c47290273bcf8')
     version('1.4.5', '5c2cd2dac45dfa6123d067e32a89e89a')
@@ -63,10 +64,20 @@ class PySphinx(PythonPackage):
     depends_on('py-alabaster@0.7.0:0.7.999',  type=('build', 'run'))
     depends_on('py-imagesize', when='@1.4:',  type=('build', 'run'))
     depends_on('py-requests@2.0.0:',          type=('build', 'run'))
-    depends_on('py-typing',                   type=('build', 'run'))
-    depends_on('py-sphinxcontrib-websupport', type=('build', 'run'))
     depends_on('py-sphinx-rtd-theme@0.1:',    type=('build', 'run'))  # optional as of 1.4
 
+    # Sphinx v1.6+ no longer includes websupport by default:
+    # http://www.sphinx-doc.org/en/stable/changes.html
+    depends_on('py-sphinxcontrib-websupport', when='@1.6:',
+               type=('build', 'run'))
+    # TODO: incorporate the proper dependencies when concretizer is capable
+    # Build dep for 1.6.1 all python (bug), see:
+    # https://github.com/sphinx-doc/sphinx/pull/3789
+    # depends_on('py-typing', when='@1.6.1', type=('build', 'run'))
+    # depends_on('py-typing', when='@1.6.2:^python@2.7:3.4',
+    #            type=('build', 'run'))
+    depends_on('py-typing', when='@1.6:', type=('build', 'run'))
+
     # TODO: Add a 'test' deptype
     # depends_on('py-pytest',     type='test')
     # depends_on('py-mock',       type='test')


Test patch: