gcc-python-plugin
gcc-python-plugin copied to clipboard
Travis: generalize matrix to cover python versions as well as gcc versions
Ideally we'd test for the matrix of all supported gcc versions vs all supported Python versions.
(Help with this would be appreciated!)
I've looked into this, and got as far as https://github.com/davidmalcolm/gcc-python-plugin/pull/147.
I managed to specify a 2 by 2 matrix using dimensions env and python:
os:
- linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8 gcc-4.8-plugin-dev g++-8 gcc-8-plugin-dev
env:
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
language: python
python:
- "2.7"
- "3.6"
before_install:
- eval "${MATRIX_EVAL}"
install:
- pip install six pygments graphviz lxml
script: make CC=$CC CXX=$CXX
So, there are 4 builds, and I run into two errors:
- 4.8/8 and 2.7: Runs into "ImportError: cannot import name _remove_dead_weakref"
- 4.8/8 and 3.6: Runs into "/usr/bin/ld: cannot find -lpython3.6m" when linking python.so
Both seem be problems with the virtualenv that is setup for python, but I don't know how to fix these.
So, there are 4 builds, and I run into two errors:
* 4.8/8 and 2.7: Runs into "ImportError: cannot import name _remove_dead_weakref" * 4.8/8 and 3.6: Runs into "/usr/bin/ld: cannot find -lpython3.6m" when linking python.so
Both seem be problems with the virtualenv that is setup for python, but I don't know how to fix these.
I think I managed to fix/workaround this.
On my opensuse leap laptop, we have:
$ python-config --ldflags
-lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic
$ python2-config --ldflags
-lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic
$ python3-config --ldflags
-L/usr/lib64 -lpython3.6m -lpthread -ldl -lutil -lm -Xlinker -export-dynamic
but if I start up an virtualenv with python3, I get:
$ virtualenv -p python3 tmp
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/vries/tmp/bin/python3
Also creating executable in /home/vries/tmp/bin/python
Installing setuptools, pip, wheel...done.
$ . ./tmp/bin/activate
(tmp) $ python-config --ldflags
-lpython3.6m -lpthread -ldl -lutil -lm -Xlinker -export-dynamic
So, it seems the virtualenv drops the " -L/usr/lib64" for some reason.
The patch below adds it back, and allows us have a reasonable testrun:
diff --git a/Makefile b/Makefile
index daa7419..d83404a 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,8 @@ PYTHON_CONFIG=python-config
#PYTHON_CONFIG=python3.3dm-config
PYTHON_INCLUDES=$(shell $(PYTHON_CONFIG) --includes)
-PYTHON_LIBS=$(shell $(PYTHON_CONFIG) --libs)
+PYTHON_LIBPL=$(shell $(PYTHON) -c "import sysconfig; print(sysconfig.get_config_var('LIBPL'))")
+PYTHON_LIBS=$(shell $(PYTHON_CONFIG) --ldflags; $(PYTHON_CONFIG) --libs; echo "-L$(PYTHON_LIBPL)"; )
# Support having multiple named plugins
# e.g. "python2.7" "python3.2mu" "python 3.2dmu" etc:
@davidmalcolm
Please take a look at:
- https://travis-ci.com/vries/gcc-python-plugin/builds/86787194
- https://github.com/vries/gcc-python-plugin/tree/travis-yml-python-v12
Can you take it from here?
Thanks, Tom