# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2

# The configuration in this "shared" section are the things that each job will
# have in common, and are substituted into the jobs config below. It is the
# job definitions that specify the things that are unique to each job (like
# the Python version to use, via the docker image name).
shared: &shared
    working_directory: ~/repo

    steps:
        - checkout
        - run:
            name: checkout submodules
            command: |
                git submodule sync
                git submodule update --init --recursive

        - run:
            name: install apt packages
            command: |
                sudo apt-get update
                sudo apt-get install -y libgtk-3-dev libjpeg-dev libtiff-dev \
                        libsdl2-dev libgstreamer-plugins-base1.0-dev libnotify-dev \
                        libsm-dev libwebkit2gtk-4.0-dev libxtst-dev \
                        libgl1-mesa-dev libglu1-mesa-dev python-virtualenv

        - run:
            name: install python packages
            command: |
                $MAKE_VENV
                source venv/bin/activate
                pip install -r requirements.txt

        - run:
            name: build wxWidgets
            command: |
                source venv/bin/activate
                python build.py --jobs=4 dox build_wx

        - run:
            name: build wxPython
            command: |
                source venv/bin/activate
                python build.py --jobs=4 etg --nodoc sip build_py

        - run:
            name: build wheel and test install
            command: |
                source venv/bin/activate
                python build.py bdist_wheel
                python build.py install
                python -c "import wx; print(wx.version())"


# We use one job for each version of Python that we want to build with. Each
# one gets its own copy of the shared config above.
jobs:
    "Python-2.7":
        <<: *shared
        docker:
            - image: circleci/python:2.7
        environment:
            - MAKE_VENV: "python -m virtualenv venv"

    "Python-3.5":
        <<: *shared
        docker:
            - image: circleci/python:3.5
        environment:
            - MAKE_VENV: "python -m venv venv"

    "Python-3.6":
        <<: *shared
        docker:
            - image: circleci/python:3.6
        environment:
            - MAKE_VENV: "python -m venv venv"

    "Python-3.7":
        <<: *shared
        docker:
            - image: circleci/python:3.7
        environment:
            - MAKE_VENV: "python -m venv venv"


# This workflow defines the jobs that comprise the "build" task. The jobs will
# be run in parallel.
workflows:
  version: 2
  build:
    jobs:
      - "Python-2.7"
      - "Python-3.5"
      - "Python-3.6"
      - "Python-3.7"
