Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1a1a9ab
Drop unused requirements.txt
filmor Feb 16, 2026
4ca65d6
Bump astral-sh/setup-uv from 6 to 7 (#2656)
dependabot[bot] Oct 28, 2025
0856eb4
Bump actions/checkout from 5 to 6 (#2663)
dependabot[bot] Nov 24, 2025
a7d0842
Only init/shutdown Python once
filmor Oct 22, 2025
f6ff431
Disable NUnit analyzer for now
filmor Oct 23, 2025
9fc08f3
Reset conversions after each codec test
filmor Oct 23, 2025
a8e5020
Remove shutdown from most tests, disable the rest for now
filmor Oct 23, 2025
0a6062e
Use python -m pytest, path seemingly not properly updated
filmor Oct 26, 2025
6b1bb92
Remove unused architecture from uv env activation
filmor Oct 26, 2025
d4d1768
Synchronize the environment
filmor Oct 26, 2025
40a3db7
Include the probed PythonDLL value in the exception
filmor Dec 7, 2025
96f428f
Use the actual pytest runner
filmor Dec 7, 2025
5459ac7
Move tests that require reinit and only run on .NET Framework
filmor Dec 8, 2025
abb6855
Bump NUnit3TestAdapter from 5.2.0 to 6.0.0 (#2667)
dependabot[bot] Dec 8, 2025
9882788
Fix line endings
filmor Dec 9, 2025
dc5c6c4
Add previous commit to ignore file
filmor Dec 9, 2025
caac33d
Initial 3.14 commit
filmor Aug 9, 2025
e10d333
Apply alignment fix
filmor Oct 22, 2025
e976558
Disable problematic GC tests
filmor Oct 22, 2025
65af098
Set ht_token to NULL in Python 3.14
filmor Oct 24, 2025
e244503
Fix lockfile
filmor Oct 26, 2025
8e0333d
Assign True instead of None to __clear_reentry_guard__
filmor Dec 6, 2025
cd108b8
Disable the three remaining failing tests
filmor Dec 6, 2025
698bf00
Take the GIL in sequence and list wrappers
filmor Dec 7, 2025
908e13b
Move tp_clear workaround to .NET
filmor Dec 7, 2025
c851b3a
Skip coreclr embedded tests for now
filmor Dec 7, 2025
08550d0
Workaround for blocked PyObject_GenericSetAttr in metatypes
filmor Dec 7, 2025
f1d90f3
Revert changes to tests
filmor Dec 7, 2025
a47555d
Bump macos image version and add arm64
filmor Dec 8, 2025
cebfd15
Reenable .NET Core embedding tests
filmor Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Line endings normalization
fd7c7e1cbd8e1d7bdb2ec2423c3cf9f95a3abed1
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Doxygen Action
uses: mattnotmitt/[email protected]
with:
Expand Down
22 changes: 17 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ jobs:

- category: macos
platform: x64
instance: macos-13
instance: macos-14

python: ["3.10", "3.11", "3.12", "3.13"]
- category: macos
platform: arm64
instance: macos-14-arm64

python: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- name: Set Environment on macOS
Expand All @@ -48,23 +52,27 @@ jobs:
mono-version: latest

- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'

- name: Set up Python ${{ matrix.python }}
uses: astral-sh/setup-uv@v6
uses: astral-sh/setup-uv@v7
with:
architecture: ${{ matrix.os.platform }}
python-version: ${{ matrix.python }}
cache-python: true
activate-environment: true
enable-cache: true

- name: Synchronize the virtual environment
run: uv sync
run: uv sync --managed-python

- name: Show pyvenv.cfg
run: cat .venv/pyvenv.cfg

- name: Embedding tests (Mono/.NET Framework)
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net472 --logger "console;verbosity=detailed" src/embed_tests/
Expand All @@ -88,4 +96,8 @@ jobs:
run: pytest --runtime netfx

- name: Python tests run from .NET
# For some reason, it won't find pytest on the Windows + 3.10
# combination, which hints that it does not handle the venv properly in
# this combination.
if: ${{ matrix.os.category != 'windows' || matrix.python != '3.10' }}
run: dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/
2 changes: 1 addition & 1 deletion .github/workflows/nuget-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
echo "DATE_VER=$(date "+%Y-%m-%d")" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand Down
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<AssemblyCopyright>Copyright (c) 2006-2025 The Contributors of the Python.NET Project</AssemblyCopyright>
<AssemblyCompany>pythonnet</AssemblyCompany>
<AssemblyProduct>Python.NET</AssemblyProduct>
<LangVersion>10.0</LangVersion>
<LangVersion>12.0</LangVersion>
<IsPackable>false</IsPackable>
<FullVersion>$([System.IO.File]::ReadAllText("$(MSBuildThisFileDirectory)version.txt").Trim())</FullVersion>
<VersionPrefix>$(FullVersion.Split('-', 2)[0])</VersionPrefix>
<VersionSuffix Condition="$(FullVersion.Contains('-'))">$(FullVersion.Split('-', 2)[1])</VersionSuffix>
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
70 changes: 35 additions & 35 deletions doc/make.bat
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"clr_loader>=0.2.7,<0.3.0"
]

requires-python = ">=3.10, <3.14"
requires-python = ">=3.10, <3.15"

classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
14 changes: 0 additions & 14 deletions requirements.txt

This file was deleted.

25 changes: 13 additions & 12 deletions src/embed_tests/CallableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,37 @@ namespace Python.EmbeddingTest
{
public class CallableObject
{
IPythonBaseTypeProvider BaseTypeProvider;

[OneTimeSetUp]
public void SetUp()
{
PythonEngine.Initialize();
using var locals = new PyDict();
PythonEngine.Exec(CallViaInheritance.BaseClassSource, locals: locals);
CustomBaseTypeProvider.BaseClass = new PyType(locals[CallViaInheritance.BaseClassName]);
PythonEngine.InteropConfiguration.PythonBaseTypeProviders.Add(new CustomBaseTypeProvider());
BaseTypeProvider = new CustomBaseTypeProvider(new PyType(locals[CallViaInheritance.BaseClassName]));
PythonEngine.InteropConfiguration.PythonBaseTypeProviders.Add(BaseTypeProvider);
}

[OneTimeTearDown]
public void Dispose()
{
PythonEngine.Shutdown();
PythonEngine.InteropConfiguration.PythonBaseTypeProviders.Remove(BaseTypeProvider);
}

[Test]
public void CallMethodMakesObjectCallable()
{
var doubler = new DerivedDoubler();
dynamic applyObjectTo21 = PythonEngine.Eval("lambda o: o(21)");
Assert.AreEqual(doubler.__call__(21), (int)applyObjectTo21(doubler.ToPython()));
Assert.That((int)applyObjectTo21(doubler.ToPython()), Is.EqualTo(doubler.__call__(21)));
}

[Test]
public void CallMethodCanBeInheritedFromPython()
{
var callViaInheritance = new CallViaInheritance();
dynamic applyObjectTo14 = PythonEngine.Eval("lambda o: o(14)");
Assert.AreEqual(callViaInheritance.Call(14), (int)applyObjectTo14(callViaInheritance.ToPython()));
Assert.That((int)applyObjectTo14(callViaInheritance.ToPython()), Is.EqualTo(callViaInheritance.Call(14)));
}

[Test]
Expand All @@ -48,7 +51,7 @@ public void CanOverwriteCall()
scope.Exec("orig_call = o.Call");
scope.Exec("o.Call = lambda a: orig_call(a*7)");
int result = scope.Eval<int>("o.Call(5)");
Assert.AreEqual(105, result);
Assert.That(result, Is.EqualTo(105));
}

class Doubler
Expand All @@ -71,16 +74,14 @@ class {BaseClassName}(MyCallableBase): pass
public int Call(int arg) => 3 * arg;
}

class CustomBaseTypeProvider : IPythonBaseTypeProvider
class CustomBaseTypeProvider(PyType BaseClass) : IPythonBaseTypeProvider
{
internal static PyType BaseClass;

public IEnumerable<PyType> GetBaseTypes(Type type, IList<PyType> existingBases)
{
Assert.Greater(BaseClass.Refcount, 0);
Assert.That(BaseClass.Refcount, Is.GreaterThan(0));
return type != typeof(CallViaInheritance)
? existingBases
: new[] { BaseClass };
: [BaseClass];
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions src/embed_tests/ClassManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ namespace Python.EmbeddingTest
{
public class ClassManagerTests
{
[OneTimeSetUp]
public void SetUp()
{
PythonEngine.Initialize();
}

[OneTimeTearDown]
public void Dispose()
{
PythonEngine.Shutdown();
}

[Test]
public void NestedClassDerivingFromParent()
{
Expand Down
62 changes: 30 additions & 32 deletions src/embed_tests/CodecGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void GetEncodersByType()
};

var got = group.GetEncoders(typeof(Uri)).ToArray();
CollectionAssert.AreEqual(new[]{encoder1, encoder2}, got);
Assert.That(got, Is.EqualTo(new[] { encoder1, encoder2 }).AsCollection);
}

[Test]
Expand All @@ -31,9 +31,13 @@ public void CanEncode()
new ObjectToEncoderInstanceEncoder<Uri>(),
};

Assert.IsTrue(group.CanEncode(typeof(Tuple<int>)));
Assert.IsTrue(group.CanEncode(typeof(Uri)));
Assert.IsFalse(group.CanEncode(typeof(string)));
Assert.Multiple(() =>
{
Assert.That(group.CanEncode(typeof(Tuple<int>)), Is.True);
Assert.That(group.CanEncode(typeof(Uri)), Is.True);
Assert.That(group.CanEncode(typeof(string)), Is.False);
});

}

[Test]
Expand All @@ -50,12 +54,12 @@ public void Encodes()

var uri = group.TryEncode(new Uri("data:"));
var clrObject = (CLRObject)ManagedType.GetManagedObject(uri);
Assert.AreSame(encoder1, clrObject.inst);
Assert.AreNotSame(encoder2, clrObject.inst);
Assert.That(clrObject.inst, Is.SameAs(encoder1));
Assert.That(clrObject.inst, Is.Not.SameAs(encoder2));

var tuple = group.TryEncode(Tuple.Create(1));
clrObject = (CLRObject)ManagedType.GetManagedObject(tuple);
Assert.AreSame(encoder0, clrObject.inst);
Assert.That(clrObject.inst, Is.SameAs(encoder0));
}

[Test]
Expand All @@ -72,11 +76,11 @@ public void GetDecodersByTypes()
};

var decoder = group.GetDecoder(pyfloat, typeof(string));
Assert.AreSame(decoder2, decoder);
Assert.That(decoder, Is.SameAs(decoder2));
decoder = group.GetDecoder(pystr, typeof(string));
Assert.IsNull(decoder);
Assert.That(decoder, Is.Null);
decoder = group.GetDecoder(pyint, typeof(long));
Assert.AreSame(decoder1, decoder);
Assert.That(decoder, Is.SameAs(decoder1));
}
[Test]
public void CanDecode()
Expand All @@ -91,10 +95,14 @@ public void CanDecode()
decoder2,
};

Assert.IsTrue(group.CanDecode(pyint, typeof(long)));
Assert.IsFalse(group.CanDecode(pyint, typeof(int)));
Assert.IsTrue(group.CanDecode(pyfloat, typeof(string)));
Assert.IsFalse(group.CanDecode(pystr, typeof(string)));
Assert.Multiple(() =>
{
Assert.That(group.CanDecode(pyint, typeof(long)));
Assert.That(group.CanDecode(pyint, typeof(int)), Is.False);
Assert.That(group.CanDecode(pyfloat, typeof(string)));
Assert.That(group.CanDecode(pystr, typeof(string)), Is.False);
});

}

[Test]
Expand All @@ -109,24 +117,14 @@ public void Decodes()
decoder2,
};

Assert.IsTrue(group.TryDecode(new PyInt(10), out long longResult));
Assert.AreEqual(42, longResult);
Assert.IsTrue(group.TryDecode(new PyFloat(10), out string strResult));
Assert.AreSame("atad:", strResult);

Assert.IsFalse(group.TryDecode(new PyInt(10), out int _));
}

[SetUp]
public void SetUp()
{
PythonEngine.Initialize();
}

[TearDown]
public void Dispose()
{
PythonEngine.Shutdown();
Assert.Multiple(() =>
{
Assert.That(group.TryDecode(new PyInt(10), out long longResult));
Assert.That(longResult, Is.EqualTo(42));
Assert.That(group.TryDecode(new PyFloat(10), out string strResult));
Assert.That(strResult, Is.SameAs("atad:"));
Assert.That(group.TryDecode(new PyInt(10), out int _), Is.False);
});
}
}
}
Loading
Loading