Repository: spack/spack

Issue:
Installation issue: geos +python ^python@3 config issues finding python
When installing geos with python3 bindings, it fails in configuration stage complaining about being unable to find the python libraries.  This appears to be due to a few python2-isms in the geos CMake files.

I created a patch file to make the CMake stuff in geos more python3 friendly (the one reported below plus a couple related spots), and when I went to open an issue on the geos upstream site discovered that the SWIG bindings were dropped in @3.9, so this is a bit moot.  But since the work was already done, I figured would push to spack just in case anyone else is interested.

### Steps to reproduce the issue

```console
$ spack install geos +python ^python@3
...
checking for python version... 3.7
checking for python platform... linux
checking for python script directory... ${prefix}/lib/python3.7/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python3.7/site-packages
checking for Python include path... /software/spack-software/2021.04.28/linux-rhel8-x86_64/gcc-8.4.0/python-3.7.7-mhx467yzopgzum7dt76cedvua6wkji3b/include/python3.7m
checking for Python library path...
configure: error: cannot find Python library path
...
```

### Information on your system

```console
$ spack debug report
* **Spack:** 0.16.1-2432-16111354aa
* **Python:** 3.6.8
* **Platform:** linux-rhel8-x86_64
* **Concretizer:** original
```
Spack is using python@3.7.7


### Additional information

* [spack-build-env.txt](https://github.com/spack/spack/files/6437096/spack-build-env.txt)
* [spack-build-out.txt](https://github.com/spack/spack/files/6437097/spack-build-out.txt)

Geos maintainer: @adamjstewart

### General information

<!-- These boxes can be checked by replacing [ ] with [x] or by clicking them after submitting the issue. -->
- [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:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/geos/package.py b/var/spack/repos/builtin/packages/geos/package.py
--- a/var/spack/repos/builtin/packages/geos/package.py
+++ b/var/spack/repos/builtin/packages/geos/package.py
@@ -46,9 +46,16 @@ class Geos(AutotoolsPackage):
     extends('ruby', when='+ruby')
     extends('python', when='+python')
 
+    # SWIG bindings dropped in 3.9, so no python/ruby bindings
+    conflicts('+python', when='@3.9:', msg='SWIG bindings dropped in 3.9')
+    conflicts('+ruby', when='@3.9:', msg='SWIG bindings dropped in 3.9')
+
     # Python 3 is supposedly supported, but I couldn't get it to work
     # https://trac.osgeo.org/geos/ticket/774
     depends_on('python@:2', when='@:3.5')
+    # This patch should fix above issue.
+    # Only tested on 3.8.1, but patch at least applies on 3.5
+    patch('geos_python3_config.patch', when='+python @3.5:3.8.99')
 
     depends_on('swig', type='build', when='+ruby')
     depends_on('swig', type='build', when='+python')


Test patch: