LoginSignup
2
2

More than 5 years have passed since last update.

CircleCI(1.0)でPython2,3を共存させる

Last updated at Posted at 2017-04-20

20171116追記

下記の記述はCircleCI1.0系についての内容です
2.0については全く別の仕組みになっているため当てはまりません

circle.yml

machineセクションでpyenvを両バージョンで書けばOK
対応しているバージョンはこちら

machine:
  post:
    - pyenv global 2.7.11 3.6.1

使用方法

python, pipコマンドの後ろに 3 を付けると3系での実行になる。

ubuntu@box832:~$ python -V
Python 2.7.11
ubuntu@box832:~$ python3 -V
Python 3.6.1
ubuntu@box832:~$ pip -V
pip 7.1.2 from /opt/circleci/python/2.7.11/lib/python2.7/site-packages (python 2.7)
ubuntu@box832:~$ pip3 -V
pip 9.0.1 from /opt/circleci/python/3.6.1/lib/python3.6/site-packages (python 3.6)

ダメなパターン

下記のような指定をすると3系のみの仮想環境で実行されてしまうので2系が必要なコマンド(GAEのappcfg.pyとか)が失敗してしまう。

machine:
  python:
    version: 3.6.1
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2