| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 436cd80 commit 0305630
24 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,6 +169,7 @@ install: | |||
| 169 | 169 | script: | |
| 170 | 170 | - python -m pytest | |
| 171 | 171 | - mono $NUNIT_PATH src/embed_tests/bin/Python.EmbeddingTest.dll | |
| 172 | + - if [[ $BUILD_OPTS == --xplat ]]; then dotnet src/embed_tests/bin/netcoreapp2.0_publish/Python.EmbeddingTest.dll; fi | ||
| 172 | 173 | ||
| 173 | 174 | after_script: | |
| 174 | 175 | # Uncomment if need to geninterop, ie. py37 final | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. | |||
| 8 | 8 | ## [unreleased][] | |
| 9 | 9 | ||
| 10 | 10 | ### Added | |
| 11 | + - Added support for embedding python into dotnet core 2.0 (NetStandard 2.0) | ||
| 11 | 12 | - Added new build system (pythonnet.15.sln) based on dotnetcore-sdk/xplat(crossplatform msbuild). | |
| 12 | 13 | Currently there two side-by-side build systems that produces the same output (net40) from the same sources. | |
| 13 | 14 | After a some transition time, current (mono/ msbuild 14.0) build system will be removed. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,6 +43,8 @@ init: | |||
| 43 | 43 | install: | |
| 44 | 44 | - pip install --upgrade -r requirements.txt --quiet | |
| 45 | 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 | ||
| 46 | 48 | ||
| 47 | 49 | # Install OpenCover. Can't put on `packages.config`, not Mono compatible | |
| 48 | 50 | - .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages -Verbosity quiet | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,23 @@ if ($CS_STATUS -ne 0) { | |||
| 44 | 44 | Write-Host "Embedded tests failed" -ForegroundColor "Red" | |
| 45 | 45 | } | |
| 46 | 46 | ||
| 47 | + if ($env:BUILD_OPTS -eq "--xplat"){ | ||
| 48 | + if ($env:PLATFORM -eq "x64") { | ||
| 49 | + $DOTNET_CMD = "dotnet" | ||
| 50 | + } | ||
| 51 | + else{ | ||
| 52 | + $DOTNET_CMD = "c:\Program Files (x86)\dotnet\dotnet" | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + # Run Embedded tests for netcoreapp2.0 (OpenCover currently does not supports dotnet core) | ||
| 56 | + Write-Host ("Starting embedded tests for netcoreapp2.0") -ForegroundColor "Green" | ||
| 57 | + &$DOTNET_CMD .\src\embed_tests\bin\netcoreapp2.0_publish\Python.EmbeddingTest.dll | ||
| 58 | + $CS_STATUS = $LastExitCode | ||
| 59 | + if ($CS_STATUS -ne 0) { | ||
| 60 | + Write-Host "Embedded tests for netcoreapp2.0 failed" -ForegroundColor "Red" | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 47 | 64 | # Set exit code to fail if either Python or Embedded tests failed | |
| 48 | 65 | if ($PYTHON_STATUS -ne 0 -or $CS_STATUS -ne 0) { | |
| 49 | 66 | Write-Host "Tests failed" -ForegroundColor "Red" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,15 +2,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 | |||
| 2 | 2 | # Visual Studio 15 | |
| 3 | 3 | VisualStudioVersion = 15.0.26730.3 | |
| 4 | 4 | MinimumVisualStudioVersion = 10.0.40219.1 | |
| 5 | - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src\runtime\Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}" | ||
| 5 | + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src/runtime/Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}" | ||
| 6 | 6 | EndProject | |
| 7 | - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src\embed_tests\Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}" | ||
| 7 | + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src/embed_tests/Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}" | ||
| 8 | 8 | EndProject | |
| 9 | - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src\clrmodule\clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}" | ||
| 9 | + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src/clrmodule/clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}" | ||
| 10 | 10 | EndProject | |
| 11 | - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src\console\Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}" | ||
| 11 | + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src/console/Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}" | ||
| 12 | 12 | EndProject | |
| 13 | - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src\testing\Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}" | ||
| 13 | + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src/testing/Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}" | ||
| 14 | 14 | EndProject | |
| 15 | 15 | Global | |
| 16 | 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -257,6 +257,8 @@ def build_extension(self, ext): | |||
| 257 | 257 | ||
| 258 | 258 | subprocess.check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell) | |
| 259 | 259 | subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell) | |
| 260 | + if DEVTOOLS == "MsDev15" or DEVTOOLS == "dotnet": | ||
| 261 | + subprocess.check_call(" ".join(cmd + ['"/t:Console_15:publish;Python_EmbeddingTest_15:publish"', "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell) | ||
| 260 | 262 | ||
| 261 | 263 | if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet": | |
| 262 | 264 | self._build_monoclr() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ | |||
| 22 | 22 | <NoWarn>1591</NoWarn> | |
| 23 | 23 | <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | |
| 24 | 24 | <PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir> | |
| 25 | + <PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PythonBuildDir> | ||
| 25 | 26 | <LangVersion>6</LangVersion> | |
| 26 | 27 | <ErrorReport>prompt</ErrorReport> | |
| 27 | 28 | <CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | <Project> | |
| 2 | 2 | <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> | |
| 3 | 3 | <PropertyGroup> | |
| 4 | - <TargetFrameworks>net40</TargetFrameworks> | ||
| 4 | + <TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks> | ||
| 5 | 5 | <Platforms>x64;x86</Platforms> | |
| 6 | 6 | <Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations> | |
| 7 | 7 | <OutputType>Exe</OutputType> | |
@@ -15,12 +15,14 @@ | |||
| 15 | 15 | <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> | |
| 16 | 16 | <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute> | |
| 17 | 17 | <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute> | |
| 18 | - <DocumentationFile>bin\nPython.xml</DocumentationFile> | ||
| 19 | 18 | <OutputPath>bin\</OutputPath> | |
| 20 | - <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
| 19 | + <AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath> | ||
| 20 | + <DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile> | ||
| 21 | + <DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> | ||
| 21 | 22 | <NoWarn>1591</NoWarn> | |
| 22 | 23 | <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | |
| 23 | 24 | <PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir> | |
| 25 | + <PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir> | ||
| 24 | 26 | <LangVersion>6</LangVersion> | |
| 25 | 27 | <ApplicationIcon>python-clear.ico</ApplicationIcon> | |
| 26 | 28 | <ErrorReport>prompt</ErrorReport> | |
@@ -89,7 +91,7 @@ | |||
| 89 | 91 | </ItemGroup> | |
| 90 | 92 | <ItemGroup> | |
| 91 | 93 | <Content Include="python-clear.ico" /> | |
| 92 | - <EmbeddedResource Include="$(PythonBuildDir)\Python.Runtime.dll"> | ||
| 94 | + <EmbeddedResource Condition="'$(TargetFramework)'=='net40'" Include="$(PythonBuildDir)\Python.Runtime.dll"> | ||
| 93 | 95 | <LogicalName>Python.Runtime.dll</LogicalName> | |
| 94 | 96 | </EmbeddedResource> | |
| 95 | 97 | </ItemGroup> | |
@@ -100,6 +102,6 @@ | |||
| 100 | 102 | <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> | |
| 101 | 103 | ||
| 102 | 104 | <Target Name="AfterBuild"> | |
| 103 | - <Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" /> | ||
| 105 | + <Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" /> | ||
| 104 | 106 | </Target> | |
| 105 | 107 | </Project> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,18 +16,21 @@ namespace Python.Runtime | |||
| 16 | 16 | /// </remarks> | |
| 17 | 17 | public sealed class PythonConsole | |
| 18 | 18 | { | |
| 19 | + #if NET40 | ||
| 19 | 20 | private static AssemblyLoader assemblyLoader = new AssemblyLoader(); | |
| 20 | - | ||
| 21 | + #endif | ||
| 21 | 22 | private PythonConsole() | |
| 22 | 23 | { | |
| 23 | 24 | } | |
| 24 | 25 | ||
| 25 | 26 | [STAThread] | |
| 26 | 27 | public static int Main(string[] args) | |
| 27 | 28 | { | |
| 29 | + // Only net40 is capable to safely inject python.runtime.dll into resources. | ||
| 30 | + #if NET40 | ||
| 28 | 31 | // reference the static assemblyLoader to stop it being optimized away | |
| 29 | 32 | AssemblyLoader a = assemblyLoader; | |
| 30 | - | ||
| 33 | + #endif | ||
| 31 | 34 | string[] cmd = Environment.GetCommandLineArgs(); | |
| 32 | 35 | PythonEngine.Initialize(); | |
| 33 | 36 | ||
@@ -37,6 +40,7 @@ public static int Main(string[] args) | |||
| 37 | 40 | return i; | |
| 38 | 41 | } | |
| 39 | 42 | ||
| 43 | + #if NET40 | ||
| 40 | 44 | // Register a callback function to load embedded assemblies. | |
| 41 | 45 | // (Python.Runtime.dll is included as a resource) | |
| 42 | 46 | private sealed class AssemblyLoader | |
@@ -73,5 +77,6 @@ public AssemblyLoader() | |||
| 73 | 77 | }; | |
| 74 | 78 | } | |
| 75 | 79 | } | |
| 80 | + #endif | ||
| 76 | 81 | } | |
| 77 | 82 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + using System; | ||
| 2 | + | ||
| 3 | + using NUnit.Common; | ||
| 4 | + | ||
| 5 | + using NUnitLite; | ||
| 6 | + | ||
| 7 | + namespace Python.EmbeddingTest | ||
| 8 | + { | ||
| 9 | + public class Program | ||
| 10 | + { | ||
| 11 | + public static int Main(string[] args) | ||
| 12 | + { | ||
| 13 | + return new AutoRun(typeof(Program).Assembly).Execute( | ||
| 14 | + args, | ||
| 15 | + new ExtendedTextWrapper(Console.Out), | ||
| 16 | + Console.In); | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments