Skip to content

Dropped net40 target from modern projects #1300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ details about the cause of the failure
### Removed

- implicit assembly loading (you have to explicitly `clr.AddReference` before doing import)
- support for .NET Framework 4.0-4.6; Mono before 5.4. Python.NET now requires .NET Standard 2.0
(see [the matrix](https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support))

## [2.5.0][] - 2020-06-14

Expand Down
316 changes: 92 additions & 224 deletions pythonnet.15.sln

Large diffs are not rendered by default.

21 changes: 4 additions & 17 deletions src/clrmodule/clrmodule.15.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<TargetFrameworks>net40</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
<RootNamespace>clrmodule</RootNamespace>
<AssemblyName>clrmodule</AssemblyName>
<PackageId>clrmodule</PackageId>
Expand Down Expand Up @@ -46,29 +46,16 @@
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'DebugMono'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2;TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2;TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3;TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3;TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3</DefineConstants>
</PropertyGroup>

Expand Down
29 changes: 17 additions & 12 deletions src/console/Console.15.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFrameworks>net40;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
<OutputType>Exe</OutputType>
<AssemblyName>nPython</AssemblyName>
<RootNamespace>Python.Runtime</RootNamespace>
Expand All @@ -16,21 +16,20 @@
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net461'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net461'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net461'">$(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>
<PublishDir Condition="'$(TargetFramework)'!='net461'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir>
<LangVersion>6</LangVersion>
<ApplicationIcon>python-clear.ico</ApplicationIcon>
<ErrorReport>prompt</ErrorReport>
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
<BaseDefineConstants>XPLAT</BaseDefineConstants>
<DefineConstants>$(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants);</DefineConstants>
<DefineConstants Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(CustomDefineConstants)' != '' AND $(Configuration.Contains('Debug'))">$(DefineConstants);TRACE;DEBUG</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'">
<PlatformTarget>x86</PlatformTarget>
Expand All @@ -39,11 +38,11 @@
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net40'">
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net461'">
<Optimize>false</Optimize>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net40'">
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net461'">
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
</PropertyGroup>
Expand All @@ -68,7 +67,7 @@
<PropertyGroup Condition="'$(PythonManifest)' != ''">
<ApplicationManifest>$(PythonManifest)</ApplicationManifest>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
Expand All @@ -78,17 +77,23 @@
</ItemGroup>
<ItemGroup>
<Content Include="python-clear.ico" />
<EmbeddedResource Condition="'$(TargetFramework)'=='net40'" Include="$(PythonBuildDir)\Python.Runtime.dll">
<EmbeddedResource Condition="'$(TargetFramework)'=='net461'" Include="$(PythonBuildDir)\Python.Runtime.dll">
<LogicalName>Python.Runtime.dll</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj" />
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<Target Name="AfterBuild">
<Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" />
<Copy Condition="'$(TargetFramework)'=='net461'" SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" />
</Target>
</Project>
8 changes: 4 additions & 4 deletions src/console/pythonconsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Python.Runtime
/// </remarks>
public sealed class PythonConsole
{
#if NET40
#if NET461
private static AssemblyLoader assemblyLoader = new AssemblyLoader();
#endif
private PythonConsole()
Expand All @@ -26,8 +26,8 @@ private PythonConsole()
[STAThread]
public static int Main(string[] args)
{
// Only net40 is capable to safely inject python.runtime.dll into resources.
#if NET40
// Only .NET Framework is capable to safely inject python.runtime.dll into resources.
#if NET461
// reference the static assemblyLoader to stop it being optimized away
AssemblyLoader a = assemblyLoader;
#endif
Expand All @@ -40,7 +40,7 @@ public static int Main(string[] args)
return i;
}

#if NET40
#if NET461
// Register a callback function to load embedded assemblies.
// (Python.Runtime.dll is included as a resource)
private sealed class AssemblyLoader
Expand Down
31 changes: 18 additions & 13 deletions src/embed_tests/Python.EmbeddingTest.15.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFrameworks>net40;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<OutputType Condition="'$(TargetFramework)' != 'net40' OR '$(PYTHONNET_VS_ENV)' == 'true'">Exe</OutputType>
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
<OutputType Condition="'$(TargetFramework)' != 'net461' OR '$(PYTHONNET_VS_ENV)' == 'true'">Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
<AssemblyName>Python.EmbeddingTest</AssemblyName>
<RootNamespace>Python.EmbeddingTest</RootNamespace>
Expand All @@ -16,13 +16,13 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net461'">false</AppendTargetFrameworkToOutputPath>
<DocumentationFile Condition="'$(TargetFramework)'=='net461'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile Condition="'$(TargetFramework)'!='net461'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<PythonBuildDir Condition="'$(TargetFramework)'=='net40' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)_publish</PublishDir>
<PythonBuildDir Condition="'$(TargetFramework)'=='net461' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
<PublishDir Condition="'$(TargetFramework)'!='net461'">$(OutputPath)\$(TargetFramework)_publish</PublishDir>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
Expand All @@ -31,7 +31,6 @@
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp3.1'">$(DefineConstants);NETCOREAPP</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">$(DefineConstants);NETSTANDARD</DefineConstants>
<DefineConstants Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(CustomDefineConstants)' != '' AND $(Configuration.Contains('Debug'))">$(DefineConstants);TRACE;DEBUG</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'">
<PlatformTarget>x86</PlatformTarget>
Expand All @@ -40,11 +39,11 @@
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net40'">
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net461'">
<Optimize>false</Optimize>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net40'">
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net461'">
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
</PropertyGroup>
Expand Down Expand Up @@ -90,11 +89,17 @@
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

Expand All @@ -114,7 +119,7 @@
</PropertyGroup>

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

Expand Down
4 changes: 2 additions & 2 deletions src/perf_tests/Python.PerformanceTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
<OutputPath>bin\</OutputPath>

<IsPackable>false</IsPackable>
Expand All @@ -28,7 +28,7 @@
</ItemGroup>

<Target Name="GetRuntimeLibBuildOutput" BeforeTargets="Build">
<MSBuild Projects="..\runtime\Python.Runtime.15.csproj" Properties="PYTHONNET_PY3_VERSION=PYTHON38;Configuration=$(Configuration);TargetFramework=net40;Python3Version=PYTHON38;OutputPath=bin\for_perf\">
<MSBuild Projects="..\runtime\Python.Runtime.15.csproj" Properties="PYTHONNET__VERSION=PYTHON38;Configuration=$(Configuration);Python3Version=PYTHON38;OutputPath=bin\for_perf\;TargetFramework=netstandard2.0">
<Output TaskParameter="TargetOutputs" ItemName="NewPythonRuntime" />
</MSBuild>
</Target>
Expand Down
Loading