8000 Merge branch 'master' into weakref-support · pythonnet/pythonnet@ff35e6d · GitHub
[go: up one dir, main page]

Skip to content

Commit ff35e6d

Browse files
committed
Merge branch 'master' into weakref-support
2 parents b4b1cff + d86bf3c commit ff35e6d

File tree

91 files changed

+6235
-1934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+6235
-1934
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,39 @@ jobs:
66
build-test:
77
name: Build and Test
88
runs-on: ${{ matrix.os }}-latest
9+
timeout-minutes: 5
910

1011
strategy:
1112
fail-fast: false
1213
matrix:
1314
os: [windows, ubuntu, macos]
14-
python: [3.6, 3.7, 3.8, 3.9]
15+
pyver_minor: [6, 7, 8, 9]
1516
platform: [x64]
1617
shutdown_mode: [Normal, Soft]
18+
include:
19+
- os: ubuntu
20+
pyver_minor: 6
21+
dll_suffix: m
22+
- os: ubuntu
23+
pyver_minor: 7
24+
dll_suffix: m
25+
26+
- os: macos
27+
dll_prefix: lib
28+
dll_pyver_major: '3.'
29+
dll_suffix: m
30+
- os: ubuntu
31+
dll_prefix: lib
32+
dll_pyver_major: '3.'
33+
- os: windows
34+
dll_pyver_major: '3'
35+
36+
- os: ubuntu
37+
dll_ext: .so
38+
- os: windows
39+
dll_ext: .dll
40+
- os: macos
41+
dll_ext: .dylib
1742

1843
env:
1944
PYTHONNET_SHUTDOWN_MODE: ${{ matrix.SHUTDOWN_MODE }}
@@ -31,10 +56,10 @@ jobs:
3156
- name: Setup .NET
3257
uses: actions/setup-dotnet@v1
3358

34-
- name: Set up Python ${{ matrix.python }}
59+
- name: Set up Python 3.${{ matrix.pyver_minor }}
3560
uses: actions/setup-python@v2
3661
with:
37-
python-version: ${{ matrix.python }}
62+
python-version: 3.${{ matrix.pyver_minor }}
3863
architecture: ${{ matrix.platform }}
3964

4065
- name: Install dependencies
@@ -46,12 +71,28 @@ jobs:
4671
python setup.py configure
4772
pip install -v .
4873
74+
# TODO this should be gone once clr module sets PythonDLL or preloads it
4975
- name: Python Tests
5076
run: pytest
77+
if: ${{ matrix.os != 'macos' }}
78+
env:
79+
PYTHONNET_PYDLL: ${{ matrix.DLL_PREFIX }}python${{matrix.DLL_PYVER_MAJOR}}${{matrix.PYVER_MINOR}}${{matrix.DLL_SUFFIX}}${{matrix.DLL_EXT}}
5180

52-
- name: Run Embedding tests
81+
- name: Python Tests
82+
run: pytest
83+
if: ${{ matrix.os == 'macos' }}
84+
85+
- name: Embedding tests
5386
run: dotnet test --runtime any-${{ matrix.platform }} src/embed_tests/
5487
if: ${{ matrix.os != 'macos' }} # Not working right now, doesn't find libpython
88+
env:
89+
PYTHONNET_PYDLL: ${{ matrix.DLL_PREFIX }}python${{matrix.DLL_PYVER_MAJOR}}${{matrix.PYVER_MINOR}}${{matrix.DLL_SUFFIX}}${{matrix.DLL_EXT}}
90+
91+
- name: Python tests run from .NET
92+
run: dotnet test --runtime any-${{ matrix.platform }} src/python_tests_runner/
93+
if: ${{ matrix.os == 'windows' }} # Not working for others right now
94+
env:
95+
PYTHONNET_PYDLL: ${{ matrix.DLL_PREFIX }}python${{matrix.DLL_PYVER_MAJOR}}${{matrix.PYVER_MINOR}}${{matrix.DLL_SUFFIX}}${{matrix.DLL_EXT}}
5596

5697
# TODO: Run perf tests
5798
# TODO: Run mono tests on Windows?

AUTHORS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- Benoît Hudson ([@benoithudson](https://github.com/benoithudson))
2525
- Bradley Friedman ([@leith-bartrich](https://github.com/leith-bartrich))
2626
- Callum Noble ([@callumnoble](https://github.com/callumnoble))
27+
- Christabella Irwanto([@christabella](https://github.com/christabella))
2728
- Christian Heimes ([@tiran](https://github.com/tiran))
2829
- Christoph Gohlke ([@cgohlke](https://github.com/cgohlke))
2930
- Christopher Bremner ([@chrisjbremner](https://github.com/chrisjbremner))
@@ -65,10 +66,10 @@
6566
- Ville M. Vainio ([@vivainio](https://github.com/vivainio))
6667
- Virgil Dupras ([@hsoft](https://github.com/hsoft))
6768
- Wenguang Yang ([@yagweb](https://github.com/yagweb))
68-
- William Sardar ([@williamsardar])(https://github.com/williamsardar)
69+
- William Sardar ([@williamsardar](https://github.com/williamsardar))
6970
- Xavier Dupré ([@sdpython](https://github.com/sdpython))
7071
- Zane Purvis ([@zanedp](https://github.com/zanedp))
71-
- ([@amos402]https://github.com/amos402)
72+
- ([@amos402](https://github.com/amos402))
7273
- ([@bltribble](https://github.com/bltribble))
7374
- ([@civilx64](https://github.com/civilx64))
7475
- ([@GSPP](https://github.com/GSPP))
@@ -81,3 +82,4 @@
8182
- ([@testrunner123](https://github.com/testrunner123))
8283
- ([@DanBarzilian](https://github.com/DanBarzilian))
8384
- ([@alxnull](https://github.com/alxnull))
85+
- ([@gpetrou](https://github.com/gpetrou))

CHANGELOG.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1010
### Added
1111

1212
- Ability to instantiate new .NET arrays using `Array[T](dim1, dim2, ...)` syntax
13+
- Python operator method will call C# operator method for supported binary and unary operators ([#1324][p1324]).
14+
- Add GetPythonThreadID and Interrupt methods in PythonEngine
15+
- Ability to implement delegates with `ref` and `out` parameters in Python, by returning the modified parameter values in a tuple. ([#1355][i1355])
1316

1417
### Changed
1518
- Drop support for Python 2, 3.4, and 3.5
@@ -27,26 +30,39 @@ details about the cause of the failure
2730
to the regular method return value (unless they are passed with `ref` or `out` keyword).
2831
- BREAKING: Drop support for the long-deprecated CLR.* prefix.
2932
- `PyObject` now implements `IEnumerable<PyObject>` in addition to `IEnumerable`
33+
- floating point values passed from Python are no longer silently truncated
34+
when .NET expects an integer [#1342][i1342]
35+
- More specific error messages for method argument mismatch
36+
- BREAKING: Methods with `ref` or `out` parameters and void return type return a tuple of only the `ref` and `out` parameters.
37+
- BREAKING: to call Python from .NET `Runtime.PythonDLL` property must be set to Python DLL name
38+
or the DLL must be loaded in advance. This must be done before calling any other Python.NET functions.
3039

3140
### Fixed
3241

33-
- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
34-
- Fix incorrect dereference in params array handling
35-
- Fixes issue with function resolution when calling overloaded function with keyword arguments from python ([#1097][i1097])
36-
- Fix `object[]` parameters taking precedence when should not in overload resolution
37-
- Fixed a bug where all .NET class instances were considered Iterable
38-
- Fix incorrect choice of method to invoke when using keyword arguments.
39-
- Fix non-delegate types incorrectly appearing as callable.
40-
- Indexers can now be used with interface objects
41-
- Fixed a bug where indexers could not be used if they were inherited
42-
- Made it possible to use `__len__` also on `ICollection<>` interface objects
43-
- Made it possible to call `ToString`, `GetHashCode`, and `GetType` on inteface objects
44-
- Fixed objects returned by enumerating `PyObject` being disposed too soon
45-
- Incorrectly using a non-generic type with type parameters now produces a helpful Python error instead of throwing NullReferenceException
42+
- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
43+
- Fix incorrect dereference in params array handling
44+
- Fixes issue with function resolution when calling overloaded function with keyword arguments from python ([#1097][i1097])
45+
- Fix `object[]` parameters taking precedence when should not in overload resolution
46+
- Fixed a bug where all .NET class instances were considered Iterable
47+
- Fix incorrect choice of method to invoke when using keyword arguments.
48+
- Fix non-delegate types incorrectly appearing as callable.
49+
- Indexers can now be used with interface objects
50+
- Fixed a bug where indexers could not be used if they were inherited
51+
- Made it possible to use `__len__` also on `ICollection<>` interface objects
52+
- Fixed issue when calling PythonException.Format where another exception would be raise for unnormalized exceptions
53+
- Made it possible to call `ToString`, `GetHashCode`, and `GetType` on inteface objects
54+
- Fixed objects returned by enumerating `PyObject` being disposed too soon
55+
- Incorrectly using a non-generic type with type parameters now produces a helpful Python error instead of throwing NullReferenceException
56+
- `import` may now raise errors with more detail than "No module named X"
57+
- Exception stacktraces on `PythonException.StackTrace` are now properly formatted
58+
- Providing an invalid type parameter to a generic type or method produces a helpful Python error
59+
- Empty parameter names (as can be generated from F#) do not cause crashes
4660

4761
### Removed
4862

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

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

@@ -806,3 +822,4 @@ This version improves performance on benchmarks significantly compared to 2.3.
806822
[i755]: https://github.com/pythonnet/pythonnet/pull/755
807823
[p534]: https://github.com/pythonnet/pythonnet/pull/534
808824
[i449]: https://github.com/pythonnet/pythonnet/issues/449
825+
[i1342]: https://github.com/pythonnet/pythonnet/issues/1342

Directory.Build.props

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
11-
<PackageReference Include="NonCopyableAnalyzer" Version="0.6.0">
11+
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.9.0-3.final">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
14+
</PackageReference>
15+
<PackageReference Include="Lost.NonCopyableAnalyzer" Version="0.7.0-m04">
1216
<PrivateAssets>all</PrivateAssets>
1317
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1418
</PackageReference>

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ environment:
3030
init:
3131
# Update Environment Variables based on matrix/platform
3232
- set PY_VER=%PYTHON_VERSION:.=%
33+
- set PYTHONNET_PYDLL=python%PY_VER%.dll
3334
- set PYTHON=C:\PYTHON%PY_VER%
3435
- if %PLATFORM%==x64 (set PYTHON=%PYTHON%-x64)
3536

pythonnet.sln

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.Test", "src\testing\
1414
EndProject
1515
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.PerformanceTests", "src\perf_tests\Python.PerformanceTests.csproj", "{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}"
1616
EndProject
17+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.DomainReloadTests", "src\domain_tests\Python.DomainReloadTests.csproj", "{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}"
18+
EndProject
1719
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Repo", "Repo", "{441A0123-F4C6-4EE4-9AEE-315FD79BE2D5}"
1820
ProjectSection(SolutionItems) = preProject
1921
.editorconfig = .editorconfig
@@ -47,6 +49,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{BC426F42
4749
tools\geninterop\geninterop.py = tools\geninterop\geninterop.py
4850
EndProjectSection
4951
EndProject
52+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Python.PythonTestsRunner", "src\python_tests_runner\Python.PythonTestsRunner.csproj", "{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}"
53+
EndProject
5054
Global
5155
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5256
Debug|Any CPU = Debug|Any CPU
@@ -129,6 +133,42 @@ Global
129133
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Release|x64.Build.0 = Release|x64
130134
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Release|x86.ActiveCfg = Release|x86
131135
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Release|x86.Build.0 = Release|x86
136+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
138+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|x64.ActiveCfg = Debug|Any CPU
139+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|x64.Build.0 = Debug|Any CPU
140+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|x86.ActiveCfg = Debug|Any CPU
141+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|x86.Build.0 = Debug|Any CPU
142+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
143+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|Any CPU.Build.0 = Release|Any CPU
144+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x64.ActiveCfg = Release|Any CPU
145+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x64.Build.0 = Release|Any CPU
146+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x86.ActiveCfg = Release|Any CPU
147+
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x86.Build.0 = Release|Any CPU
148+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
149+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|Any CPU.Build.0 = Debug|Any CPU
150+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x64.ActiveCfg = Debug|Any CPU
151+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x64.Build.0 = Debug|Any CPU
152+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x86.ActiveCfg = Debug|Any CPU
153+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Debug|x86.Build.0 = Debug|Any CPU
154+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|Any CPU.ActiveCfg = Release|Any CPU
155+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|Any CPU.Build.0 = Release|Any CPU
156+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x64.ActiveCfg = Release|Any CPU
157+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x64.Build.0 = Release|Any CPU
158+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x86.ActiveCfg = Release|Any CPU
159+
{6CF9EEA0-F865-4536-AABA-739AE3DA971E}.Release|x86.Build.0 = Release|Any CPU
160+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
161+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|Any CPU.Build.0 = Debug|Any CPU
162+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|x64.ActiveCfg = Debug|Any CPU
163+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|x64.Build.0 = Debug|Any CPU
164+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|x86.ActiveCfg = Debug|Any CPU
165+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|x86.Build.0 = Debug|Any CPU
166+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|Any CPU.ActiveCfg = Release|Any CPU
167+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|Any CPU.Build.0 = Release|Any CPU
168+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|x64.ActiveCfg = Release|Any CPU
169+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|x64.Build.0 = Release|Any CPU
170+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|x86.ActiveCfg = Release|Any CPU
171+
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|x86.Build.0 = Release|Any CPU
132172
EndGlobalSection
133173
GlobalSection(SolutionProperties) = preSolution
134174
HideSolutionNode = FALSE

src/clrmodule/ClrModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public static IntPtr PyInit_clr()
6262
pythonRuntime = Assembly.Load(pythonRuntimeName);
6363
DebugPrint("Success loading 'Python.Runtime' using standard binding rules.");
6464
}
65-
catch (IOException)
65+
catch (IOException ex)
6666
{
67-
DebugPrint("'Python.Runtime' not found using standard binding rules.");
67+
DebugPrint($"'Python.Runtime' not found using standard binding rules: {ex}");
6868
try
6969
{
7070
// If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll"

src/console/pythonconsole.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private PythonConsole()
2626
[STAThread]
2727
public static int Main(string[] args)
2828
{
29-
// Only net40 is capable to safely inject python.runtime.dll into resources.
29+
// Only .NET Framework is capable to safely inject python.runtime.dll into resources.
3030
#if NET40
3131
// reference the static assemblyLoader to stop it being optimized away
3232
AssemblyLoader a = assemblyLoader;

src/domain_tests/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net472</TargetFrameworks>
5+
<OutputPath>bin\</OutputPath>
6+
<OutputType>Exe</OutputType>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Reference Include="System" />
11+
<Reference Include="System.Core" />
12+
<Reference Include="System.Xml.Linq" />
13+
<Reference Include="System.Data.DataSetExtensions" />
14+
<Reference Include="System.Data" />
15+
<Reference Include="System.Xml" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\runtime\Python.Runtime.csproj" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
24+
</ItemGroup>
25+
26+
</Project>

0 commit comments

Comments
 (0)
0