 # CI configuration for Windows tests on appveyor
 # Based on Olivier Grisel's python-appveyor-demo
environment:
  global:
    # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
    # /E:ON and /V:ON options are not enabled in the batch script intepreter
    # See: http://stackoverflow.com/a/13751649/163740
    CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\dev\\continuous-integration\\appveyor\\run_with_env.cmd"
  BINSTAR_TOKEN:
    secure: mP9XvwSNUqxq7cFK4V0wM2rNmvlGUYecSlZvkYjRtdGotr9ueS2IycSDvvNGlSdK

  matrix:
    - PYTHON: "C:\\Miniconda3"
      PYTHON_VERSION: "3.4"
      PYTHON_ARCH: "32"
      platform: x86
      STANDALONE: "FALSE"
      CONDA_PY: "34"
      CONDA_BUILD: "TRUE"
      SPLIT_RUN: "FALSE"

    - PYTHON: "C:\\Miniconda3-x64"
      PYTHON_VERSION: "3.4"
      PYTHON_ARCH: "64"
      platform: x64
      STANDALONE: "FALSE"
      CONDA_PY: "34"
      CONDA_BUILD: "TRUE"
      SPLIT_RUN: "FALSE"

    - PYTHON: "C:\\Miniconda35"
      PYTHON_VERSION: "3.5"
      PYTHON_ARCH: "32"
      platform: x86
      STANDALONE: "FALSE"
      CONDA_PY: "35"
      CONDA_BUILD: "TRUE"
      SPLIT_RUN: "FALSE"

    - PYTHON: "C:\\Miniconda35-x64"
      PYTHON_VERSION: "3.5"
      PYTHON_ARCH: "64"
      platform: x64
      STANDALONE: "FALSE"
      CONDA_PY: "35"
      CONDA_BUILD: "TRUE"
      SPLIT_RUN: "FALSE"

    - PYTHON: "C:\\Miniconda"
      PYTHON_VERSION: "2.7"
      PYTHON_ARCH: "32"
      platform: x86
      STANDALONE: "FALSE"
      CONDA_PY: "27"
      CONDA_BUILD: "TRUE"
      SPLIT_RUN: "1"

    - PYTHON: "C:\\Miniconda"
      PYTHON_VERSION: "2.7"
      PYTHON_ARCH: "32"
      platform: x86
      STANDALONE: "FALSE"
      CONDA_BUILD: "FALSE"
      SPLIT_RUN: "2"

    - PYTHON: "C:\\Miniconda-x64"
      PYTHON_VERSION: "2.7"
      PYTHON_ARCH: "64"
      platform: x64
      STANDALONE: "FALSE"
      CONDA_PY: "27"
      CONDA_BUILD: "TRUE"
      SPLIT_RUN: "1"

    - PYTHON: "C:\\Miniconda-x64"
      PYTHON_VERSION: "2.7"
      PYTHON_ARCH: "64"
      platform: x64
      STANDALONE: "FALSE"
      CONDA_BUILD: "FALSE"
      SPLIT_RUN: "2"

    - PYTHON: "C:\\Miniconda"
      PYTHON_VERSION: "2.7"
      PYTHON_ARCH: "32"
      platform: x86
      STANDALONE: "TRUE"

    - PYTHON: "C:\\Miniconda-x64"
      PYTHON_VERSION: "2.7"
      PYTHON_ARCH: "64"
      platform: x64
      STANDALONE: "TRUE"

install:
  # Add the paths
  - 'set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%'
  # Create a new environment with the exact Python version and activate it
  - 'conda create --yes --quiet -n appveyor_test python=%PYTHON_VERSION%'
  - 'activate appveyor_test'

  # Check that we have the expected version and architecture for Python
  - 'python --version'
  - 'python -c "import struct; print(struct.calcsize(''P'') * 8)"'

  # Install the build dependencies of the project via conda
  - 'conda install --yes --quiet numpy scipy nose sphinx sympy pyparsing jinja2 ipython setuptools cython'
  - 'conda install --yes --quiet -c brian-team py-cpuinfo'

build: false  # Not a C# project, build stuff at the test step instead.

test_script:
  # Run the test suite
  - '%CMD_IN_ENV% python -c "import sys; print(sys.executable)"'
  - '%CMD_IN_ENV% python setup.py install'
  - 'set SRC_DIR=%CD%'
  - 'cd \'
  # Since "CMD_IN_ENV" assumes we are in the source directory we cannot use it
  # here. We therefore copy its content and use the correct path
  - 'cmd /E:ON /V:ON /C %SRC_DIR%\dev\continuous-integration\appveyor\run_with_env.cmd python %SRC_DIR%\dev\continuous-integration\run_test_suite.py'

after_test:
  - 'IF "%CONDA_BUILD%" == "TRUE" (
          pip install wheel &&
          cd %SRC_DIR% &&
          %CMD_IN_ENV% python setup.py bdist_wheel &&
          %CMD_IN_ENV% python setup.py bdist_wininst &&
          deactivate &&
          %CMD_IN_ENV% conda install --yes --quiet conda-build anaconda-client pip &&
          %CMD_IN_ENV% conda build --quiet -c brian-team dev\conda-recipe --numpy 1.9 &&
          %CMD_IN_ENV% conda build --quiet -c brian-team dev\conda-recipe --numpy 1.10 &&
          %CMD_IN_ENV% conda build --quiet -c brian-team dev\conda-recipe --numpy 1.11 &&
          %CMD_IN_ENV% python dev\continuous-integration\move-conda-package.py dev\conda-recipe &&
          if "%APPVEYOR_PULL_REQUEST_NUMBER%" == "" if "%APPVEYOR_REPO_NAME%" == "brian-team/brian2" if "%APPVEYOR_REPO_BRANCH%" == "master" %CMD_IN_ENV% python dev\continuous-integration\conda-server-push.py
     )'

artifacts:
  # Archive the generated conda package in the ci.appveyor.com build report.
  - path: '*.tar.bz2'
    name: conda package
  - path: dist\*
    name: PyPI binaries
