diff options
author | Frazer McLean <frazer@frazermclean.co.uk> | 2016-07-16 23:11:19 +0200 |
---|---|---|
committer | Frazer McLean <frazer@frazermclean.co.uk> | 2016-07-20 00:11:20 +0200 |
commit | 0d1fb10033e197d75485dd4ea700da6bcd14ee0f (patch) | |
tree | 5203f7543903d948b0bf6ae027a1e75f13ea65a9 | |
parent | 8952a30f0a27d6b57e7b054b8b464382b67e3828 (diff) | |
download | sqlalchemy-pr/291.tar.gz |
Add AppVeyor build with autoupload when commit is tagged with 'rel_*'pr/291
-rw-r--r-- | appveyor.yml | 47 | ||||
-rw-r--r-- | appveyor/after_build.bat | 6 | ||||
-rw-r--r-- | appveyor/build.cmd | 21 | ||||
-rw-r--r-- | appveyor/getwheels.py | 78 |
4 files changed, 152 insertions, 0 deletions
diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..1831b2ced --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,47 @@ +environment: + global: + PYPI_USERNAME: + secure: <insert secure variable here> + PYPI_PASSWORD: + secure: <insert secure variable here> + + matrix: + + # For Python versions available on Appveyor, see + # http://www.appveyor.com/docs/installed-software#python + + - PYTHON: "C:\\Python26" + - PYTHON: "C:\\Python27" + - PYTHON: "C:\\Python33" + - PYTHON: "C:\\Python34" + - PYTHON: "C:\\Python35" + - PYTHON: "C:\\Python26-x64" + - PYTHON: "C:\\Python27-x64" + - PYTHON: "C:\\Python33-x64" + DISTUTILS_USE_SDK: "1" + - PYTHON: "C:\\Python34-x64" + DISTUTILS_USE_SDK: "1" + - PYTHON: "C:\\Python35-x64" + +version: "{build}" + +install: + # We need wheel installed to build wheels + - "%PYTHON%\\Scripts\\pip.exe install -U twine wheel" + +build_script: + # Put your build command here. + # If you don't need to build C extensions on 64-bit Python 3.3 or 3.4, + # you can remove "build.cmd" from the front of the command, as it's + # only needed to support those cases. + # Note that you must use the environment variable %PYTHON% to refer to + # the interpreter you're using - Appveyor does not do anything special + # to put the Python version you want to use on PATH. + - "appveyor\\build.cmd %PYTHON%\\python.exe setup.py bdist_wheel" + +after_build: + - "appveyor\\after_build.bat" + +artifacts: + # bdist_wheel puts your built wheel in the dist directory + - path: dist\* diff --git a/appveyor/after_build.bat b/appveyor/after_build.bat new file mode 100644 index 000000000..ec37f0b8c --- /dev/null +++ b/appveyor/after_build.bat @@ -0,0 +1,6 @@ +appveyor\\build.cmd %PYTHON%\\python.exe setup.py bdist_wheel
+IF "%APPVEYOR_REPO_TAG%"=="true" (
+ IF "%APPVEYOR_REPO_TAG_NAME:~0,4%"=="rel_" (
+ %PYTHON%\\Scripts\\twine.exe upload -u %PYPI_USERNAME% -p %PYPI_PASSWORD% dist\*.whl
+ )
+)
diff --git a/appveyor/build.cmd b/appveyor/build.cmd new file mode 100644 index 000000000..243dc9a1f --- /dev/null +++ b/appveyor/build.cmd @@ -0,0 +1,21 @@ +@echo off +:: To build extensions for 64 bit Python 3, we need to configure environment +:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: +:: MS Windows SDK for Windows 7 and .NET Framework 4 +:: +:: More details at: +:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows + +IF "%DISTUTILS_USE_SDK%"=="1" ( + ECHO Configuring environment to build with MSVC on a 64bit architecture + ECHO Using Windows SDK 7.1 + "C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup\WindowsSdkVer.exe" -q -version:v7.1 + CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /release + SET MSSdk=1 + REM Need the following to allow tox to see the SDK compiler + SET TOX_TESTENV_PASSENV=DISTUTILS_USE_SDK MSSdk INCLUDE LIB +) ELSE ( + ECHO Using default MSVC build environment +) + +CALL %* diff --git a/appveyor/getwheels.py b/appveyor/getwheels.py new file mode 100644 index 000000000..84ac03045 --- /dev/null +++ b/appveyor/getwheels.py @@ -0,0 +1,78 @@ +# coding: utf-8 +from __future__ import absolute_import, division, print_function + +import os +import sys +from textwrap import dedent + +import requests + +URL = 'https://ci.appveyor.com/api' +TOKEN = os.getenv('APPVEYOR_TOKEN') +ACCOUNT = 'zzzeek' # AppVeyor username, assuming zzzeek +PROJECT = 'sqlalchemy' + +if len(sys.argv) != 2: + sys.exit('getwheels.py <branch>') + +if TOKEN is None: + sys.exit('APPVEYOR_TOKEN env var not set.') + +branch = sys.argv[1] + +session = requests.Session() +session.headers.update({'Authorization': 'Bearer ' + TOKEN}) + +BRANCH_BUILD_URL = '{}/projects/{}/{}/branch/{}'.format( + URL, ACCOUNT, PROJECT, branch) + +response = session.get(BRANCH_BUILD_URL) +response.raise_for_status() + +build_data = response.json()['build'] + +message = dedent(''' + Downloading wheels for latest build on branch {bd[branch]!r}. + + Branch: {bd[branch]} + AppVeyor build: {bd[buildNumber]} + Commit ID: {bd[commitId]} + Commit message: {bd[message]} + + Build status: {bd[status]} +'''.format(bd=build_data)) + +print(message) + +if build_data['status'] == 'failed': + sys.exit('Build failed, aborting download.') +elif build_data['status'] == 'running': + sys.exit('Build still running, aborting download.') + +job_ids = [job['jobId'] for job in build_data['jobs']] + + +def download_artifact(artifact): + FILE_URL = '{}/buildjobs/{}/artifacts'.format( + URL, job_id, artifact['fileName']) + + print('Downloading', artifact['fileName']) + + response = session.get(FILE_URL, stream=True) + response.raise_for_status() + + with open(artifact['fileName'], 'wb') as fp: + for chunk in response.iter_content(chunk_size=100 * 1024): + fp.write(chunk) + +try: + os.mkdir('dist') +except OSError: + pass + +for job_id in job_ids: + ARTIFACTS_URL = '{}/buildjobs/{}/artifacts'.format(URL, job_id) + response = session.get(ARTIFACTS_URL) + for artifact in response.json(): + if artifact['fileName'].endswith('.whl'): + download_artifact(artifact) |