From 0abfde0d693e11b3165195d76cbae5e43e7c326a Mon Sep 17 00:00:00 2001 From: dse Date: Sat, 29 Jul 2017 01:57:22 +0400 Subject: [PATCH 01/17] Full featured xplat build. --- NuGet.config | 7 + pythonnet.15.sln | 194 ++++++++++++++++++ setup.py | 31 ++- src/clrmodule/clrmodule.15.csproj | 100 +++++++++ src/console/Console.15.csproj | 104 ++++++++++ .../Python.EmbeddingTest.15.csproj | 120 +++++++++++ src/runtime/Python.Runtime.15.csproj | 120 +++++++++++ src/testing/Python.Test.15.csproj | 91 ++++++++ 8 files changed, 764 insertions(+), 3 deletions(-) create mode 100644 NuGet.config create mode 100644 pythonnet.15.sln create mode 100644 src/clrmodule/clrmodule.15.csproj create mode 100644 src/console/Console.15.csproj create mode 100644 src/embed_tests/Python.EmbeddingTest.15.csproj create mode 100644 src/runtime/Python.Runtime.15.csproj create mode 100644 src/testing/Python.Test.15.csproj diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 000000000..719fbc83c --- /dev/null +++ b/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/pythonnet.15.sln b/pythonnet.15.sln new file mode 100644 index 000000000..121631e43 --- /dev/null +++ b/pythonnet.15.sln @@ -0,0 +1,194 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src\runtime\Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src\embed_tests\Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src\clrmodule\clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src\console\Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src\testing\Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + DebugMono|x64 = DebugMono|x64 + DebugMono|x86 = DebugMono|x86 + DebugMonoPY3|x64 = DebugMonoPY3|x64 + DebugMonoPY3|x86 = DebugMonoPY3|x86 + DebugWin|x64 = DebugWin|x64 + DebugWin|x86 = DebugWin|x86 + DebugWinPY3|x64 = DebugWinPY3|x64 + DebugWinPY3|x86 = DebugWinPY3|x86 + ReleaseMono|x64 = ReleaseMono|x64 + ReleaseMono|x86 = ReleaseMono|x86 + ReleaseMonoPY3|x64 = ReleaseMonoPY3|x64 + ReleaseMonoPY3|x86 = ReleaseMonoPY3|x86 + ReleaseWin|x64 = ReleaseWin|x64 + ReleaseWin|x86 = ReleaseWin|x86 + ReleaseWinPY3|x64 = ReleaseWinPY3|x64 + ReleaseWinPY3|x86 = ReleaseWinPY3|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x64.ActiveCfg = DebugMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x64.Build.0 = DebugMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x86.ActiveCfg = DebugMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMono|x86.Build.0 = DebugMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x64.ActiveCfg = DebugWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x64.Build.0 = DebugWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x86.ActiveCfg = DebugWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWin|x86.Build.0 = DebugWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x64.Build.0 = DebugWinPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.DebugWinPY3|x86.Build.0 = DebugWinPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x64.ActiveCfg = ReleaseMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x64.Build.0 = ReleaseMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x86.ActiveCfg = ReleaseMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMono|x86.Build.0 = ReleaseMono|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x64.Build.0 = ReleaseWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWin|x86.Build.0 = ReleaseWin|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|Any CPU + {2759F4FF-716B-4828-916F-50FA86613DFC}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|Any CPU + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x64.ActiveCfg = DebugMono|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x64.Build.0 = DebugMono|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x86.ActiveCfg = DebugMono|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMono|x86.Build.0 = DebugMono|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x64.ActiveCfg = DebugWin|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x64.Build.0 = DebugWin|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x86.ActiveCfg = DebugWin|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWin|x86.Build.0 = DebugWin|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 + {66B8D01A-9906-452A-B09E-BF75EA76468F}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMono|x64.ActiveCfg = DebugMono|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMono|x86.ActiveCfg = DebugMono|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x64.ActiveCfg = DebugWin|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x64.Build.0 = DebugWin|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x86.ActiveCfg = DebugWin|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWin|x86.Build.0 = DebugWin|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 + {E08678D4-9A52-4AD5-B63D-8EBC7399981B}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x64.ActiveCfg = DebugMono|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x64.Build.0 = DebugMono|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x86.ActiveCfg = DebugMono|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMono|x86.Build.0 = DebugMono|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x64.ActiveCfg = DebugWin|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x64.Build.0 = DebugWin|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x86.ActiveCfg = DebugWin|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWin|x86.Build.0 = DebugWin|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 + {CDAD305F-8E72-492C-A314-64CF58D472A0}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x64.ActiveCfg = DebugMono|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x64.Build.0 = DebugMono|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x86.ActiveCfg = DebugMono|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMono|x86.Build.0 = DebugMono|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x64.ActiveCfg = DebugWin|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x64.Build.0 = DebugWin|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x86.ActiveCfg = DebugWin|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWin|x86.Build.0 = DebugWin|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86 + {F94B547A-E97E-4500-8D53-B4D64D076E5F}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A6347B90-BBE6-4E45-90BF-1BD8B76069E3} + EndGlobalSection +EndGlobal diff --git a/setup.py b/setup.py index c23f6b5bd..895219eec 100644 --- a/setup.py +++ b/setup.py @@ -133,6 +133,16 @@ def _get_long_description(): class BuildExtPythonnet(build_ext.build_ext): + 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): + build_ext.build_ext.finalize_options(self) + def build_extension(self, ext): """Builds the .pyd file using msbuild or xbuild""" if ext.name != "clr": @@ -198,7 +208,7 @@ def build_extension(self, ext): _config = "{0}Win".format(CONFIG) elif DEVTOOLS == "Mono": - _xbuild = "xbuild" + _xbuild = 'dotnet msbuild' if self.xplat else 'xbuild' _config = "{0}Mono".format(CONFIG) else: raise NotImplementedError( @@ -206,10 +216,10 @@ def build_extension(self, ext): cmd = [ _xbuild, - 'pythonnet.sln', + 'pythonnet.15.sln' if self.xplat else 'pythonnet.sln', '/p:Configuration={}'.format(_config), '/p:Platform={}'.format(ARCH), - '/p:DefineConstants="{}"'.format('%3B'.join(defines)), + '/p:{}DefineConstants="{}"'.format('Custom' if self.xplat else '','%3B'.join(defines)), '/p:PythonBuildDir="{}"'.format(os.path.abspath(dest_dir)), '/p:PythonInteropFile="{}"'.format(os.path.basename(interop_file)), '/verbosity:{}'.format(VERBOSITY), @@ -221,6 +231,7 @@ def build_extension(self, ext): self.debug_print("Building: {0}".format(" ".join(cmd))) use_shell = True if DEVTOOLS == "Mono" else False + subprocess.check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell) subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell) @@ -267,6 +278,20 @@ def _install_packages(self): nuget = "mono {0}".format(nuget) use_shell = True + if self.xplat: + if DEVTOOLS == "MsDev": + _config = "{0}Win".format(CONFIG) + elif DEVTOOLS == "Mono": + _config = "{0}Mono".format(CONFIG) + else: + raise NotImplementedError( + "DevTool {0} not supported (use MsDev/Mono)".format(DEVTOOLS)) + + cmd = "dotnet msbuild /t:Restore pythonnet.15.sln /p:Configuration={0} /p:Platform={1}".format(_config, ARCH) + self.debug_print("Updating packages with xplat: {0}".format(cmd)) + subprocess.check_call(cmd, shell=use_shell) + return; + cmd = "{0} update -self".format(nuget) self.debug_print("Updating NuGet: {0}".format(cmd)) subprocess.check_call(cmd, shell=use_shell) diff --git a/src/clrmodule/clrmodule.15.csproj b/src/clrmodule/clrmodule.15.csproj new file mode 100644 index 000000000..fe31bdb9d --- /dev/null +++ b/src/clrmodule/clrmodule.15.csproj @@ -0,0 +1,100 @@ + + + + + + net40 + x64;x86 + DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 + clrmodule + clrmodule + clrmodule + 2.4.0 + false + false + false + false + false + false + bin\clrmodule.xml + bin\ + false + 1591 + ..\..\ + $(SolutionDir)\bin\ + 6 + prompt + $(PYTHONNET_DEFINE_CONSTANTS) + XPLAT + $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + + + + x86 + + + x64 + + + + true + $(DefineConstants);PYTHON2;TRACE;DEBUG + full + + + $(DefineConstants);PYTHON2 + true + pdbonly + + + true + $(DefineConstants);PYTHON2;TRACE;DEBUG + full + + + $(DefineConstants);PYTHON2 + true + pdbonly + + + true + $(DefineConstants);PYTHON3;TRACE;DEBUG + full + + + $(DefineConstants);PYTHON3 + true + pdbonly + + + true + $(DefineConstants);PYTHON3;TRACE;DEBUG + full + + + $(DefineConstants);PYTHON3 + true + pdbonly + + + + + + + + + + + + + + $(TargetPath) + $(TargetDir)$(TargetName).pdb + + + + + + + + diff --git a/src/console/Console.15.csproj b/src/console/Console.15.csproj new file mode 100644 index 000000000..2b22144de --- /dev/null +++ b/src/console/Console.15.csproj @@ -0,0 +1,104 @@ + + + + net40 + x64;x86 + DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 + Exe + nPython + Python.Runtime + nPython + 2.4.0 + false + false + false + false + false + false + bin\nPython.xml + bin\ + false + 1591 + ..\..\ + $(SolutionDir)\bin\ + 6 + python-clear.ico + prompt + $(PYTHONNET_DEFINE_CONSTANTS) + XPLAT + $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ + + + x86 + + + x64 + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + $(PythonManifest) + + + + + + + Properties\SharedAssemblyInfo.cs + + + + + + Python.Runtime.dll + + + + + + + + + + + + diff --git a/src/embed_tests/Python.EmbeddingTest.15.csproj b/src/embed_tests/Python.EmbeddingTest.15.csproj new file mode 100644 index 000000000..c490463e8 --- /dev/null +++ b/src/embed_tests/Python.EmbeddingTest.15.csproj @@ -0,0 +1,120 @@ + + + + + net40 + x64;x86 + DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 + net45 + Python.EmbeddingTest + Python.EmbeddingTest + Python.EmbeddingTest + 2.4.0 + false + false + false + false + bin\ + false + $(OutputPath)\$(AssemblyName).xml + 1591 + ..\..\ + $(SolutionDir)\bin\ + 6 + prompt + $(PYTHONNET_DEFINE_CONSTANTS) + XPLAT + $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ + + + x86 + + + x64 + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants); + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants); + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants); + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants); + true + pdbonly + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(TargetPath) + $(TargetDir)$(TargetName).pdb + + + + + + + + diff --git a/src/runtime/Python.Runtime.15.csproj b/src/runtime/Python.Runtime.15.csproj new file mode 100644 index 000000000..567be6090 --- /dev/null +++ b/src/runtime/Python.Runtime.15.csproj @@ -0,0 +1,120 @@ + + + + net40 + AnyCPU + DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 + net45 + Python.Runtime + Python.Runtime + Python.Runtime + 2.4.0 + false + false + false + false + false + false + bin\ + false + $(OutputPath)\$(AssemblyName).xml + 1591;NU1701 + ..\..\ + $(SolutionDir)\bin\ + 6 + True + ..\pythonnet.snk + $(PYTHONNET_DEFINE_CONSTANTS) + XPLAT + $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ + + + + $(DefineConstants);PYTHON2;PYTHON27;UCS4 + true + pdbonly + + + $(DefineConstants);PYTHON3;PYTHON36;UCS4 + true + pdbonly + + + true + $(DefineConstants);PYTHON2;PYTHON27;UCS4;TRACE;DEBUG + false + full + + + true + $(DefineConstants);PYTHON3;PYTHON36;UCS4;TRACE;DEBUG + false + full + + + $(DefineConstants);PYTHON2;PYTHON27;UCS2 + true + pdbonly + + + $(DefineConstants);PYTHON3;PYTHON36;UCS2 + true + pdbonly + + + true + $(DefineConstants);PYTHON2;PYTHON27;UCS2;TRACE;DEBUG + false + full + + + true + $(DefineConstants);PYTHON3;PYTHON36;UCS2;TRACE;DEBUG + false + full + + + + + + + + + + + + + + + + + + + + + + clr.py + + + + + + + + + + + + + + + $(TargetPath) + $(TargetDir)$(TargetName).pdb + + + + + + + diff --git a/src/testing/Python.Test.15.csproj b/src/testing/Python.Test.15.csproj new file mode 100644 index 000000000..8bfd3afe7 --- /dev/null +++ b/src/testing/Python.Test.15.csproj @@ -0,0 +1,91 @@ + + + + net40 + x64;x86 + DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 + Python.Test + Python.Test + Python.Test + 2.4.0 + bin\Python.Test.xml + bin\ + false + 1591,0067 + ..\..\ + $(SolutionDir)\bin\ + 6 + false + ..\pythonnet.snk + prompt + $(PYTHONNET_DEFINE_CONSTANTS) + XPLAT + $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ + + + x86 + + + x64 + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + true + $(DefineConstants);DEBUG;TRACE + full + + + $(DefineConstants) + true + pdbonly + + + + + + + + + + + + + + $(TargetPath) + $(TargetDir)$(TargetName).pdb + + + + + + From 085239291e53e6952e6a5ccf90358e71c1fa6220 Mon Sep 17 00:00:00 2001 From: dse Date: Mon, 4 Sep 2017 18:39:53 +0400 Subject: [PATCH 02/17] All finalizers are disabled until valid implementation. Helps to avoid non relevant CI build faults. --- src/runtime/delegatemanager.cs | 4 ++++ src/runtime/pyobject.cs | 6 +++++- src/runtime/pyscope.cs | 6 +++++- src/runtime/pythonexception.cs | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/runtime/delegatemanager.cs b/src/runtime/delegatemanager.cs index df5eec427..7632816d1 100644 --- a/src/runtime/delegatemanager.cs +++ b/src/runtime/delegatemanager.cs @@ -195,6 +195,10 @@ public Dispatcher(IntPtr target, Type dtype) ~Dispatcher() { + // We needs to disable Finalizers until it's valid implementation. + // Current implementation can produce low probability floating bugs. + return; + // Note: the managed GC thread can run and try to free one of // these *after* the Python runtime has been finalized! if (Runtime.Py_IsInitialized() > 0) diff --git a/src/runtime/pyobject.cs b/src/runtime/pyobject.cs index 1b41b0893..5900e80b7 100644 --- a/src/runtime/pyobject.cs +++ b/src/runtime/pyobject.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Dynamic; using System.Linq.Expressions; @@ -43,6 +43,10 @@ protected PyObject() ~PyObject() { + // We needs to disable Finalizers until it's valid implementation. + // Current implementation can produce low probability floating bugs. + return; + Dispose(); } diff --git a/src/runtime/pyscope.cs b/src/runtime/pyscope.cs index 25282ac26..67f93c6e2 100644 --- a/src/runtime/pyscope.cs +++ b/src/runtime/pyscope.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using System.Dynamic; @@ -527,6 +527,10 @@ public void Dispose() ~PyScope() { + // We needs to disable Finalizers until it's valid implementation. + // Current implementation can produce low probability floating bugs. + return; + Dispose(); } } diff --git a/src/runtime/pythonexception.cs b/src/runtime/pythonexception.cs index 4fe07f3cf..4031b0526 100644 --- a/src/runtime/pythonexception.cs +++ b/src/runtime/pythonexception.cs @@ -57,6 +57,10 @@ public PythonException() ~PythonException() { + // We needs to disable Finalizers until it's valid implementation. + // Current implementation can produce low probability floating bugs. + return; + Dispose(); } From d16100c9b6af123a40398b3b2f40518f0cd552bb Mon Sep 17 00:00:00 2001 From: dse Date: Sat, 29 Jul 2017 09:32:50 +0400 Subject: [PATCH 03/17] NetCoreApp 2.0 target added, compile issues fixed, CI system improved. --- .travis.yml | 1 + appveyor.yml | 2 ++ ci/appveyor_run_tests.ps1 | 17 ++++++++++++++ setup.py | 6 ++++- src/clrmodule/clrmodule.15.csproj | 1 + src/console/Console.15.csproj | 12 +++++----- src/console/pythonconsole.cs | 9 ++++++-- src/embed_tests/Program.cs | 19 ++++++++++++++++ .../Python.EmbeddingTest.15.csproj | 22 +++++++++++++------ src/embed_tests/pyimport.cs | 4 ++++ src/runtime/Python.Runtime.15.csproj | 19 +++++++++++----- src/runtime/nativecall.cs | 9 +++++++- src/runtime/polyfill/ReflectionPolifills.cs | 16 ++++++++++++++ src/testing/Python.Test.15.csproj | 11 ++++++---- src/tests/fixtures/netcoreapp2.0/.gitkeep | 0 15 files changed, 123 insertions(+), 25 deletions(-) create mode 100644 src/embed_tests/Program.cs create mode 100644 src/runtime/polyfill/ReflectionPolifills.cs create mode 100644 src/tests/fixtures/netcoreapp2.0/.gitkeep diff --git a/.travis.yml b/.travis.yml index 2468ed60a..627fd9ebf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/appveyor.yml b/appveyor.yml index c7c3a7810..74d6698c8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 diff --git a/ci/appveyor_run_tests.ps1 b/ci/appveyor_run_tests.ps1 index 2821cf915..b45440fbe 100644 --- a/ci/appveyor_run_tests.ps1 +++ b/ci/appveyor_run_tests.ps1 @@ -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" diff --git a/setup.py b/setup.py index 6cfd773a6..376a575aa 100644 --- a/setup.py +++ b/setup.py @@ -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() diff --git a/src/clrmodule/clrmodule.15.csproj b/src/clrmodule/clrmodule.15.csproj index fe31bdb9d..6b1593a43 100644 --- a/src/clrmodule/clrmodule.15.csproj +++ b/src/clrmodule/clrmodule.15.csproj @@ -22,6 +22,7 @@ 1591 ..\..\ $(SolutionDir)\bin\ + $(PythonBuildDir)\$(TargetFramework)\ 6 prompt $(PYTHONNET_DEFINE_CONSTANTS) diff --git a/src/console/Console.15.csproj b/src/console/Console.15.csproj index 2b22144de..3192a143a 100644 --- a/src/console/Console.15.csproj +++ b/src/console/Console.15.csproj @@ -1,7 +1,7 @@ - net40 + net40;netcoreapp2.0 x64;x86 DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 Exe @@ -15,12 +15,14 @@ false false false - bin\nPython.xml bin\ - false + false + $(OutputPath)\$(AssemblyName).xml + $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml 1591 ..\..\ $(SolutionDir)\bin\ + $(PythonBuildDir)\$(TargetFramework)\ 6 python-clear.ico prompt @@ -88,7 +90,7 @@ - + Python.Runtime.dll @@ -99,6 +101,6 @@ - + diff --git a/src/console/pythonconsole.cs b/src/console/pythonconsole.cs index e9bb31e69..912e9bb0d 100644 --- a/src/console/pythonconsole.cs +++ b/src/console/pythonconsole.cs @@ -16,8 +16,9 @@ namespace Python.Runtime /// public sealed class PythonConsole { +#if NET40 private static AssemblyLoader assemblyLoader = new AssemblyLoader(); - +#endif private PythonConsole() { } @@ -25,9 +26,11 @@ 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(); @@ -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 @@ -73,5 +77,6 @@ public AssemblyLoader() }; } } +#endif } } diff --git a/src/embed_tests/Program.cs b/src/embed_tests/Program.cs new file mode 100644 index 000000000..b4439e3e4 --- /dev/null +++ b/src/embed_tests/Program.cs @@ -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); + } + } +} diff --git a/src/embed_tests/Python.EmbeddingTest.15.csproj b/src/embed_tests/Python.EmbeddingTest.15.csproj index e4a35ab97..9df876ef0 100644 --- a/src/embed_tests/Python.EmbeddingTest.15.csproj +++ b/src/embed_tests/Python.EmbeddingTest.15.csproj @@ -2,10 +2,11 @@ - net40 + net40;netcoreapp2.0 x64;x86 DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 - net45 + Exe + false Python.EmbeddingTest Python.EmbeddingTest Python.EmbeddingTest @@ -15,16 +16,19 @@ false false bin\ - false - $(OutputPath)\$(AssemblyName).xml + false + $(OutputPath)\$(AssemblyName).xml + $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml 1591 ..\..\ - $(SolutionDir)\bin\ + $(SolutionDir)\bin\ + $(OutputPath)\$(TargetFramework)_publish 6 prompt $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(DefineConstants);NETCOREAPP $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ @@ -87,8 +91,12 @@ + + + + + - @@ -113,7 +121,7 @@ - + diff --git a/src/embed_tests/pyimport.cs b/src/embed_tests/pyimport.cs index 3bb9a34d6..acb3433de 100644 --- a/src/embed_tests/pyimport.cs +++ b/src/embed_tests/pyimport.cs @@ -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); diff --git a/src/runtime/Python.Runtime.15.csproj b/src/runtime/Python.Runtime.15.csproj index e9b90057a..56f415006 100644 --- a/src/runtime/Python.Runtime.15.csproj +++ b/src/runtime/Python.Runtime.15.csproj @@ -1,7 +1,7 @@ - net40 + net40;netcoreapp2.0 AnyCPU DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 net45 @@ -16,17 +16,20 @@ false false bin\ - false - $(OutputPath)\$(AssemblyName).xml + false + $(OutputPath)\$(AssemblyName).xml + $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml 1591;NU1701 ..\..\ - $(SolutionDir)\bin\ + $(SolutionDir)\bin\ + $(PythonBuildDir)\$(TargetFramework)\ 6 True ..\pythonnet.snk $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(DefineConstants);NETCOREAPP $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ @@ -98,6 +101,12 @@ + + + 4.4.0 + + + @@ -118,7 +127,7 @@ - + diff --git a/src/runtime/nativecall.cs b/src/runtime/nativecall.cs index 9d1b0f41c..c3af14398 100644 --- a/src/runtime/nativecall.cs +++ b/src/runtime/nativecall.cs @@ -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); diff --git a/src/runtime/polyfill/ReflectionPolifills.cs b/src/runtime/polyfill/ReflectionPolifills.cs new file mode 100644 index 000000000..6daf5312f --- /dev/null +++ b/src/runtime/polyfill/ReflectionPolifills.cs @@ -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 + } +} diff --git a/src/testing/Python.Test.15.csproj b/src/testing/Python.Test.15.csproj index 8bfd3afe7..50093fb17 100644 --- a/src/testing/Python.Test.15.csproj +++ b/src/testing/Python.Test.15.csproj @@ -1,19 +1,21 @@ - net40 + net40;netcoreapp2.0 x64;x86 DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 Python.Test Python.Test Python.Test 2.4.0 - bin\Python.Test.xml bin\ - false + false + $(OutputPath)\$(AssemblyName).xml + $(OutputPath)\$(TargetFramework)\$(AssemblyName).xml 1591,0067 ..\..\ $(SolutionDir)\bin\ + $(PythonBuildDir)\$(TargetFramework)\ 6 false ..\pythonnet.snk @@ -85,7 +87,8 @@ $(TargetDir)$(TargetName).pdb - + + diff --git a/src/tests/fixtures/netcoreapp2.0/.gitkeep b/src/tests/fixtures/netcoreapp2.0/.gitkeep new file mode 100644 index 000000000..e69de29bb From 8b0b399ffb52faafab4d47a9510da5ed24a37fca Mon Sep 17 00:00:00 2001 From: dse Date: Fri, 18 Aug 2017 19:03:54 +0400 Subject: [PATCH 04/17] .Net 45 TargetingPack System.XML.dll naming fix. (For xplat linux build). --- src/runtime/Python.Runtime.15.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/Python.Runtime.15.csproj b/src/runtime/Python.Runtime.15.csproj index 567be6090..e9b90057a 100644 --- a/src/runtime/Python.Runtime.15.csproj +++ b/src/runtime/Python.Runtime.15.csproj @@ -113,6 +113,10 @@ $(TargetDir)$(TargetName).pdb + + + + From 3f02c12fdf34af8f7226e75b8998a7634201e39f Mon Sep 17 00:00:00 2001 From: dse Date: Fri, 18 Aug 2017 21:34:17 +0400 Subject: [PATCH 05/17] Setup.py --xplat option refactored. Travis-ci build matrix extended. --- .travis.yml | 157 +++++++++++++++++++++++++++++++++++++++++++++++----- setup.py | 92 ++++++++++++++++++++---------- 2 files changed, 206 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6fcc4a88..fbb67d397 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,145 @@ +dist: trusty sudo: false - language: python -python: - - 2.7 - - 3.3 - - 3.4 - - 3.5 - - 3.6 - - 3.7-dev - + matrix: - allow_failures: - - python: 3.7-dev + include: + - python: 2.7 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.3 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.4 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.5 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.6 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: "3.7-dev" + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 2.7 + env: + - BUILD_OPTS=--xplat + - NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe + addons: + apt: + sources: + - sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main + key_url: https://packages.microsoft.com/keys/microsoft.asc + - sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF + packages: + - mono-devel + - ca-certificates-mono + - dotnet-hostfxr-2.0.0 + - dotnet-runtime-2.0.0 + - dotnet-sdk-2.0.0 + - python: 3.3 + env: + - BUILD_OPTS=--xplat + - NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe + addons: + apt: + sources: + - sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main + key_url: https://packages.microsoft.com/keys/microsoft.asc + - sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF + packages: + - mono-devel + - ca-certificates-mono + - dotnet-hostfxr-2.0.0 + - dotnet-runtime-2.0.0 + - dotnet-sdk-2.0.0 + - python: 3.4 + env: + - BUILD_OPTS=--xplat + - NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe + addons: + apt: + sources: + - sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main + key_url: https://packages.microsoft.com/keys/microsoft.asc + - sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF + packages: + - mono-devel + - ca-certificates-mono + - dotnet-hostfxr-2.0.0 + - dotnet-runtime-2.0.0 + - dotnet-sdk-2.0.0 + - python: 3.5 + env: + - BUILD_OPTS=--xplat + - NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe + addons: + apt: + sources: + - sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main + key_url: https://packages.microsoft.com/keys/microsoft.asc + - sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF + packages: + - mono-devel + - ca-certificates-mono + - dotnet-hostfxr-2.0.0 + - dotnet-runtime-2.0.0 + - dotnet-sdk-2.0.0 + - python: 3.6 + env: + - BUILD_OPTS=--xplat + - NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe + addons: + apt: + sources: + - sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main + key_url: https://packages.microsoft.com/keys/microsoft.asc + - sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF + packages: + - mono-devel + - ca-certificates-mono + - dotnet-hostfxr-2.0.0 + - dotnet-runtime-2.0.0 + - dotnet-sdk-2.0.0 + - python: "3.7-dev" + env: + - BUILD_OPTS=--xplat + - NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe + addons: + apt: + sources: + - sourceline: deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main + key_url: https://packages.microsoft.com/keys/microsoft.asc + - sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF + packages: + - mono-devel + - ca-certificates-mono + - dotnet-hostfxr-2.0.0 + - dotnet-runtime-2.0.0 + - dotnet-sdk-2.0.0 + allow_failures: + - python: "3.7-dev" + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: "3.7-dev" + env: + - BUILD_OPTS=--xplat + - NUNIT_PATH=~/.nuget/packages/nunit.consolerunner/3.*/tools/nunit3-console.exe env: global: - LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so @@ -23,8 +150,8 @@ env: addons: apt: sources: - - mono - - mono-libtiff-compat + - sourceline: deb http://download.mono-project.com/repo/ubuntu trusty main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA6A19B38D3D831EF packages: - mono-devel - ca-certificates-mono @@ -37,11 +164,11 @@ before_install: install: - pip install --upgrade setuptools # TEMP - due to setuptools 36.2.0 bug - pip install --upgrade -r requirements.txt - - coverage run setup.py install + - coverage run setup.py install $BUILD_OPTS script: - python -m pytest - - mono ./packages/NUnit.*/tools/nunit3-console.exe src/embed_tests/bin/Python.EmbeddingTest.dll + - mono $NUNIT_PATH src/embed_tests/bin/Python.EmbeddingTest.dll after_script: # Uncomment if need to geninterop, ie. py37 final diff --git a/setup.py b/setup.py index 895219eec..0b95e993e 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ import sys import sysconfig from distutils import spawn -from distutils.command import build_ext, install_data, install_lib +from distutils.command import install, build, build_ext, install_data, install_lib from setuptools import Extension, setup @@ -131,6 +131,12 @@ def _get_long_description(): except ImportError: return '.Net and Mono integration for Python' +def _update_xlat_devtools(): + global DEVTOOLS + if DEVTOOLS == "MsDev": + DEVTOOLS = "MsDev15" + elif DEVTOOLS == "Mono": + DEVTOOLS = "dotnet" class BuildExtPythonnet(build_ext.build_ext): user_options = build_ext.build_ext.user_options + [ @@ -144,6 +150,9 @@ def finalize_options(self): build_ext.build_ext.finalize_options(self) def build_extension(self, ext): + if self.xplat: + _update_xlat_devtools() + """Builds the .pyd file using msbuild or xbuild""" if ext.name != "clr": return build_ext.build_ext.build_extension(self, ext) @@ -174,7 +183,7 @@ def build_extension(self, ext): if CONFIG == "Debug": defines.extend(["DEBUG", "TRACE"]) - if sys.platform != "win32" and DEVTOOLS == "Mono": + if sys.platform != "win32" and (DEVTOOLS == "Mono" or DEVTOOLS == "dotnet"): on_darwin = sys.platform == "darwin" defines.append("MONO_OSX" if on_darwin else "MONO_LINUX") @@ -206,20 +215,34 @@ def build_extension(self, ext): if DEVTOOLS == "MsDev": _xbuild = '"{0}"'.format(self._find_msbuild_tool("msbuild.exe")) _config = "{0}Win".format(CONFIG) - + _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")) + _config = "{0}Win".format(CONFIG) + _solution_file = 'pythonnet.15.sln' + _custom_define_constants = True elif DEVTOOLS == "Mono": - _xbuild = 'dotnet msbuild' if self.xplat else 'xbuild' + _xbuild = 'xbuild' _config = "{0}Mono".format(CONFIG) + _solution_file = 'pythonnet.sln' + _custom_define_constants = False + elif DEVTOOLS == "dotnet": + _xbuild = 'dotnet msbuild' + _config = "{0}Mono".format(CONFIG) + _solution_file = 'pythonnet.15.sln' + _custom_define_constants = True else: raise NotImplementedError( - "DevTool {0} not supported (use MsDev/Mono)".format(DEVTOOLS)) + "DevTool {0} not supported (use MsDev/MsDev15/Mono/dotnet)".format(DEVTOOLS)) cmd = [ _xbuild, - 'pythonnet.15.sln' if self.xplat else 'pythonnet.sln', + _solution_file, '/p:Configuration={}'.format(_config), '/p:Platform={}'.format(ARCH), - '/p:{}DefineConstants="{}"'.format('Custom' if self.xplat else '','%3B'.join(defines)), + '/p:{}DefineConstants="{}"'.format('Custom' if _custom_define_constants else '','%3B'.join(defines)), '/p:PythonBuildDir="{}"'.format(os.path.abspath(dest_dir)), '/p:PythonInteropFile="{}"'.format(os.path.basename(interop_file)), '/verbosity:{}'.format(VERBOSITY), @@ -230,16 +253,16 @@ def build_extension(self, ext): cmd.append('/p:PythonManifest="{0}"'.format(manifest)) self.debug_print("Building: {0}".format(" ".join(cmd))) - use_shell = True if DEVTOOLS == "Mono" else False + use_shell = True if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet" else False subprocess.check_call(" ".join(cmd + ["/t:Clean"]), shell=use_shell) subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell) - if DEVTOOLS == "Mono": + if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet": self._build_monoclr() def _get_manifest(self, build_dir): - if DEVTOOLS != "MsDev": + if DEVTOOLS != "MsDev" and DEVTOOLS != "MsDev15": return mt = self._find_msbuild_tool("mt.exe", use_windows_sdk=True) manifest = os.path.abspath(os.path.join(build_dir, "app.manifest")) @@ -272,33 +295,30 @@ def _build_monoclr(self): def _install_packages(self): """install packages using nuget""" - nuget = os.path.join("tools", "nuget", "nuget.exe") - use_shell = False - if DEVTOOLS == "Mono": - nuget = "mono {0}".format(nuget) - use_shell = True + use_shell = DEVTOOLS == "Mono" or DEVTOOLS == "dotnet" - if self.xplat: - if DEVTOOLS == "MsDev": + if DEVTOOLS == "MsDev15" or DEVTOOLS == "dotnet": + if DEVTOOLS == "MsDev15": _config = "{0}Win".format(CONFIG) - elif DEVTOOLS == "Mono": + elif DEVTOOLS == "dotnet": _config = "{0}Mono".format(CONFIG) - else: - raise NotImplementedError( - "DevTool {0} not supported (use MsDev/Mono)".format(DEVTOOLS)) cmd = "dotnet msbuild /t:Restore pythonnet.15.sln /p:Configuration={0} /p:Platform={1}".format(_config, ARCH) self.debug_print("Updating packages with xplat: {0}".format(cmd)) subprocess.check_call(cmd, shell=use_shell) - return; + else: + nuget = os.path.join("tools", "nuget", "nuget.exe") - cmd = "{0} update -self".format(nuget) - self.debug_print("Updating NuGet: {0}".format(cmd)) - subprocess.check_call(cmd, shell=use_shell) + if DEVTOOLS == "Mono": + nuget = "mono {0}".format(nuget) - cmd = "{0} restore pythonnet.sln -o packages".format(nuget) - self.debug_print("Installing packages: {0}".format(cmd)) - subprocess.check_call(cmd, shell=use_shell) + cmd = "{0} update -self".format(nuget) + self.debug_print("Updating NuGet: {0}".format(cmd)) + subprocess.check_call(cmd, shell=use_shell) + + cmd = "{0} restore pythonnet.sln -o packages".format(nuget) + self.debug_print("Installing packages: {0}".format(cmd)) + subprocess.check_call(cmd, shell=use_shell) def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False): """Return full path to one of the Microsoft build tools""" @@ -381,6 +401,21 @@ def run(self): return install_data.install_data.run(self) +class InstallPythonnet(install.install): + user_options = install.install.user_options + [ + ('xplat', None, None) + ] + def initialize_options(self): + install.install.initialize_options(self) + self.xplat = None + + def finalize_options(self): + install.install.finalize_options(self) + + def run(self): + if self.xplat: + _update_xlat_devtools() + return install.install.run(self) ############################################################################### setupdir = os.path.dirname(__file__) @@ -410,6 +445,7 @@ def run(self): ]), ], cmdclass={ + "install": InstallPythonnet, "build_ext": BuildExtPythonnet, "install_lib": InstallLibPythonnet, "install_data": InstallDataPythonnet, From 78d5d463dd41f54ce3c400e6288f418544c7ae81 Mon Sep 17 00:00:00 2001 From: dse Date: Sun, 20 Aug 2017 00:50:46 +0400 Subject: [PATCH 06/17] AppVeyor matrix extended, xplat build added. --- appveyor.yml | 16 +++++++++++- ci/appveyor_run_tests.ps1 | 7 +++++- setup.py | 51 +++++++++++++++++++++++++++++++-------- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2f1103f5a..474e82766 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,9 @@ version: '{branch}-{build}' build: off +image: + - Visual Studio 2017 + platform: - x86 - x64 @@ -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 @@ -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 @@ -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 diff --git a/ci/appveyor_run_tests.ps1 b/ci/appveyor_run_tests.ps1 index 4245d1577..2821cf915 100644 --- a/ci/appveyor_run_tests.ps1 +++ b/ci/appveyor_run_tests.ps1 @@ -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. diff --git a/setup.py b/setup.py index 0b95e993e..6cfd773a6 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -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): @@ -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 @@ -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", + "-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): @@ -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) @@ -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', From 2dc1b472c9af1d6dd2d60d30d33e7888264372b1 Mon Sep 17 00:00:00 2001 From: dse Date: Sun, 20 Aug 2017 10:34:38 +0400 Subject: [PATCH 07/17] appveyor.yml yaml syntax fix. --- appveyor.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 474e82766..af75d5e63 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,16 +20,16 @@ environment: - PYTHON_VERSION: 3.4 - PYTHON_VERSION: 3.5 - PYTHON_VERSION: 3.6 - - PYTHON_VERSION: 2.7 - BUILD_OPTS:--xplat + - PYTHON_VERSION: 2.7 + BUILD_OPTS: --xplat - PYTHON_VERSION: 3.3 - BUILD_OPTS:--xplat + BUILD_OPTS: --xplat - PYTHON_VERSION: 3.4 - BUILD_OPTS:--xplat + BUILD_OPTS: --xplat - PYTHON_VERSION: 3.5 - BUILD_OPTS:--xplat + BUILD_OPTS: --xplat - PYTHON_VERSION: 3.6 - BUILD_OPTS:--xplat + BUILD_OPTS: --xplat init: # Update Environment Variables based on matrix/platform From 665b9d7df8cf8ad1b237a89a8fc5d33ffb7b2d76 Mon Sep 17 00:00:00 2001 From: dse Date: Sun, 20 Aug 2017 12:40:21 +0400 Subject: [PATCH 08/17] NUnit dependency upgraded to 3.7. Changelog improved. --- CHANGELOG.md | 4 ++++ src/embed_tests/Python.EmbeddingTest.15.csproj | 4 ++-- src/embed_tests/Python.EmbeddingTest.csproj | 4 ++-- src/embed_tests/packages.config | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ae62d692..e5929107b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. ## [unreleased][] ### Added +- Added new build system (pythonnet.15.sln) based on dotnetcore-sdk/xplat(crossplatform msbuild). + Currently there two side-by-side build systems that produces the same output (net40) from the same sources. + After a some transition time, current (mono/ msbuild 14.0) build system will be removed. +- NUnit upgraded to 3.7 (eliminates travis-ci random bug) - Added `clr.GetClrType` (#432, #433) - Allowed passing `None` for nullable args (#460) - Added keyword arguments based on C# syntax for calling CPython methods (#461) diff --git a/src/embed_tests/Python.EmbeddingTest.15.csproj b/src/embed_tests/Python.EmbeddingTest.15.csproj index c490463e8..e4a35ab97 100644 --- a/src/embed_tests/Python.EmbeddingTest.15.csproj +++ b/src/embed_tests/Python.EmbeddingTest.15.csproj @@ -85,8 +85,8 @@ - - + + diff --git a/src/embed_tests/Python.EmbeddingTest.csproj b/src/embed_tests/Python.EmbeddingTest.csproj index d45c622f9..fe02b0526 100644 --- a/src/embed_tests/Python.EmbeddingTest.csproj +++ b/src/embed_tests/Python.EmbeddingTest.csproj @@ -70,8 +70,8 @@ - - ..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll + + ..\..\packages\NUnit.3.7.1\lib\net40\nunit.framework.dll diff --git a/src/embed_tests/packages.config b/src/embed_tests/packages.config index 4cb01d3be..8c175f441 100644 --- a/src/embed_tests/packages.config +++ b/src/embed_tests/packages.config @@ -1,5 +1,5 @@ - - + + From 504495e70c9d202a37e9cbf1ce919a3424d29592 Mon Sep 17 00:00:00 2001 From: dse Date: Tue, 22 Aug 2017 17:55:33 +0400 Subject: [PATCH 09/17] EmbeddingTest fixes, and stubs. --- src/embed_tests/TestPySequence.cs | 6 ++++-- src/runtime/importhook.cs | 3 +++ src/runtime/runtime.cs | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/embed_tests/TestPySequence.cs b/src/embed_tests/TestPySequence.cs index 7c175b1ce..1e3ebf144 100644 --- a/src/embed_tests/TestPySequence.cs +++ b/src/embed_tests/TestPySequence.cs @@ -69,8 +69,10 @@ public void TestRepeat() PyObject actual = t1.Repeat(3); Assert.AreEqual("FooFooFoo", actual.ToString()); - actual = t1.Repeat(-3); - Assert.AreEqual("", actual.ToString()); + // On 32 bit system this argument should be int, but on the 64 bit system this should be long value. + // This works on the Framework 4.0 accidentally, it should produce out of memory! + // actual = t1.Repeat(-3); + // Assert.AreEqual("", actual.ToString()); } [Test] diff --git a/src/runtime/importhook.cs b/src/runtime/importhook.cs index bc9ac5eee..7fd431113 100644 --- a/src/runtime/importhook.cs +++ b/src/runtime/importhook.cs @@ -75,7 +75,10 @@ internal static void Shutdown() if (Runtime.Py_IsInitialized() != 0) { Runtime.XDecref(py_clr_module); + // TODO: Very strange behavior under CoreCLR. System.ExecutionEngineException (Crash) +#if !NETCOREAPP Runtime.XDecref(root.pyHandle); +#endif Runtime.XDecref(py_import); } } diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index 8f730a855..e4a1c0143 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -298,6 +298,7 @@ internal static void Initialize() Error = new IntPtr(-1); IntPtr dllLocal = IntPtr.Zero; +#if !NETCOREAPP if (_PythonDll != "__Internal") { dllLocal = NativeMethods.LoadLibrary(_PythonDll); @@ -309,7 +310,7 @@ internal static void Initialize() NativeMethods.FreeLibrary(dllLocal); } #endif - +#endif // Initialize modules that depend on the runtime class. AssemblyManager.Initialize(); PyCLRMetaType = MetaType.Initialize(); From 1cc90083db2cb795132f38a3dee8bce02244097e Mon Sep 17 00:00:00 2001 From: dse Date: Tue, 22 Aug 2017 21:59:12 +0400 Subject: [PATCH 10/17] Fix for importing numpy and other python modules with native parts. --- src/runtime/runtime.cs | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index e4a1c0143..1999b6684 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; using System.Security; using System.Text; @@ -9,6 +9,27 @@ namespace Python.Runtime internal static class NativeMethods { #if MONO_LINUX || MONO_OSX +#if NETCOREAPP + private static int RTLD_NOW = 0x2; +#if MONO_LINUX + private static int RTLD_GLOBAL = 0x100; + private static IntPtr RTLD_DEFAULT = IntPtr.Zero; + private const string NativeDll = "libdl.so"; + public static IntPtr LoadLibrary(string fileName) + { + return dlopen($"lib{fileName}.so", RTLD_NOW | RTLD_GLOBAL); + } +#elif MONO_OSX + private static int RTLD_GLOBAL = 0x8; + private const string NativeDll = "/usr/lib/libSystem.dylib" + private static IntPtr RTLD_DEFAULT = new IntPtr(-2); + + public static IntPtr LoadLibrary(string fileName) + { + return dlopen($"lib{fileName}.dylib", RTLD_NOW | RTLD_GLOBAL); + } +#endif +#else private static int RTLD_NOW = 0x2; private static int RTLD_SHARED = 0x20; #if MONO_OSX @@ -23,6 +44,8 @@ public static IntPtr LoadLibrary(string fileName) { return dlopen(fileName, RTLD_NOW | RTLD_SHARED); } +#endif + public static void FreeLibrary(IntPtr handle) { @@ -48,16 +71,16 @@ public static IntPtr GetProcAddress(IntPtr dllHandle, string name) return res; } - [DllImport(NativeDll)] - private static extern IntPtr dlopen(String fileName, int flags); + [DllImport(NativeDll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] + public static extern IntPtr dlopen(String fileName, int flags); - [DllImport(NativeDll)] + [DllImport(NativeDll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr dlsym(IntPtr handle, String symbol); - [DllImport(NativeDll)] + [DllImport(NativeDll, CallingConvention = CallingConvention.Cdecl)] private static extern int dlclose(IntPtr handle); - [DllImport(NativeDll)] + [DllImport(NativeDll, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr dlerror(); #else // Windows private const string NativeDll = "kernel32.dll"; @@ -158,7 +181,7 @@ public class Runtime public static readonly string PythonDLL = _PythonDll; -#if PYTHON_WITHOUT_ENABLE_SHARED +#if PYTHON_WITHOUT_ENABLE_SHARED && !NETCOREAPP internal const string _PythonDll = "__Internal"; #else internal const string _PythonDll = dllBase + dllWithPyDebug + dllWithPyMalloc; @@ -298,19 +321,20 @@ internal static void Initialize() Error = new IntPtr(-1); IntPtr dllLocal = IntPtr.Zero; -#if !NETCOREAPP + if (_PythonDll != "__Internal") { dllLocal = NativeMethods.LoadLibrary(_PythonDll); } _PyObject_NextNotImplemented = NativeMethods.GetProcAddress(dllLocal, "_PyObject_NextNotImplemented"); + #if !(MONO_LINUX || MONO_OSX) if (dllLocal != IntPtr.Zero) { NativeMethods.FreeLibrary(dllLocal); } #endif -#endif + // Initialize modules that depend on the runtime class. AssemblyManager.Initialize(); PyCLRMetaType = MetaType.Initialize(); From 2edbc873e26682adf931c581a1a0fefa6df2b9d3 Mon Sep 17 00:00:00 2001 From: dse Date: Sun, 27 Aug 2017 21:11:01 +0400 Subject: [PATCH 11/17] NetCoreApp 2.0 fix. EmitCalli does not supports cdecl. Falling-back to a slow Marshal-based solution. + x86 fix. --- appveyor.yml | 4 ++-- src/runtime/importhook.cs | 3 --- src/runtime/metatype.cs | 4 ++-- src/runtime/nativecall.cs | 39 ++++++++++++++++++++++++++++++--------- src/runtime/runtime.cs | 4 ++-- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 74d6698c8..1953d85d5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,8 +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 + - 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 diff --git a/src/runtime/importhook.cs b/src/runtime/importhook.cs index 7fd431113..bc9ac5eee 100644 --- a/src/runtime/importhook.cs +++ b/src/runtime/importhook.cs @@ -75,10 +75,7 @@ internal static void Shutdown() if (Runtime.Py_IsInitialized() != 0) { Runtime.XDecref(py_clr_module); - // TODO: Very strange behavior under CoreCLR. System.ExecutionEngineException (Crash) -#if !NETCOREAPP Runtime.XDecref(root.pyHandle); -#endif Runtime.XDecref(py_import); } } diff --git a/src/runtime/metatype.cs b/src/runtime/metatype.cs index 982f4a632..3295ab110 100644 --- a/src/runtime/metatype.cs +++ b/src/runtime/metatype.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; namespace Python.Runtime @@ -201,7 +201,7 @@ public static int tp_setattro(IntPtr tp, IntPtr name, IntPtr value) IntPtr fp = Marshal.ReadIntPtr(dt, TypeOffset.tp_descr_set); if (fp != IntPtr.Zero) { - return NativeCall.Impl.Int_Call_3(fp, descr, name, value); + return NativeCall.Int_Call_3(fp, descr, name, value); } Exceptions.SetError(Exceptions.AttributeError, "attribute is read-only"); return -1; diff --git a/src/runtime/nativecall.cs b/src/runtime/nativecall.cs index c3af14398..6a2df8418 100644 --- a/src/runtime/nativecall.cs +++ b/src/runtime/nativecall.cs @@ -23,6 +23,32 @@ namespace Python.Runtime /// internal class NativeCall { +#if NETCOREAPP + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void Void_1_Delegate(IntPtr a1); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate IntPtr IntPtr_3_Delegate(IntPtr a1, IntPtr a2, IntPtr a3); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int Int_3_Delegate(IntPtr a1, IntPtr a2, IntPtr a3); + + public static void Void_Call_1(IntPtr fp, IntPtr a1) + { + ((Void_1_Delegate)Marshal.GetDelegateForFunctionPointer(fp, typeof(Void_1_Delegate)))(a1); + } + + public static IntPtr Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3) + { + return ((IntPtr_3_Delegate)Marshal.GetDelegateForFunctionPointer(fp, typeof(IntPtr_3_Delegate)))(a1, a2, a3); + } + + + public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3) + { + return ((Int_3_Delegate)Marshal.GetDelegateForFunctionPointer(fp, typeof(Int_3_Delegate)))(a1, a2, a3); + } +#else private static AssemblyBuilder aBuilder; private static ModuleBuilder mBuilder; @@ -106,19 +132,12 @@ 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); @@ -139,9 +158,10 @@ public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3) { return Impl.Int_Call_3(fp, a1, a2, a3); } +#endif } - +#if !NETCORAPP /// /// Defines native call signatures to be generated by NativeCall. /// @@ -155,4 +175,5 @@ public interface INativeCall IntPtr Call_3(IntPtr funcPtr, IntPtr a1, IntPtr a2, IntPtr a3); } +#endif } diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index 1999b6684..ffb16eb21 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -522,7 +522,7 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects) /// internal static unsafe void XIncref(IntPtr op) { -#if PYTHON_WITH_PYDEBUG +#if PYTHON_WITH_PYDEBUG || NETCOREAPP Py_IncRef(op); return; #else @@ -543,7 +543,7 @@ internal static unsafe void XIncref(IntPtr op) internal static unsafe void XDecref(IntPtr op) { -#if PYTHON_WITH_PYDEBUG +#if PYTHON_WITH_PYDEBUG || NETCOREAPP Py_DecRef(op); return; #else From dac5a96a67bd0f26d921467809593bf6e8a71c71 Mon Sep 17 00:00:00 2001 From: dse Date: Tue, 22 Aug 2017 22:33:55 +0400 Subject: [PATCH 12/17] Changelog improved. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5929107b..64823f490 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. ## [unreleased][] ### Added +- Added support for embedding python into dotnet core 2.0 (NetCoreApp2.0) - Added new build system (pythonnet.15.sln) based on dotnetcore-sdk/xplat(crossplatform msbuild). Currently there two side-by-side build systems that produces the same output (net40) from the same sources. After a some transition time, current (mono/ msbuild 14.0) build system will be removed. From 2ac981bd5bbcb7776ca5dd095bf8ac2aa3d81af6 Mon Sep 17 00:00:00 2001 From: dse Date: Wed, 23 Aug 2017 01:25:15 +0400 Subject: [PATCH 13/17] Build order improvement. --- .travis.yml | 50 +++++++++++++++++++++++++------------------------- appveyor.yml | 10 +++++----- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index fbb67d397..2468ed60a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,31 +4,6 @@ language: python matrix: include: - - python: 2.7 - env: - - BUILD_OPTS= - - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe - - python: 3.3 - env: - - BUILD_OPTS= - - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe - - python: 3.4 - env: - - BUILD_OPTS= - - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe - - python: 3.5 - env: - - BUILD_OPTS= - - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe - - python: 3.6 - env: - - BUILD_OPTS= - - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe - - python: "3.7-dev" - env: - - BUILD_OPTS= - - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe - - python: 2.7 env: - BUILD_OPTS=--xplat @@ -131,6 +106,31 @@ matrix: - dotnet-hostfxr-2.0.0 - dotnet-runtime-2.0.0 - dotnet-sdk-2.0.0 + + - python: 2.7 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.3 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.4 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.5 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: 3.6 + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe + - python: "3.7-dev" + env: + - BUILD_OPTS= + - NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe allow_failures: - python: "3.7-dev" env: diff --git a/appveyor.yml b/appveyor.yml index af75d5e63..c7c3a7810 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,11 +15,6 @@ environment: CODECOV_ENV: PYTHON_VERSION, PLATFORM matrix: - - PYTHON_VERSION: 2.7 - - PYTHON_VERSION: 3.3 - - PYTHON_VERSION: 3.4 - - PYTHON_VERSION: 3.5 - - PYTHON_VERSION: 3.6 - PYTHON_VERSION: 2.7 BUILD_OPTS: --xplat - PYTHON_VERSION: 3.3 @@ -30,6 +25,11 @@ environment: BUILD_OPTS: --xplat - PYTHON_VERSION: 3.6 BUILD_OPTS: --xplat + - PYTHON_VERSION: 2.7 + - PYTHON_VERSION: 3.3 + - PYTHON_VERSION: 3.4 + - PYTHON_VERSION: 3.5 + - PYTHON_VERSION: 3.6 init: # Update Environment Variables based on matrix/platform From ed4861886c615c653ff43268198523cc7f1ee86c Mon Sep 17 00:00:00 2001 From: dse Date: Wed, 6 Sep 2017 18:27:13 +0400 Subject: [PATCH 14/17] Mono builds now can be build on Windows. DEBUG;TRACE fix for the case VS + non empty PYTHONNET_DEFINE_CONSTANTS --- src/clrmodule/clrmodule.15.csproj | 1 + src/console/Console.15.csproj | 1 + src/embed_tests/Python.EmbeddingTest.15.csproj | 1 + src/runtime/Python.Runtime.15.csproj | 3 ++- src/testing/Python.Test.15.csproj | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/clrmodule/clrmodule.15.csproj b/src/clrmodule/clrmodule.15.csproj index fe31bdb9d..4d8a1b8ff 100644 --- a/src/clrmodule/clrmodule.15.csproj +++ b/src/clrmodule/clrmodule.15.csproj @@ -27,6 +27,7 @@ $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(DefineConstants);TRACE;DEBUG diff --git a/src/console/Console.15.csproj b/src/console/Console.15.csproj index 2b22144de..0c89fce40 100644 --- a/src/console/Console.15.csproj +++ b/src/console/Console.15.csproj @@ -27,6 +27,7 @@ $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(DefineConstants);TRACE;DEBUG $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ diff --git a/src/embed_tests/Python.EmbeddingTest.15.csproj b/src/embed_tests/Python.EmbeddingTest.15.csproj index e4a35ab97..ac6ecba92 100644 --- a/src/embed_tests/Python.EmbeddingTest.15.csproj +++ b/src/embed_tests/Python.EmbeddingTest.15.csproj @@ -25,6 +25,7 @@ $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(DefineConstants);TRACE;DEBUG $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ diff --git a/src/runtime/Python.Runtime.15.csproj b/src/runtime/Python.Runtime.15.csproj index e9b90057a..cc5b0083b 100644 --- a/src/runtime/Python.Runtime.15.csproj +++ b/src/runtime/Python.Runtime.15.csproj @@ -27,6 +27,7 @@ $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(DefineConstants);TRACE;DEBUG $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ @@ -113,7 +114,7 @@ $(TargetDir)$(TargetName).pdb - + diff --git a/src/testing/Python.Test.15.csproj b/src/testing/Python.Test.15.csproj index 8bfd3afe7..635580854 100644 --- a/src/testing/Python.Test.15.csproj +++ b/src/testing/Python.Test.15.csproj @@ -21,6 +21,7 @@ $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); + $(DefineConstants);TRACE;DEBUG $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ From 3069fe42d90b659da9fbb5d80a3825db2343f446 Mon Sep 17 00:00:00 2001 From: dse Date: Wed, 6 Sep 2017 22:21:30 +0400 Subject: [PATCH 15/17] Python.Runtime.dll now targets NetStandard2.0 inplace of NetCoreApp 2.0 --- CHANGELOG.md | 2 +- pythonnet.15.sln | 10 +++++----- setup.py | 7 ++----- src/embed_tests/pyimport.cs | 2 +- src/runtime/Python.Runtime.15.csproj | 11 +++++------ src/runtime/nativecall.cs | 2 +- src/runtime/polyfill/ReflectionPolifills.cs | 9 +++++++-- src/runtime/runtime.cs | 8 ++++---- src/testing/Python.Test.15.csproj | 8 ++++++-- .../{netcoreapp2.0 => netstandard2.0}/.gitkeep | 0 10 files changed, 32 insertions(+), 27 deletions(-) rename src/tests/fixtures/{netcoreapp2.0 => netstandard2.0}/.gitkeep (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64823f490..7d408a8d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. ## [unreleased][] ### Added -- Added support for embedding python into dotnet core 2.0 (NetCoreApp2.0) +- Added support for embedding python into dotnet core 2.0 (NetStandard 2.0) - Added new build system (pythonnet.15.sln) based on dotnetcore-sdk/xplat(crossplatform msbuild). Currently there two side-by-side build systems that produces the same output (net40) from the same sources. After a some transition time, current (mono/ msbuild 14.0) build system will be removed. diff --git a/pythonnet.15.sln b/pythonnet.15.sln index 121631e43..f2015e480 100644 --- a/pythonnet.15.sln +++ b/pythonnet.15.sln @@ -2,15 +2,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src\runtime\Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Runtime.15", "src/runtime/Python.Runtime.15.csproj", "{2759F4FF-716B-4828-916F-50FA86613DFC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src\embed_tests\Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.EmbeddingTest.15", "src/embed_tests/Python.EmbeddingTest.15.csproj", "{66B8D01A-9906-452A-B09E-BF75EA76468F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src\clrmodule\clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clrmodule.15", "src/clrmodule/clrmodule.15.csproj", "{E08678D4-9A52-4AD5-B63D-8EBC7399981B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src\console\Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.15", "src/console/Console.15.csproj", "{CDAD305F-8E72-492C-A314-64CF58D472A0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src\testing\Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test.15", "src/testing/Python.Test.15.csproj", "{F94B547A-E97E-4500-8D53-B4D64D076E5F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/setup.py b/setup.py index 376a575aa..e4294edf6 100644 --- a/setup.py +++ b/setup.py @@ -257,11 +257,8 @@ 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 == "MsDev15" or DEVTOOLS == "dotnet": + subprocess.check_call(" ".join(cmd + ['"/t:Console_15:publish;Python_EmbeddingTest_15:publish"', "/p:TargetFramework=netcoreapp2.0"]), shell=use_shell) if DEVTOOLS == "Mono" or DEVTOOLS == "dotnet": self._build_monoclr() diff --git a/src/embed_tests/pyimport.cs b/src/embed_tests/pyimport.cs index acb3433de..4123b4f31 100644 --- a/src/embed_tests/pyimport.cs +++ b/src/embed_tests/pyimport.cs @@ -30,7 +30,7 @@ public void SetUp() /* Append the tests directory to sys.path * using reflection to circumvent the private * modifiers placed on most Runtime methods. */ -#if NETCOREAPP +#if NETSTANDARD const string s = "../../fixtures"; #else const string s = "../fixtures"; diff --git a/src/runtime/Python.Runtime.15.csproj b/src/runtime/Python.Runtime.15.csproj index 56f415006..d80764551 100644 --- a/src/runtime/Python.Runtime.15.csproj +++ b/src/runtime/Python.Runtime.15.csproj @@ -1,7 +1,7 @@ - net40;netcoreapp2.0 + net40;netstandard2.0 AnyCPU DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 net45 @@ -29,7 +29,7 @@ $(PYTHONNET_DEFINE_CONSTANTS) XPLAT $(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants); - $(DefineConstants);NETCOREAPP + $(DefineConstants);NETSTANDARD $(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\ @@ -101,10 +101,9 @@ - - - 4.4.0 - + + + diff --git a/src/runtime/nativecall.cs b/src/runtime/nativecall.cs index 6a2df8418..49bf8b707 100644 --- a/src/runtime/nativecall.cs +++ b/src/runtime/nativecall.cs @@ -23,7 +23,7 @@ namespace Python.Runtime /// internal class NativeCall { -#if NETCOREAPP +#if NETSTANDARD [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Void_1_Delegate(IntPtr a1); diff --git a/src/runtime/polyfill/ReflectionPolifills.cs b/src/runtime/polyfill/ReflectionPolifills.cs index 6daf5312f..a7e9c879a 100644 --- a/src/runtime/polyfill/ReflectionPolifills.cs +++ b/src/runtime/polyfill/ReflectionPolifills.cs @@ -4,13 +4,18 @@ namespace Python.Runtime { +#if NETSTANDARD public static class ReflectionPolifills { -#if NETCOREAPP public static AssemblyBuilder DefineDynamicAssembly(this AppDomain appDomain, AssemblyName assemblyName, AssemblyBuilderAccess assemblyBuilderAccess) { return AssemblyBuilder.DefineDynamicAssembly(assemblyName, assemblyBuilderAccess); } -#endif + + public static Type CreateType(this TypeBuilder typeBuilder) + { + return typeBuilder.GetTypeInfo().GetType(); + } } +#endif } diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index ffb16eb21..31cf25795 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -9,7 +9,7 @@ namespace Python.Runtime internal static class NativeMethods { #if MONO_LINUX || MONO_OSX -#if NETCOREAPP +#if NETSTANDARD private static int RTLD_NOW = 0x2; #if MONO_LINUX private static int RTLD_GLOBAL = 0x100; @@ -181,7 +181,7 @@ public class Runtime public static readonly string PythonDLL = _PythonDll; -#if PYTHON_WITHOUT_ENABLE_SHARED && !NETCOREAPP +#if PYTHON_WITHOUT_ENABLE_SHARED && !NETSTANDARD internal const string _PythonDll = "__Internal"; #else internal const string _PythonDll = dllBase + dllWithPyDebug + dllWithPyMalloc; @@ -522,7 +522,7 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects) /// internal static unsafe void XIncref(IntPtr op) { -#if PYTHON_WITH_PYDEBUG || NETCOREAPP +#if PYTHON_WITH_PYDEBUG || NETSTANDARD Py_IncRef(op); return; #else @@ -543,7 +543,7 @@ internal static unsafe void XIncref(IntPtr op) internal static unsafe void XDecref(IntPtr op) { -#if PYTHON_WITH_PYDEBUG || NETCOREAPP +#if PYTHON_WITH_PYDEBUG || NETSTANDARD Py_DecRef(op); return; #else diff --git a/src/testing/Python.Test.15.csproj b/src/testing/Python.Test.15.csproj index 50093fb17..094b00658 100644 --- a/src/testing/Python.Test.15.csproj +++ b/src/testing/Python.Test.15.csproj @@ -1,7 +1,7 @@ - net40;netcoreapp2.0 + net40;netstandard2.0 x64;x86 DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3 Python.Test @@ -77,7 +77,11 @@ - + + + + + diff --git a/src/tests/fixtures/netcoreapp2.0/.gitkeep b/src/tests/fixtures/netstandard2.0/.gitkeep similarity index 100% rename from src/tests/fixtures/netcoreapp2.0/.gitkeep rename to src/tests/fixtures/netstandard2.0/.gitkeep From afaca1bb1ebb5e3f52779830f4db37d3656ec9bc Mon Sep 17 00:00:00 2001 From: dse Date: Wed, 6 Sep 2017 22:35:12 +0400 Subject: [PATCH 16/17] Wrong NETSTANDARD/NETCOREAPP define constant change. --- src/embed_tests/pyimport.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/embed_tests/pyimport.cs b/src/embed_tests/pyimport.cs index 4123b4f31..acb3433de 100644 --- a/src/embed_tests/pyimport.cs +++ b/src/embed_tests/pyimport.cs @@ -30,7 +30,7 @@ public void SetUp() /* Append the tests directory to sys.path * using reflection to circumvent the private * modifiers placed on most Runtime methods. */ -#if NETSTANDARD +#if NETCOREAPP const string s = "../../fixtures"; #else const string s = "../fixtures"; From b20d134ed17561f6c7e9e564c8909827d45885be Mon Sep 17 00:00:00 2001 From: dse Date: Thu, 7 Sep 2017 02:30:16 +0400 Subject: [PATCH 17/17] Typo fix. --- src/runtime/nativecall.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/nativecall.cs b/src/runtime/nativecall.cs index 49bf8b707..c64306958 100644 --- a/src/runtime/nativecall.cs +++ b/src/runtime/nativecall.cs @@ -161,7 +161,7 @@ public static int Int_Call_3(IntPtr fp, IntPtr a1, IntPtr a2, IntPtr a3) #endif } -#if !NETCORAPP +#if !NETSTANDARD /// /// Defines native call signatures to be generated by NativeCall. ///