Skip to content
Merged
Prev Previous commit
Next Next commit
AppVeyor matrix extended, xplat build added.
  • Loading branch information
dse committed Aug 19, 2017
commit 78d5d463dd41f54ce3c400e6288f418544c7ae81
16 changes: 15 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: '{branch}-{build}'
build: off

image:
- Visual Studio 2017

platform:
- x86
- x64
Expand All @@ -17,6 +20,16 @@ environment:
- PYTHON_VERSION: 3.4
- PYTHON_VERSION: 3.5
- PYTHON_VERSION: 3.6
- PYTHON_VERSION: 2.7
BUILD_OPTS:--xplat
- PYTHON_VERSION: 3.3
BUILD_OPTS:--xplat
- PYTHON_VERSION: 3.4
BUILD_OPTS:--xplat
- PYTHON_VERSION: 3.5
BUILD_OPTS:--xplat
- PYTHON_VERSION: 3.6
BUILD_OPTS:--xplat

init:
# Update Environment Variables based on matrix/platform
Expand All @@ -29,6 +42,7 @@ init:

install:
- pip install --upgrade -r requirements.txt --quiet
- choco install vswhere -y

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

test_script:
- pip install --no-index --find-links=.\dist\ pythonnet
Expand Down
7 changes: 6 additions & 1 deletion ci/appveyor_run_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ if ($FALSE -and $env:PLATFORM -eq "x86"){
# Executable paths for OpenCover
# Note if OpenCover fails, it won't affect the exit codes.
$OPENCOVER = Resolve-Path .\packages\OpenCover.*\tools\OpenCover.Console.exe
$CS_RUNNER = Resolve-Path .\packages\NUnit.*\tools\"$CS_RUNNER".exe
if ($env:BUILD_OPTS -eq "--xplat"){
$CS_RUNNER = Resolve-Path $env:USERPROFILE\.nuget\packages\nunit.consolerunner\*\tools\"$CS_RUNNER".exe
}
else{
$CS_RUNNER = Resolve-Path .\packages\NUnit.*\tools\"$CS_RUNNER".exe
}
$PY = Get-Command python

# Can't use ".\build\*\Python.EmbeddingTest.dll". Missing framework files.
Expand Down
51 changes: 41 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sysconfig
from distutils import spawn
from distutils.command import install, build, build_ext, install_data, install_lib
from wheel import bdist_wheel

from setuptools import Extension, setup

Expand Down Expand Up @@ -139,14 +140,14 @@ def _update_xlat_devtools():
DEVTOOLS = "dotnet"

class BuildExtPythonnet(build_ext.build_ext):
user_options = build_ext.build_ext.user_options + [
('xplat', None, None)
user_options = build_ext.build_ext.user_options + [
('xplat', None, None)
]
def initialize_options(self):
build_ext.build_ext.initialize_options(self)
self.xplat = None
def finalize_options(self):
def initialize_options(self):
build_ext.build_ext.initialize_options(self)
self.xplat = None

def finalize_options(self):
build_ext.build_ext.finalize_options(self)

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

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

def _find_msbuild_tool_15(self):
"""Return full path to one of the Microsoft build tools"""
try:
basePathes = subprocess.check_output(
["vswhere", "-latest",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitriyse can you change this to tools\vswhere\vswhere.exe like I did in my pull request #540?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added tools\vswhere\vswhere.exe file into the repository instead of chocolatey installation.
See PR #546

"-version", "[15.0, 16.0)",
"-requires", "Microsoft.Component.MSBuild",
"-property", "InstallationPath"]).splitlines()
if len(basePathes):
return os.path.join(basePathes[0].decode(sys.stdout.encoding or "utf-8"), "MSBuild", "15.0", "Bin", "MSBuild.exe")
else:
raise RuntimeError("MSBuild >=15.0 could not be found.")
except subprocess.CalledProcessError as e:
raise RuntimeError("MSBuild >=15.0 could not be found. {0}".format(e.output))

class InstallLibPythonnet(install_lib.install_lib):
def install(self):
Expand Down Expand Up @@ -417,7 +431,23 @@ def run(self):
_update_xlat_devtools()
return install.install.run(self)

###############################################################################
class BDistWheelPythonnet(bdist_wheel.bdist_wheel):
user_options = bdist_wheel.bdist_wheel.user_options + [
('xplat', None, None)
]
def initialize_options(self):
bdist_wheel.bdist_wheel.initialize_options(self)
self.xplat = None

def finalize_options(self):
bdist_wheel.bdist_wheel.finalize_options(self)

def run(self):
if self.xplat:
_update_xlat_devtools()
return bdist_wheel.bdist_wheel.run(self)

###############################################################################
setupdir = os.path.dirname(__file__)
if setupdir:
os.chdir(setupdir)
Expand Down Expand Up @@ -449,6 +479,7 @@ def run(self):
"build_ext": BuildExtPythonnet,
"install_lib": InstallLibPythonnet,
"install_data": InstallDataPythonnet,
"bdist_wheel": BDistWheelPythonnet
},
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand Down