Skip to content

Commit 75e5231

Browse files
dmitriyseden-run-ai
authored andcommitted
Build system improvements pack - addressing comments to PR and some issues. (pythonnet#546)
* vswhere.exe tool now distributed with the pythonnet sources, dotnet-core-2.0-x86 installation step removed. * .travis.yaml file simplification. * PYTHONNET_INTEROP_FILE env var introduced to allow working with custom interop*.cs file inside IDE. * pdb generation improved for all conditions Net 4.0/NetStandard 2.0 x Debug/Release. * Fix for the pythonnet#539 classic build fails when VS 2017 installed. * Build fixes for the fresh Windows 10 SDKS. * Workaround: Mono downgrade to 5.2.0 to avoid broken mono 5.4.0.201
1 parent df1c224 commit 75e5231

File tree

9 files changed

+120
-222
lines changed

9 files changed

+120
-222
lines changed

.travis.yml

+35-106
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ language: python
44

55
matrix:
66
include:
7+
# --------------------- XPLAT builds ------------------------
78
- python: 2.7
8-
env:
9+
env: &xplat-env
910
- BUILD_OPTS=--xplat
1011
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
11-
addons:
12+
addons: &xplat-addons
1213
apt:
1314
sources:
1415
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main
1516
key_url: https://packages.microsoft.com/keys/microsoft.asc
16-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
17+
- sourceline: deb http://download.mono-project.com/repo/debian trusty/snapshots/5.2.0.224 main
1718
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
1819
packages:
1920
- mono-devel
@@ -22,124 +23,52 @@ matrix:
2223
- dotnet-runtime-2.0.0
2324
- dotnet-sdk-2.0.0
2425
- python: 3.3
25-
env:
26-
- BUILD_OPTS=--xplat
27-
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
28-
addons:
29-
apt:
30-
sources:
31-
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main
32-
key_url: https://packages.microsoft.com/keys/microsoft.asc
33-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
34-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
35-
packages:
36-
- mono-devel
37-
- ca-certificates-mono
38-
- dotnet-hostfxr-2.0.0
39-
- dotnet-runtime-2.0.0
40-
- dotnet-sdk-2.0.0
26+
env: *xplat-env
27+
addons: *xplat-addons
28+
4129
- python: 3.4
42-
env:
43-
- BUILD_OPTS=--xplat
44-
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
45-
addons:
46-
apt:
47-
sources:
48-
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main
49-
key_url: https://packages.microsoft.com/keys/microsoft.asc
50-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
51-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
52-
packages:
53-
- mono-devel
54-
- ca-certificates-mono
55-
- dotnet-hostfxr-2.0.0
56-
- dotnet-runtime-2.0.0
57-
- dotnet-sdk-2.0.0
30+
env: *xplat-env
31+
addons: *xplat-addons
32+
5833
- python: 3.5
59-
env:
60-
- BUILD_OPTS=--xplat
61-
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
62-
addons:
63-
apt:
64-
sources:
65-
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main
66-
key_url: https://packages.microsoft.com/keys/microsoft.asc
67-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
68-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
69-
packages:
70-
- mono-devel
71-
- ca-certificates-mono
72-
- dotnet-hostfxr-2.0.0
73-
- dotnet-runtime-2.0.0
74-
- dotnet-sdk-2.0.0
34+
env: *xplat-env
35+
addons: *xplat-addons
36+
7537
- python: 3.6
76-
env:
77-
- BUILD_OPTS=--xplat
78-
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
79-
addons:
80-
apt:
81-
sources:
82-
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main
83-
key_url: https://packages.microsoft.com/keys/microsoft.asc
84-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
85-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
86-
packages:
87-
- mono-devel
88-
- ca-certificates-mono
89-
- dotnet-hostfxr-2.0.0
90-
- dotnet-runtime-2.0.0
91-
- dotnet-sdk-2.0.0
38+
env: *xplat-env
39+
addons: *xplat-addons
9240
- python: "3.7-dev"
93-
env:
94-
- BUILD_OPTS=--xplat
95-
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
96-
addons:
97-
apt:
98-
sources:
99-
- sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main
100-
key_url: https://packages.microsoft.com/keys/microsoft.asc
101-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
102-
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
103-
packages:
104-
- mono-devel
105-
- ca-certificates-mono
106-
- dotnet-hostfxr-2.0.0
107-
- dotnet-runtime-2.0.0
108-
- dotnet-sdk-2.0.0
41+
env: *xplat-env
42+
addons: *xplat-addons
10943

44+
# --------------------- Classic builds ------------------------
11045
- python: 2.7
111-
env:
46+
env: &classic-env
11247
- BUILD_OPTS=
11348
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
49+
11450
- python: 3.3
115-
env:
116-
- BUILD_OPTS=
117-
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
51+
env: *classic-env
52+
11853
- python: 3.4
119-
env:
120-
- BUILD_OPTS=
121-
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
54+
env: *classic-env
55+
12256
- python: 3.5
123-
env:
124-
- BUILD_OPTS=
125-
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
57+
env: *classic-env
58+
12659
- python: 3.6
127-
env:
128-
- BUILD_OPTS=
129-
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
60+
env: *classic-env
61+
13062
- python: "3.7-dev"
131-
env:
132-
- BUILD_OPTS=
133-
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
63+
env: *classic-env
64+
13465
allow_failures:
13566
- python: "3.7-dev"
136-
env:
137-
- BUILD_OPTS=
138-
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
67+
env: *xplat-env
68+
13969
- python: "3.7-dev"
140-
env:
141-
- BUILD_OPTS=--xplat
142-
- NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe
70+
env: *classic-env
71+
14372
env:
14473
global:
14574
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
@@ -150,7 +79,7 @@ env:
15079
addons:
15180
apt:
15281
sources:
153-
- sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main
82+
- sourceline: deb http://download.mono-project.com/repo/debian trusty/snapshots/5.2.0.224 main
15483
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF
15584
packages:
15685
- mono-devel

appveyor.yml

-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ init:
4242

4343
install:
4444
- pip install --upgrade -r requirements.txt --quiet
45-
- choco install vswhere -y
46-
- cmd: curl -O https://download.microsoft.com/download/5/6/B/56BFEF92-9045-4414-970C-AB31E0FC07EC/dotnet-runtime-2.0.0-win-x86.exe
47-
- cmd: dotnet-runtime-2.0.0-win-x86.exe /install /quiet /norestart /log install.log
4845

4946
# Install OpenCover. Can't put on `packages.config`, not Mono compatible
5047
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages -Verbosity quiet

setup.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
kits_suffix = os.path.join("bin", ARCH)
4141

4242
WIN_SDK_KEYS = (
43+
RegKey(sdk_name="Windows Kit 10.0", key=kits_root,
44+
value_name="KitsRoot10", suffix=os.path.join("bin", "10.0.16299.0", ARCH)),
45+
46+
RegKey(sdk_name="Windows Kit 10.0", key=kits_root,
47+
value_name="KitsRoot10", suffix=os.path.join("bin", "10.0.15063.0", ARCH)),
48+
4349
RegKey(sdk_name="Windows Kit 10.0", key=kits_root,
4450
value_name="KitsRoot10", suffix=kits_suffix),
4551

@@ -324,6 +330,20 @@ def _install_packages(self):
324330

325331
def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False):
326332
"""Return full path to one of the Microsoft build tools"""
333+
334+
# trying to search path with help of vswhere when MSBuild 15.0 and higher installed.
335+
if tool=="msbuild.exe" and use_windows_sdk==False:
336+
try:
337+
basePathes = subprocess.check_output(
338+
["tools\\vswhere\\vswhere.exe", "-latest",
339+
"-version", "[15.0, 16.0)",
340+
"-requires", "Microsoft.Component.MSBuild",
341+
"-property", "InstallationPath"]).splitlines()
342+
if len(basePathes):
343+
return os.path.join(basePathes[0].decode(sys.stdout.encoding or "utf-8"), "MSBuild", "15.0", "Bin", "MSBuild.exe")
344+
except:
345+
pass # keep trying to search by old method.
346+
327347
# Search in PATH first
328348
path = spawn.find_executable(tool)
329349
if path:
@@ -370,7 +390,7 @@ def _find_msbuild_tool_15(self):
370390
"""Return full path to one of the Microsoft build tools"""
371391
try:
372392
basePathes = subprocess.check_output(
373-
["vswhere", "-latest",
393+
["tools\\vswhere\\vswhere.exe", "-latest",
374394
"-version", "[15.0, 16.0)",
375395
"-requires", "Microsoft.Component.MSBuild",
376396
"-property", "InstallationPath"]).splitlines()

src/clrmodule/clrmodule.15.csproj

+9-16
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,38 @@
3838
<PlatformTarget>x64</PlatformTarget>
3939
</PropertyGroup>
4040

41+
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net40'">
42+
<Optimize>false</Optimize>
43+
<DebugType>full</DebugType>
44+
</PropertyGroup>
45+
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net40'">
46+
<Optimize>true</Optimize>
47+
<DebugType>pdbonly</DebugType>
48+
</PropertyGroup>
49+
4150
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMono'">
42-
<DebugSymbols>true</DebugSymbols>
4351
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2;TRACE;DEBUG</DefineConstants>
44-
<DebugType>full</DebugType>
4552
</PropertyGroup>
4653
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
4754
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2</DefineConstants>
48-
<Optimize>true</Optimize>
49-
<DebugType>pdbonly</DebugType>
5055
</PropertyGroup>
5156
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
52-
<DebugSymbols>true</DebugSymbols>
5357
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2;TRACE;DEBUG</DefineConstants>
54-
<DebugType>full</DebugType>
5558
</PropertyGroup>
5659
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
5760
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2</DefineConstants>
58-
<Optimize>true</Optimize>
59-
<DebugType>pdbonly</DebugType>
6061
</PropertyGroup>
6162
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
62-
<DebugSymbols>true</DebugSymbols>
6363
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3;TRACE;DEBUG</DefineConstants>
64-
<DebugType>full</DebugType>
6564
</PropertyGroup>
6665
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
6766
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3</DefineConstants>
68-
<Optimize>true</Optimize>
69-
<DebugType>pdbonly</DebugType>
7067
</PropertyGroup>
7168
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
72-
<DebugSymbols>true</DebugSymbols>
7369
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3;TRACE;DEBUG</DefineConstants>
74-
<DebugType>full</DebugType>
7570
</PropertyGroup>
7671
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
7772
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3</DefineConstants>
78-
<Optimize>true</Optimize>
79-
<DebugType>pdbonly</DebugType>
8073
</PropertyGroup>
8174

8275
<ItemGroup>

src/console/Console.15.csproj

+12-25
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,33 @@
3838
<PropertyGroup Condition=" '$(Platform)' == 'x64'">
3939
<PlatformTarget>x64</PlatformTarget>
4040
</PropertyGroup>
41-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMono'">
42-
<DebugSymbols>true</DebugSymbols>
43-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);DEBUG;TRACE</DefineConstants>
41+
42+
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net40'">
43+
<Optimize>false</Optimize>
4444
<DebugType>full</DebugType>
4545
</PropertyGroup>
46-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
47-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants)</DefineConstants>
46+
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net40'">
4847
<Optimize>true</Optimize>
4948
<DebugType>pdbonly</DebugType>
5049
</PropertyGroup>
51-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
50+
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='netstandard2.0'">
5251
<DebugSymbols>true</DebugSymbols>
53-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);DEBUG;TRACE</DefineConstants>
52+
<Optimize>false</Optimize>
5453
<DebugType>full</DebugType>
5554
</PropertyGroup>
56-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
57-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants)</DefineConstants>
58-
<Optimize>true</Optimize>
59-
<DebugType>pdbonly</DebugType>
60-
</PropertyGroup>
61-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
55+
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='netstandard2.0'">
6256
<DebugSymbols>true</DebugSymbols>
63-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);DEBUG;TRACE</DefineConstants>
64-
<DebugType>full</DebugType>
65-
</PropertyGroup>
66-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
67-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants)</DefineConstants>
6857
<Optimize>true</Optimize>
69-
<DebugType>pdbonly</DebugType>
58+
<DebugType>portable</DebugType>
7059
</PropertyGroup>
71-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
72-
<DebugSymbols>true</DebugSymbols>
60+
61+
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
7362
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);DEBUG;TRACE</DefineConstants>
74-
<DebugType>full</DebugType>
7563
</PropertyGroup>
76-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
64+
<PropertyGroup Condition="$(Configuration.Contains('Release'))">
7765
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants)</DefineConstants>
78-
<Optimize>true</Optimize>
79-
<DebugType>pdbonly</DebugType>
8066
</PropertyGroup>
67+
8168
<PropertyGroup Condition="'$(PythonManifest)' != ''">
8269
<ApplicationManifest>$(PythonManifest)</ApplicationManifest>
8370
</PropertyGroup>

0 commit comments

Comments
 (0)