gplugin/gplugin

Parents 84288a17a5b8
Children 6fab4ebf3aeb
Python3 has started shipping multiple pc files so we need to check for all of them similar to lua.

Testing Done:
Ran on debian unstable with python3.10 and python3.9 installed. pygobject doesn't current work with python3.10 according to the test output but python3.9 worked fine.

```
Dependency pygobject-3.0 found: YES 3.38.0 (cached)
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency python-3.10-embed found: YES 3.10
Checking if "Python3 GI" with dependencies glib-2.0, python-3.10-embed, pygobject-3.0 runs: NO (255)
Message: pygobject does not work with python-3.10-embed
Run-time dependency python-3.9-embed found: YES 3.9
Checking if "Python3 GI" with dependencies glib-2.0, python-3.9-embed, pygobject-3.0 runs: YES
```

Reviewed at https://reviews.imfreedom.org/r/832/
--- a/python3/meson.build Fri Jul 23 04:07:52 2021 -0500
+++ b/python3/meson.build Fri Jul 23 16:48:23 2021 -0500
@@ -16,19 +16,45 @@
'gplugin-python3-utils.h',
]
- PYTHON3 = dependency('python3-embed', version: '>=3.5.0', required: false)
- if not PYTHON3.found()
- PYTHON3 = dependency('python3', version: '>=3.5.0')
- endif
-
PYGOBJECT = dependency('pygobject-3.0', version: '>=3.0.0')
- # Compile and run our python-gi test program
- python3_gi_test = compiler.run(files('gplugin-python3-test-pygobject.c'),
- dependencies : [GLIB, PYTHON3, PYGOBJECT],
- name : 'Python3 GI')
- if not python3_gi_test.compiled() or python3_gi_test.returncode() != 0
- error('pygobject does not work with Python3')
+ _PYTHONS = [
+ ['python-3.10-embed', '>=3.10'],
+ ['python-3.9-embed', '>=3.9'],
+ ['python-3.8-embed', '>=3.8'],
+ ['python3-embed', '>=3.8'],
+ ['python3', '>=3.8'],
+ ['python-3.7', '>=3.7'],
+ ['python-3.7m', '>=3.7'],
+ ['python-3.6', '>=3.6'],
+ ['python-3.6m', '>=3.6'],
+ ]
+ PYTHON_FOUND = false
+ PYGOBJECT_WORKS = false
+ foreach _PYTHON : _PYTHONS
+ PYTHON3 = dependency(_PYTHON[0], version : _PYTHON[1], required : false)
+ if PYTHON3.found()
+ PYTHON_FOUND = true
+
+ python3_gi_test = compiler.run(files('gplugin-python3-test-pygobject.c'),
+ dependencies : [GLIB, PYTHON3, PYGOBJECT],
+ name : 'Python3 GI')
+ if not python3_gi_test.compiled() or python3_gi_test.returncode() != 0
+ message('pygobject does not work with @0@'.format(_PYTHON[0]))
+ continue
+ endif
+
+ PYGOBJECT_WORKS = true
+ break
+ endif
+ endforeach
+
+ if not PYTHON_FOUND
+ error('failed to find a usable python')
+ endif
+
+ if not PYGOBJECT_WORKS
+ error('found a usable python but pygobject does not work with it')
endif
# Now add our libraries