Repository: spack/spack

Issue:
Installation issue: py-psycopg2 fails to build with python@3.8

### Steps to reproduce the issue
It seems this package fails to build with latest python, 3.8.5. It builds just fine with `python@3.7.8`

```console
$ spack install py-psycopg2
...
==> Installing py-psycopg2
==> No binary for py-psycopg2 found: installing from source
==> Using cached archive: /mnt/local/spack/var/spack/cache/_source-cache/archive/ec/eccf962d41ca46e6326b97c8fe0a6687b58dfc1a5f6540ed071ff1474cea749e.tar.gz
==> py-psycopg2: Executing phase: 'build'
==> Error: ProcessError: Command exited with status 1:
    '/mnt/local/spack/opt/spack/linux-centos7-skylake/gcc-8.3.0/python-3.8.5-vaawtghjfbpb5nws2xfrrrm3252khyuq/bin/python3.8' '-s' 'setup.py' '--no-user-cfg' '
build'

2 errors found in build log:
     54    running build_ext
     55    building 'psycopg2._psycopg' extension
     56    creating build/temp.linux-x86_64-3.8
     57    creating build/temp.linux-x86_64-3.8/psycopg
     58    /mnt/local/spack/lib/spack/env/gcc/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 
           -DPSYCOPG_VERSION=2.7.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=110002 -DHAVE_LO64=1 -I/mnt/local/spack/opt/spack/linux-centos7-skylake/gcc-8.3.0/p
           ython-3.8.5-vaawtghjfbpb5nws2xfrrrm3252khyuq/include/python3.8 -I. -I/mnt/local/spack/opt/spack/linux-centos7-skylake/gcc-8.3.0/postgresql-11.2-6s
           4527k55r2n52g5deyugy437ozlilfb/include -I/mnt/local/spack/opt/spack/linux-centos7-skylake/gcc-8.3.0/postgresql-11.2-6s4527k55r2n52g5deyugy437ozlil
           fb/include/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
     59    psycopg/psycopgmodule.c: In function 'psyco_is_main_interp':
  >> 60    psycopg/psycopgmodule.c:689:18: error: dereferencing pointer to incomplete type 'PyInterpreterState' {aka 'struct _is'}
     61         while (interp->next)
     62                      ^~
     63    
     64    It appears you are missing some prerequisite to build the package from source.
     65    
     66    You may install a binary package by installing 'psycopg2-binary' from PyPI.
     67    If you want to install psycopg2 from source, please install the packages
     68    required for the build and try again.
     69    
     70    For further information please check the 'doc/src/install.rst' file (also at
     71    <http://initd.org/psycopg/docs/install.html>).
     72    
  >> 73    error: command '/mnt/local/spack/lib/spack/env/gcc/gcc' failed with exit status 1

See build log for details:
  /cache/sbulut/spack-stage/spack-stage-py-psycopg2-2.7.5-cyfelqawl25prflqej3ntw5jfwapu3tf/spack-build-out.txt
```

### Information on your system

```
$ spack debug report
* **Spack:** 0.15.4-1050-b272e00
* **Python:** 3.6.8
* **Platform:** linux-centos7-skylake
```

### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/5264050/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:
Latest version builds just fine. Will push a PR soon.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-psycopg2/package.py b/var/spack/repos/builtin/packages/py-psycopg2/package.py
--- a/var/spack/repos/builtin/packages/py-psycopg2/package.py
+++ b/var/spack/repos/builtin/packages/py-psycopg2/package.py
@@ -12,7 +12,10 @@ class PyPsycopg2(PythonPackage):
     homepage = "http://initd.org/psycopg/"
     url = "http://initd.org/psycopg/tarballs/PSYCOPG-2-7/psycopg2-2.7.5.tar.gz"
 
+    version('2.8.6', sha256='fb23f6c71107c37fd667cb4ea363ddeb936b348bbd6449278eb92c189699f543')
     version('2.7.5', sha256='eccf962d41ca46e6326b97c8fe0a6687b58dfc1a5f6540ed071ff1474cea749e')
 
+    depends_on('python@2.7:2.8,3.4:3.8', type=('build', 'run'), when='@2.8:')
+    depends_on('python@2.6:2.8,3.2:3.7', type=('build', 'run'), when='@2.7')
     depends_on('py-setuptools', type='build')
     depends_on('postgresql', type=('build', 'run'))


Test patch: