I have a CPython C ++ module with C ++ 11 code, but I cannot build on Travis-ci

This project works fine on my local Ubuntu 12.04 and Mac OSX 10.10 (with fink python). I can't figure out how to configure .travis.yml to get .cpp files for building with g ++ - 4.8 (4.9 or 5.x) would be nice too.

Project: https://github.com/schwehr/libais

My recent unsuccessful attempt:

language: python

python:
  - "2.7"
  - "3.4"

before_install:
  - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
  - sudo apt-get update -qq
  - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi

install:
  - sudo apt-get install -qq gcc-4.8 g++-4.8
  - python setup.py install

script:
  - python setup.py test 

gives:

gcc -pthread -fno-strict-aliasing -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/python/2.7.9/include/python2.7 -c src/libais/ais_py.cpp -o build/temp.linux-x86_64-2.7/src/libais/ais_py.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
cc1plus: error: unrecognized command line option ‘-std=c++11

The key part of my setup.py:

EXTRA_COMPILE_ARGS = []
if sys.platform in ('darwin', 'linux', 'linux2'):
    EXTRA_COMPILE_ARGS = ['-std=c++11']

AIS_MODULE = Extension(
    '_ais',
    extra_compile_args=EXTRA_COMPILE_ARGS,
+4
source share
1 answer

Thanks to Dominica. I tried typing things and it was helpful. This made me think that I could just get explicit and force python to use the correct compiler. This makes it easier to see what is happening.

install:
  - sudo apt-get install -qq gcc-4.8 g++-4.8
  - CC=g++-4.8 python setup.py install

What works.

+3
source

Source: https://habr.com/ru/post/1589251/


All Articles