Skip to content

Commit 9141e90

Browse files
nitzmahoneingydotnet
authored andcommitted
Windows Appveyor build
* builds Windows wheels against a specified libyaml repo/refspec for many Python versions * since we don't have multiple Appveyor workers, it's faster/more convenient to run them serially * not all paths sufficient for general CI usage yet; still needs manual inspection/testing of output * various hacks to quiet warning noise during build on old Pythons
1 parent d6cbff6 commit 9141e90

File tree

5 files changed

+270
-9
lines changed

5 files changed

+270
-9
lines changed

.appveyor.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# TODO: update this from inside the build to use branch current version
2+
version: '{build}'
3+
4+
image:
5+
- Visual Studio 2015
6+
7+
#cache:
8+
#- 'C:\Python38\'
9+
#- 'C:\Python38-x64'
10+
11+
environment:
12+
libyaml_repo_url: https://github.com/yaml/libyaml.git
13+
libyaml_refspec: release/0.2.2
14+
# matrix:
15+
# - PYTHON_VER: Python27
16+
# - PYTHON_VER: Python27-x64
17+
# - PYTHON_VER: Python34
18+
# - PYTHON_VER: Python34-x64
19+
# - PYTHON_VER: Python35
20+
# - PYTHON_VER: Python35-x64
21+
# - PYTHON_VER: Python36
22+
# - PYTHON_VER: Python36-x64
23+
# - PYTHON_VER: Python37
24+
# - PYTHON_VER: Python37-x64
25+
# - PYTHON_VER: Python38
26+
# - PYTHON_VER: Python38-x64
27+
28+
#init:
29+
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
30+
31+
build_script:
32+
- ps: packaging\build\appveyor.ps1
33+
34+
#on_finish:
35+
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

.gitignore

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
# This file is generated by Cython
2-
ext/_yaml.c
3-
4-
# Tox and Build Artifacts
5-
.tox/
1+
# build outputs
2+
/dist/*
3+
/build/*
4+
/ext/_yaml.c
65
MANIFEST
7-
build/
86

9-
# Python runtime Artifacts
10-
*.pyc
7+
# cached Python binaries
8+
*.py[cdo]
9+
_pycache_/*
10+
11+
# local IDE state
12+
/.idea/*
13+

packaging/build/FixVS9CMake.reg

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Windows Registry Editor Version 5.00
2+
3+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{600dd186-2429-11d7-8bf6-00b0d03daa06}]
4+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectIA64Platform.dll"
5+
@="Win64 (Itanium) Platform Class"
6+
7+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{600dd187-2429-11d7-8bf6-00b0d03daa06}]
8+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectIA64Platform.dll"
9+
@="ClIA64CodeGeneration Class"
10+
11+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{600dd188-2429-11d7-8bf6-00b0d03daa06}]
12+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectIA64Platform.dll"
13+
@="ClIA64General Class"
14+
15+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{600dd189-2429-11d7-8bf6-00b0d03daa06}]
16+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectIA64Platform.dll"
17+
@="ClIA64AdditionalOptions Class"
18+
19+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{656d875f-2429-11d7-8bf6-00b0d03daa06}]
20+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectAMD64Platform.dll"
21+
@="ClAMD64CodeGeneration Class"
22+
23+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{656d8760-2429-11d7-8bf6-00b0d03daa06}]
24+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectAMD64Platform.dll"
25+
@="ClAMD64General Class"
26+
27+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{656d8763-2429-11d7-8bf6-00b0d03daa06}]
28+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectAMD64Platform.dll"
29+
@="Win64 (AMD64) Platform Class"
30+
31+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\CLSID\{656d8766-2429-11d7-8bf6-00b0d03daa06}]
32+
"InprocServer32"="C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\vcpackages\\VCProjectAMD64Platform.dll"
33+
@="ClAMD64AdditionalOptions Class"
34+
35+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO]
36+
37+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (AMD64)]
38+
@="{656d8763-2429-11d7-8bf6-00b0d03daa06}"
39+
40+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (AMD64)\ToolDefaultExtensionLists]
41+
"VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
42+
"VCLinkerTool"="*.obj;*.res;*.lib;*.rsc"
43+
"VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
44+
"VCMIDLTool"="*.idl;*.odl"
45+
"VCCustomBuildTool"="*.bat"
46+
"VCResourceCompilerTool"="*.rc"
47+
"VCPreBuildEventTool"="*.bat"
48+
"VCPreLinkEventTool"="*.bat"
49+
"VCPostBuildEventTool"="*.bat"
50+
"VCBscMakeTool"="*.sbr"
51+
"VCNMakeTool"=""
52+
"VCWebServiceProxyGeneratorTool"="*.sdl;*.wsdl"
53+
"VCWebDeploymentTool"=""
54+
"VCALinkTool"="*.resources"
55+
"VCManagedResourceCompilerTool"="*.resx"
56+
57+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (Itanium)]
58+
@="{600dd186-2429-11d7-8bf6-00b0d03daa06}"
59+
60+
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\VC\VC_OBJECTS_PLATFORM_INFO\Win64 (Itanium)\ToolDefaultExtensionLists]
61+
"VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
62+
"VCLinkerTool"="*.obj;*.res;*.lib;*.rsc"
63+
"VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
64+
"VCMIDLTool"="*.idl;*.odl"
65+
"VCCustomBuildTool"="*.bat"
66+
"VCResourceCompilerTool"="*.rc"
67+
"VCPreBuildEventTool"="*.bat"
68+
"VCPreLinkEventTool"="*.bat"
69+
"VCPostBuildEventTool"="*.bat"
70+
"VCBscMakeTool"="*.sbr"
71+
"VCNMakeTool"=""
72+
"VCWebServiceProxyGeneratorTool"="*.sdl;*.wsdl"
73+
"VCWebDeploymentTool"=""
74+
"VCALinkTool"="*.resources"
75+
"VCManagedResourceCompilerTool"="*.resx"
76+

packaging/build/appveyor.ps1

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# TODO: run in PR/test mode (larger matrix) vs "all-in-one" artifact/packaging mode
2+
# TODO: use dynamic matrix so PRs are multi-job and tag builds are one (consolidate artifacts)
3+
# TODO: consider secure credential storage for inline upload on tags? Or keep that all manual/OOB for security...
4+
# TODO: refactor libyaml/pyyaml tests to enable first-class output for AppVeyor
5+
# TODO: get version number from setup.py and/or lib(3)/__version__
6+
# Update-AppveyorBuild -Version $dynamic_version
7+
8+
Function Bootstrap() {
9+
# uncomment when we want to start testing on Python 3.8
10+
# ensure py38 is present (current Appveyor VS2015 image doesn't include it)
11+
#If(-not $(Test-Path C:\Python38)) {
12+
# choco.exe install python3 --version=3.8.0-a2 --forcex86 --force #--install-arguments="TargetDir=C:\Python38 PrependPath=0" --no-progress
13+
#}
14+
15+
#If(-not $(Test-Path C:\Python38-x64)) {
16+
# choco.exe install python3 --version=3.8.0-a2 --force #--install-arguments="TargetDir=C:\Python38-x64 PrependPath=0" --no-progress
17+
#}
18+
19+
Write-Output "patching Windows SDK bits for distutils"
20+
21+
# patch 7.0/7.1 vcvars SDK bits up to work with distutils query
22+
Set-Content -Path 'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat' '@CALL "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat"'
23+
Set-Content -Path 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat' '@CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /Release /x64'
24+
25+
# patch VS9 x64 CMake config for VS Express, hide `reg.exe` stderr noise
26+
$noise = reg.exe import packaging\build\FixVS9CMake.reg 2>&1
27+
28+
If($LASTEXITCODE -ne 0) {
29+
throw "reg failed with error code $LASTEXITCODE"
30+
}
31+
32+
Copy-Item -Path "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\AMD64.VCPlatform.config" -Destination "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\AMD64.VCPlatform.Express.config" -Force
33+
Copy-Item -Path "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\Itanium.VCPlatform.config" -Destination "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\Itanium.VCPlatform.Express.config" -Force
34+
35+
# git spews all over stderr unless we tell it not to
36+
$env:GIT_REDIRECT_STDERR="2>&1";
37+
38+
$libyaml_repo_url = If($env:libyaml_repo_url) { $env:libyaml_repo_url } Else { "https://github.com/yaml/libyaml.git" }
39+
$libyaml_refspec = If($env:libyaml_refspec) { $env:libyaml_refspec } Else { "master" }
40+
41+
Write-Output "cloning libyaml from $libyaml_repo_url / $libyaml_refspec"
42+
43+
If(-not $(Test-Path .\libyaml)) {
44+
git clone -b $libyaml_refspec $libyaml_repo_url 2>&1
45+
}
46+
}
47+
48+
Function Build-Wheel($python_path) {
49+
50+
#$python_path = Join-Path C:\ $env:PYTHON_VER
51+
$python = Join-Path $python_path python.exe
52+
53+
Write-Output "building pyyaml wheel for $python_path"
54+
55+
# query distutils for the VC version used to build this Python; translate to a VS version to choose the right generator
56+
$python_vs_buildver = & $python -c "from distutils.version import LooseVersion; from distutils.msvc9compiler import get_build_version; print(LooseVersion(str(get_build_version())).version[0])"
57+
58+
$python_cmake_generator = switch($python_vs_buildver) {
59+
"9" { "Visual Studio 9 2008" }
60+
"10" { "Visual Studio 10 2010" }
61+
"14" { "Visual Studio 14 2015" }
62+
default { throw "Python was built with unknown VS build version: $python_vs_buildver" }
63+
}
64+
65+
# query arch this python was built for
66+
$python_arch = & $python -c "from distutils.util import get_platform; print(str(get_platform()))"
67+
68+
if($python_arch -eq 'win-amd64') {
69+
$python_cmake_generator += " Win64"
70+
$vcvars_arch = "x64"
71+
}
72+
73+
# snarf VS vars (paths, etc) for the matching VS version and arch that built this Python
74+
$raw_vars_out = & cmd.exe /c "`"C:\Program Files (x86)\Microsoft Visual Studio $($python_vs_buildver).0\VC\vcvarsall.bat`" $vcvars_arch & set"
75+
foreach($kv in $raw_vars_out) {
76+
If($kv -match "=") {
77+
$kv = $kv.Split("=", 2)
78+
Set-Item -Force "env:$kv[0]" $kv[1]
79+
}
80+
Else {
81+
Write-Output $kv
82+
}
83+
}
84+
85+
# ensure pip is current (some appveyor pips are not)
86+
& $python -W "ignore:DEPRECATION" -m pip install --upgrade pip
87+
88+
# ensure required-for-build packages are present and up-to-date
89+
& $python -W "ignore:DEPRECATION" -m pip install --upgrade cython wheel setuptools --no-warn-script-location
90+
91+
pushd libyaml
92+
git clean -fdx
93+
popd
94+
95+
mkdir libyaml\build
96+
97+
pushd libyaml\build
98+
cmake.exe -G $python_cmake_generator -DYAML_STATIC_LIB_NAME=yaml ..
99+
cmake.exe --build . --config Release
100+
popd
101+
102+
& $python setup.py --with-libyaml build_ext -I libyaml\include -L libyaml\build\Release -D YAML_DECLARE_STATIC build test bdist_wheel
103+
}
104+
105+
Function Upload-Artifacts() {
106+
Write-Output "uploading artifacts..."
107+
108+
foreach($wheel in @(Resolve-Path dist\*.whl)) {
109+
Push-AppveyorArtifact $wheel
110+
}
111+
}
112+
113+
Bootstrap
114+
115+
$pythons = @(
116+
"C:\Python27"
117+
"C:\Python27-x64"
118+
"C:\Python34"
119+
"C:\Python34-x64"
120+
"C:\Python35"
121+
"C:\Python35-x64"
122+
"C:\Python36"
123+
"C:\Python36-x64"
124+
"C:\Python37"
125+
"C:\Python37-x64"
126+
)
127+
128+
#$pythons = @("C:\$($env:PYTHON_VER)")
129+
130+
foreach($python in $pythons) {
131+
Build-Wheel $python
132+
}
133+
134+
Upload-Artifacts

setup.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"""
5959

6060

61-
import sys, os.path, platform
61+
import sys, os.path, platform, warnings
6262

6363
from distutils import log
6464
from distutils.core import setup, Command
@@ -93,6 +93,19 @@
9393
bdist_wheel = None
9494

9595

96+
# on Windows, disable wheel generation warning noise
97+
windows_ignore_warnings = [
98+
"Unknown distribution option: 'python_requires'",
99+
"Config variable 'Py_DEBUG' is unset",
100+
"Config variable 'WITH_PYMALLOC' is unset",
101+
"Config variable 'Py_UNICODE_SIZE' is unset",
102+
"Cython directive 'language_level' not set"
103+
]
104+
105+
if platform.system() == 'Windows':
106+
for w in windows_ignore_warnings:
107+
warnings.filterwarnings('ignore', w)
108+
96109
class Distribution(_Distribution):
97110

98111
def __init__(self, attrs=None):

0 commit comments

Comments
 (0)