clone_depth: 50
max_jobs: 8
shallow_clone: true
build:
  parallel: true
  verbosity: minimal

image: Visual Studio 2022

environment:
  global:
    APPVEYOR_SAVE_CACHE_ON_ERROR: "true"
    # 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 interpreter
    # See: http://stackoverflow.com/a/13751649/163740
    CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
    # Use a fixed hash seed for reproducibility
    PYTHONHASHSEED: 8675309
    PYTHONDEVMODE: 1
    PYTHONFAULTHANDLER: 1
    PYTHONUNBUFFERED: 1
    # Try to avoid pulling in the C runtime, as some users won't have the
    # right package.
    GREENLET_STATIC_RUNTIME: "1"
    # Don't get warnings about Python 2 support being deprecated. We
    # know.
    PIP_NO_PYTHON_VERSION_WARNING: 1
    PIP_UPGRADE_STRATEGY: eager
    # Enable this if debugging a resource leak. Otherwise
    # it slows things down.
    # PYTHONTRACEMALLOC: 10
    # Upload settings for twine.
    TWINE_USERNAME: "__token__"
    TWINE_PASSWORD:
      secure: 9JKBIB2o2S18+REaEqzUrP/1g08eRdX3eEa7D/BBN5ae0XHTlrPqbvRTNJceiUa/o3r4bejFF3o0xA69ueMd+09PGKAAAfpQnwnQPInuLVkOq3mprNk4wW0GyWLFzI3WqZhYnWH7PZtmG4Kr7mNOyd6Qdi773kN3Hn7CNhvk+ik/K3zbsGerb2YYloM/KIQSJbgdEqNcIIItoqrZzg/cqiM/47Pz7ZzcGDvevD8Nx/0lVGqFVJnj8cMevwa9iDPYn7fB59Y1GEEbtBjenrWr1Q==

  matrix:
    # http://www.appveyor.com/docs/installed-software#python

    # Fully supported 64-bit versions, with testing. This should be
    # all the current (non EOL) versions.
    - PYTHON: "C:\\Python314-x64"
      PYTHON_VERSION: "3.14.0rc1"
      PYTHON_ARCH: "64"
      PYTHON_EXE: python

    - PYTHON: "C:\\Python313-x64"
      PYTHON_VERSION: "3.13.0"
      PYTHON_ARCH: "64"
      PYTHON_EXE: python


    - PYTHON: "C:\\Python312-x64"
      PYTHON_VERSION: "3.12.0"
      PYTHON_ARCH: "64"
      PYTHON_EXE: python


    - PYTHON: "C:\\Python311-x64"
      PYTHON_VERSION: "3.11.0"
      PYTHON_ARCH: "64"
      PYTHON_EXE: python


    - PYTHON: "C:\\Python310-x64"
      PYTHON_VERSION: "3.10.0"
      PYTHON_ARCH: "64"
      PYTHON_EXE: python


    - PYTHON: "C:\\Python39-x64"
      PYTHON_ARCH: "64"
      PYTHON_VERSION: "3.9.x"
      PYTHON_EXE: python



    # Tested 32-bit versions. A small, hand-picked selection covering
    # important variations. No need to include newer versions of
    # cpython here, 32-bit x86 windows is on the way out.

    - PYTHON: "C:\\Python39"
      PYTHON_ARCH: "32"
      PYTHON_VERSION: "3.9.x"
      PYTHON_EXE: python



    # Untested 64-bit versions. We don't expect any variance here from
    # the other tested 64-bit versions, OR they are very EOL

    # None right now.

    # Untested 32-bit versions. As above, we don't expect any variance
    # from the tested 32-bit versions, OR they are very EOL.

    # None right now.



cache:
  - "%TMP%\\py\\"
  - '%LOCALAPPDATA%\pip\Cache -> appveyor.yml,setup.py'

install:
  # If there is a newer build queued for the same PR, cancel this one.
  # The AppVeyor 'rollout builds' option is supposed to serve the same
  # purpose but it is problematic because it tends to cancel builds pushed
  # directly to master instead of just PR builds (or the converse).
  # credits: JuliaLang developers.
  - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
        https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
        Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
          throw "There are newer queued builds for this pull request, failing early." }
  ## Debugging
  - ECHO "Filesystem root:"
  - ps: "ls \"C:/\""

  # - ECHO "Installed SDKs:"
  # - ps: "if(Test-Path(\"C:/Program Files/Microsoft SDKs/Windows\")) {ls \"C:/Program Files/Microsoft SDKs/Windows\";}"

  # Install Python (from the official .msi of http://python.org) and pip when
  # not already installed.
  # PyPy portion based on https://github.com/wbond/asn1crypto/blob/master/appveyor.yml
  - ps:
      $env:PYTMP = "${env:TMP}\py";
      if (!(Test-Path "$env:PYTMP")) {
        New-Item -ItemType directory -Path "$env:PYTMP" | Out-Null;
      }
      if ("${env:PYTHON_ID}" -eq "pypy") {
        if (!(Test-Path "${env:PYTMP}\pypy2-v7.3.1-win32.zip")) {
          (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy2.7-v7.3.1-win32.zip', "${env:PYTMP}\pypy2-v7.3.1-win32.zip");
        }
        7z x -y "${env:PYTMP}\pypy2-v7.3.1-win32.zip" -oC:\ | Out-Null;
      }
      elseif (-not(Test-Path($env:PYTHON))) {
        & appveyor\install.ps1;
      }

  # Prepend newly installed Python to the PATH of this build (this cannot be
  # done from inside the powershell script as it would require to restart
  # the parent CMD process).
  - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PYTHON%\\bin;%PATH%"
  - "SET PYEXE=%PYTHON%\\%PYTHON_EXE%.exe"

  - "python --version"
  - "python -c \"import struct; print(struct.calcsize('P') * 8)\""

  # Upgrade to the latest version of pip to avoid it displaying warnings
  # about it being out of date. Do this here instead of above in
  # powershell because the annoying 'DEPRECATION:blahblahblah 2.7 blahblahblah'
  # breaks powershell.
  - "%CMD_IN_ENV% %PYEXE% -mensurepip -U --user"
  - "%CMD_IN_ENV% %PYEXE% -mpip install -U --user pip"

  # Install requirements for running tests and building artifacts
  - "%CMD_IN_ENV% pip install --upgrade -r dev-requirements.txt"

build_script:
# Show any compiler warnings.
  - "%CMD_IN_ENV% python setup.py build_ext"
  - "%CMD_IN_ENV% python -m pip install -U -e .[test,docs]"
  - "%CMD_IN_ENV% python -m pip install -U zope.testrunner"


test_script:
  -  if not "%GWHEEL_ONLY%"=="true" %PYEXE% -m zope.testrunner --test-path=src -vvv
# XXX: Doctest disabled pending sphinx release for 3.10; see tests.yml.
#  - "%CMD_IN_ENV% python -m sphinx -b doctest -d docs/_build/doctrees docs docs/_build/doctest"

after_test:
  - "%CMD_IN_ENV% python -mpip wheel --wheel-dir dist ."

artifacts:
  - path: dist\*

deploy_script:
  - ps: if ($env:APPVEYOR_REPO_TAG -eq $TRUE) { pip install twine; twine upload --skip-existing dist/* }

deploy: on
