Skip to content

Commit 78d5d46

Browse files
author
dse
committed
AppVeyor matrix extended, xplat build added.
1 parent 3f02c12 commit 78d5d46

File tree

3 files changed

+62
-12
lines changed

3 files changed

+62
-12
lines changed

appveyor.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
version: '{branch}-{build}'
22
build: off
33

4+
image:
5+
- Visual Studio 2017
6+
47
platform:
58
- x86
69
- x64
@@ -17,6 +20,16 @@ environment:
1720
- PYTHON_VERSION: 3.4
1821
- PYTHON_VERSION: 3.5
1922
- PYTHON_VERSION: 3.6
23+
- PYTHON_VERSION: 2.7
24+
BUILD_OPTS:--xplat
25+
- PYTHON_VERSION: 3.3
26+
BUILD_OPTS:--xplat
27+
- PYTHON_VERSION: 3.4
28+
BUILD_OPTS:--xplat
29+
- PYTHON_VERSION: 3.5
30+
BUILD_OPTS:--xplat
31+
- PYTHON_VERSION: 3.6
32+
BUILD_OPTS:--xplat
2033

2134
init:
2235
# Update Environment Variables based on matrix/platform
@@ -29,6 +42,7 @@ init:
2942

3043
install:
3144
- pip install --upgrade -r requirements.txt --quiet
45+
- choco install vswhere -y
3246

3347
# Install OpenCover. Can't put on `packages.config`, not Mono compatible
3448
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages -Verbosity quiet
@@ -37,7 +51,7 @@ build_script:
3751
# Create clean `sdist`. Only used for releases
3852
- python setup.py --quiet sdist
3953
# Build `wheel` with coverage of `setup.py`
40-
- coverage run setup.py bdist_wheel
54+
- coverage run setup.py bdist_wheel %BUILD_OPTS%
4155

4256
test_script:
4357
- pip install --no-index --find-links=.\dist\ pythonnet

ci/appveyor_run_tests.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ if ($FALSE -and $env:PLATFORM -eq "x86"){
1111
# Executable paths for OpenCover
1212
# Note if OpenCover fails, it won't affect the exit codes.
1313
$OPENCOVER = Resolve-Path .\packages\OpenCover.*\tools\OpenCover.Console.exe
14-
$CS_RUNNER = Resolve-Path .\packages\NUnit.*\tools\"$CS_RUNNER".exe
14+
if ($env:BUILD_OPTS -eq "--xplat"){
15+
$CS_RUNNER = Resolve-Path $env:USERPROFILE\.nuget\packages\nunit.consolerunner\*\tools\"$CS_RUNNER".exe
16+
}
17+
else{
18+
$CS_RUNNER = Resolve-Path .\packages\NUnit.*\tools\"$CS_RUNNER".exe
19+
}
1520
$PY = Get-Command python
1621

1722
# Can't use ".\build\*\Python.EmbeddingTest.dll". Missing framework files.

setup.py

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sysconfig
1616
from distutils import spawn
1717
from distutils.command import install, build, build_ext, install_data, install_lib
18+
from wheel import bdist_wheel
1819

1920
from setuptools import Extension, setup
2021

@@ -139,14 +140,14 @@ def _update_xlat_devtools():
139140
DEVTOOLS = "dotnet"
140141

141142
class BuildExtPythonnet(build_ext.build_ext):
142-
user_options = build_ext.build_ext.user_options + [
143-
('xplat', None, None)
143+
user_options = build_ext.build_ext.user_options + [
144+
('xplat', None, None)
144145
]
145-
def initialize_options(self):
146-
build_ext.build_ext.initialize_options(self)
147-
self.xplat = None
148-
149-
def finalize_options(self):
146+
def initialize_options(self):
147+
build_ext.build_ext.initialize_options(self)
148+
self.xplat = None
149+
150+
def finalize_options(self):
150151
build_ext.build_ext.finalize_options(self)
151152

152153
def build_extension(self, ext):
@@ -218,8 +219,7 @@ def build_extension(self, ext):
218219
_solution_file = 'pythonnet.sln'
219220
_custom_define_constants = False
220221
elif DEVTOOLS == "MsDev15":
221-
# Improve this with self._find_msbuild_tool_15 to find good >15.3 msbuild, currently only works under VS 15.3 developer environment.
222-
_xbuild = '"{0}"'.format(self._find_msbuild_tool("msbuild.exe"))
222+
_xbuild = '"{0}"'.format(self._find_msbuild_tool_15())
223223
_config = "{0}Win".format(CONFIG)
224224
_solution_file = 'pythonnet.15.sln'
225225
_custom_define_constants = True
@@ -364,6 +364,20 @@ def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False):
364364

365365
raise RuntimeError("{0} could not be found".format(tool))
366366

367+
def _find_msbuild_tool_15(self):
368+
"""Return full path to one of the Microsoft build tools"""
369+
try:
370+
basePathes = subprocess.check_output(
371+
["vswhere", "-latest",
372+
"-version", "[15.0, 16.0)",
373+
"-requires", "Microsoft.Component.MSBuild",
374+
"-property", "InstallationPath"]).splitlines()
375+
if len(basePathes):
376+
return os.path.join(basePathes[0].decode(sys.stdout.encoding or "utf-8"), "MSBuild", "15.0", "Bin", "MSBuild.exe")
377+
else:
378+
raise RuntimeError("MSBuild >=15.0 could not be found.")
379+
except subprocess.CalledProcessError as e:
380+
raise RuntimeError("MSBuild >=15.0 could not be found. {0}".format(e.output))
367381

368382
class InstallLibPythonnet(install_lib.install_lib):
369383
def install(self):
@@ -417,7 +431,23 @@ def run(self):
417431
_update_xlat_devtools()
418432
return install.install.run(self)
419433

420-
###############################################################################
434+
class BDistWheelPythonnet(bdist_wheel.bdist_wheel):
435+
user_options = bdist_wheel.bdist_wheel.user_options + [
436+
('xplat', None, None)
437+
]
438+
def initialize_options(self):
439+
bdist_wheel.bdist_wheel.initialize_options(self)
440+
self.xplat = None
441+
442+
def finalize_options(self):
443+
bdist_wheel.bdist_wheel.finalize_options(self)
444+
445+
def run(self):
446+
if self.xplat:
447+
_update_xlat_devtools()
448+
return bdist_wheel.bdist_wheel.run(self)
449+
450+
###############################################################################
421451
setupdir = os.path.dirname(__file__)
422452
if setupdir:
423453
os.chdir(setupdir)
@@ -449,6 +479,7 @@ def run(self):
449479
"build_ext": BuildExtPythonnet,
450480
"install_lib": InstallLibPythonnet,
451481
"install_data": InstallDataPythonnet,
482+
"bdist_wheel": BDistWheelPythonnet
452483
},
453484
classifiers=[
454485
'Development Status :: 5 - Production/Stable',

0 commit comments

Comments
 (0)