How to use python 3 as a build script in non-python travis configuration? How to use python 3 as a build script in non-python travis configuration? python python

How to use python 3 as a build script in non-python travis configuration?


If you want to use the container based infrastructure you can make use of the apt addon:

addons:  apt:    sources:      - deadsnakes # source required so it finds the package definition below    packages:      - python3.5

Packages that can be used are listed here

Update

In order to use dependencies with c-extensions like psycopg2 or pyYAML it is also necessary to add python3.4-dev


You should be able to just install the needed python3 packages by adding a before_install: section of your .travis.yml:

before_install:- sudo apt-get update- sudo apt-get install python3


Travis uses pyenv to manage its Python, and has both Python 2.7.16 and 3.6.3 installed by default at the time of writing. You can use pyenv global 3.6 to use Python 3.6.3; you don't need root for this.

This is the easiest and fastest way to get a Python 3 and useful in cases where you don't require a specific Python 3 version (e.g. for a build script or the like). If you want specific Python versions and/or a build matrix then installing it as a package or addon as mentioned in some of the other answers is probably faster and easier.