Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
NetCoreApp 2.0 target added, compile issues fixed, CI system improved.
  • Loading branch information
dse committed Jul 29, 2017
commit d16100c9b6af123a40398b3b2f40518f0cd552bb
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ install:
script:
- python -m pytest
- mono $NUNIT_PATH src/embed_tests/bin/Python.EmbeddingTest.dll
- if [[ $BUILD_OPTS == --xplat ]]; then dotnet src/embed_tests/bin/netcoreapp2.0_publish/Python.EmbeddingTest.dll; fi

after_script:
# Uncomment if need to geninterop, ie. py37 final
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ init:
install:
- pip install --upgrade -r requirements.txt --quiet
- choco install vswhere -y
# - cmd: curl -O https://download.microsoft.com/download/5/6/B/56BFEF92-9045-4414-970C-AB31E0FC07EC/dotnet-runtime-2.0.0-win-x86.exe
# - cmd: dotnet-runtime-2.0.0-win-x86.exe /install /quiet /norestart /log install.log

# Install OpenCover. Can't put on `packages.config`, not Mono compatible
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages -Verbosity quiet
Expand Down
17 changes: 17 additions & 0 deletions ci/appveyor_run_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ if ($CS_STATUS -ne 0) {
Write-Host "Embedded tests failed" -ForegroundColor "Red"
}

if ($env:BUILD_OPTS -eq "--xplat"){
if ($env:PLATFORM -eq "x64") {
$DOTNET_CMD = "dotnet"
}
else{
$DOTNET_CMD = "c:\Program Files (x86)\dotnet\dotnet"
}

# Run Embedded tests for netcoreapp2.0 (OpenCover currently does not supports dotnet core)
Write-Host ("Starting embedded tests for netcoreapp2.0") -ForegroundColor "Green"
&$DOTNET_CMD .\src\embed_tests\bin\netcoreapp2.0_publish\Python.EmbeddingTest.dll
$CS_STATUS = $LastExitCode
if ($CS_STATUS -ne 0) {
Write-Host "Embedded tests for netcoreapp2.0 failed" -ForegroundColor "Red"
}
}

# Set exit code to fail if either Python or Embedded tests failed
if ($PYTHON_STATUS -ne 0 -or $CS_STATUS -ne 0) {
Write-Host "Tests failed" -ForegroundColor "Red"
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ def build_extension(self, ext):

subprocess.check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell)
subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)

if DEVTOOLS == "MsDev15":
subprocess.check_call(" ".join(cmd + ["/t:Console_15:publish;Python_EmbeddingTest_15:publish", "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell)
elif DEVTOOLS == "dotnet":
subprocess.check_call(" ".join(cmd + ["/t:publish", "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell)

if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet":
self._build_monoclr()

Expand Down
1 change: 1 addition & 0 deletions src/clrmodule/clrmodule.15.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<NoWarn>1591</NoWarn>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PythonBuildDir>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
Expand Down
12 changes: 7 additions & 5 deletions src/console/Console.15.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFrameworks>net40</TargetFrameworks>
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<OutputType>Exe</OutputType>
Expand All @@ -15,12 +15,14 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<DocumentationFile>bin\nPython.xml</DocumentationFile>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir>
<LangVersion>6</LangVersion>
<ApplicationIcon>python-clear.ico</ApplicationIcon>
<ErrorReport>prompt</ErrorReport>
Expand Down Expand Up @@ -88,7 +90,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="python-clear.ico" />
<EmbeddedResource Include="$(PythonBuildDir)\Python.Runtime.dll">
<EmbeddedResource Condition="'$(TargetFramework)'=='net40'" Include="$(PythonBuildDir)\Python.Runtime.dll">
<LogicalName>Python.Runtime.dll</LogicalName>
</EmbeddedResource>
</ItemGroup>
Expand All @@ -99,6 +101,6 @@
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" />
<Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" />
</Target>
</Project>
9 changes: 7 additions & 2 deletions src/console/pythonconsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ namespace Python.Runtime
/// </remarks>
public sealed class PythonConsole
{
#if NET40
private static AssemblyLoader assemblyLoader = new AssemblyLoader();

#endif
private PythonConsole()
{
}

[STAThread]
public static int Main(string[] args)
{
// Only net40 is capable to safely inject python.runtime.dll into resources.
#if NET40
// reference the static assemblyLoader to stop it being optimized away
AssemblyLoader a = assemblyLoader;

#endif
string[] cmd = Environment.GetCommandLineArgs();
PythonEngine.Initialize();

Expand All @@ -37,6 +40,7 @@ public static int Main(string[] args)
return i;
}

#if NET40
// Register a callback function to load embedded assemblies.
// (Python.Runtime.dll is included as a resource)
private sealed class AssemblyLoader
Expand Down Expand Up @@ -73,5 +77,6 @@ public AssemblyLoader()
};
}
}
#endif
}
}
19 changes: 19 additions & 0 deletions src/embed_tests/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

using NUnit.Common;

using NUnitLite;

namespace Python.EmbeddingTest
{
public class Program
{
public static int Main(string[] args)
{
return new AutoRun(typeof(Program).Assembly).Execute(
args,
new ExtendedTextWrapper(Console.Out),
Console.In);
}
}
}
22 changes: 15 additions & 7 deletions src/embed_tests/Python.EmbeddingTest.15.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFrameworks>net40</TargetFrameworks>
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<AssetTargetFallback Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">net45</AssetTargetFallback>
<OutputType Condition="'$(TargetFramework)' != 'net40' OR '$(PYTHONNET_VS_ENV)' == 'true'">Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
<AssemblyName>Python.EmbeddingTest</AssemblyName>
<RootNamespace>Python.EmbeddingTest</RootNamespace>
<PackageId>Python.EmbeddingTest</PackageId>
Expand All @@ -15,16 +16,19 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
<PythonBuildDir Condition="'$(TargetFramework)'=='net40' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)_publish</PublishDir>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
<BaseDefineConstants>XPLAT</BaseDefineConstants>
<DefineConstants>$(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants);</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.0'">$(DefineConstants);NETCOREAPP</DefineConstants>
<FrameworkPathOverride Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">$(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\</FrameworkPathOverride>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86'">
Expand Down Expand Up @@ -87,8 +91,12 @@
<ItemGroup>
<PackageReference Include="NUnit" Version="3.7.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="NUnitLite" Version="3.7.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj" />
</ItemGroup>
Expand All @@ -113,7 +121,7 @@
</PropertyGroup>

<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
<Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
</Target>

Expand Down
4 changes: 4 additions & 0 deletions src/embed_tests/pyimport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public void SetUp()
/* Append the tests directory to sys.path
* using reflection to circumvent the private
* modifiers placed on most Runtime methods. */
#if NETCOREAPP
const string s = "../../fixtures";
#else
const string s = "../fixtures";
#endif
string testPath = Path.Combine(TestContext.CurrentContext.TestDirectory, s);

IntPtr str = Runtime.Runtime.PyString_FromString(testPath);
Expand Down
19 changes: 14 additions & 5 deletions src/runtime/Python.Runtime.15.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFrameworks>net40</TargetFrameworks>
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
<Platforms>AnyCPU</Platforms>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<AssetTargetFallback Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">net45</AssetTargetFallback>
Expand All @@ -16,17 +16,20 @@
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<NoWarn>1591;NU1701</NoWarn>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
<PythonBuildDir Condition="'$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir>
<LangVersion>6</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
<BaseDefineConstants>XPLAT</BaseDefineConstants>
<DefineConstants>$(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants);</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.0'">$(DefineConstants);NETCOREAPP</DefineConstants>
<FrameworkPathOverride Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">$(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\</FrameworkPathOverride>
</PropertyGroup>

Expand Down Expand Up @@ -98,6 +101,12 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="System.Security.Permissions">
<Version>4.4.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand All @@ -118,7 +127,7 @@
<Exec Command="cp $(NuGetPackageRoot)/microsoft.targetingpack.netframework.v4.5/1.0.1/lib/net45/System.XML.dll $(NuGetPackageRoot)/microsoft.targetingpack.netframework.v4.5/1.0.1/lib/net45/System.Xml.dll" />
</Target>
<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
<Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
</Target>
</Project>
9 changes: 8 additions & 1 deletion src/runtime/nativecall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,19 @@ private static void GenerateThunk(TypeBuilder tb, MethodInfo method)

il.Emit(OpCodes.Ldarg_1);

#if NETCOREAPP
il.EmitCalli(OpCodes.Calli,
CallingConventions.ExplicitThis,
method.ReturnType,
nargs, null
);
#else
il.EmitCalli(OpCodes.Calli,
CallingConvention.Cdecl,
method.ReturnType,
nargs
);

#endif
il.Emit(OpCodes.Ret);

tb.DefineMethodOverride(mb, method);
Expand Down
16 changes: 16 additions & 0 deletions src/runtime/polyfill/ReflectionPolifills.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Reflection;
using System.Reflection.Emit;

namespace Python.Runtime
{
public static class ReflectionPolifills
{
#if NETCOREAPP
public static AssemblyBuilder DefineDynamicAssembly(this AppDomain appDomain, AssemblyName assemblyName, AssemblyBuilderAccess assemblyBuilderAccess)
{
return AssemblyBuilder.DefineDynamicAssembly(assemblyName, assemblyBuilderAccess);
}
#endif
}
}
11 changes: 7 additions & 4 deletions src/testing/Python.Test.15.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFrameworks>net40</TargetFrameworks>
<TargetFrameworks>net40;netcoreapp2.0</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<AssemblyName>Python.Test</AssemblyName>
<RootNamespace>Python.Test</RootNamespace>
<PackageId>Python.Test</PackageId>
<VersionPrefix>2.4.0</VersionPrefix>
<DocumentationFile>bin\Python.Test.xml</DocumentationFile>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<NoWarn>1591,0067</NoWarn>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
<PythonBuildDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PythonBuildDir>
<LangVersion>6</LangVersion>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -85,7 +87,8 @@
<TargetAssemblyPdb>$(TargetDir)$(TargetName).pdb</TargetAssemblyPdb>
</PropertyGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(SolutionDir)\src\tests\fixtures" />
<Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetAssembly)" DestinationFolder="$(SolutionDir)\src\tests\fixtures" />
<Copy Condition="'$(TargetFramework)'!='net40'" SourceFiles="$(TargetAssembly)" DestinationFolder="$(SolutionDir)\src\tests\fixtures\$(TargetFramework)" />
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
</Target>
</Project>
Empty file.