From 87bf48cf93c6053ce991e8200691505c486efd1e Mon Sep 17 00:00:00 2001 From: Arjen Kroezen Date: Thu, 24 Sep 2026 06:30:50 +0000 Subject: [PATCH] fix: load .NET assemblies when running on .NET 9+ GitHub-hosted runners now ship .NET 8, 9 and 10. clr_loader 0.2.x (used with pythonnet 3.0.x, e.g. on Python 3.9) picks the runtime by string sort, so it selects .NET 9. On .NET 9+, pythonnet 3.0.x's clr.AddReference(".dll") parses the path as an assembly name and throws FileNotFoundException before its full-path fallback runs. The error was swallowed, so imports failed with "No module named 'Microsoft.Azure'". Pass the path without the ".dll" suffix so pythonnet probes and loads ".dll" directly, which works on .NET 8, 9 and 10 with pythonnet 3.0.x and 3.1.x. Also pin the e2e matrix to Python 3.13 instead of '3.x', which now resolves to 3.14 and is outside requires-python (<3.14). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- src/data_factory_testing_framework/_pythonnet/__init__.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c03ddb4f..3e58386e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,7 @@ jobs: strategy: matrix: os: ['ubuntu-latest', 'windows-latest'] - python-version: ['3.9', '3.10', '3.11', '3.12', '3.x'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] dotnet-version: ['8.0.x'] dist: [whl, sdist] uses: ./.github/workflows/e2e.yml diff --git a/src/data_factory_testing_framework/_pythonnet/__init__.py b/src/data_factory_testing_framework/_pythonnet/__init__.py index 5986726b..65e29f99 100644 --- a/src/data_factory_testing_framework/_pythonnet/__init__.py +++ b/src/data_factory_testing_framework/_pythonnet/__init__.py @@ -10,9 +10,11 @@ def load_dotnet_assemblies() -> None: # Load the .NET assemblies for dll in (Path(__file__).parent / "bin").glob("**/*.dll"): - dll = os.path.abspath(dll) + # Pass the path without the ".dll" suffix so pythonnet probes and loads ".dll" directly. + # With the suffix, pythonnet 3.0.x on .NET 9+ parses the path as an assembly name and fails to load it. + assembly_path = os.path.splitext(os.path.abspath(dll))[0] try: - clr.AddReference(dll) + clr.AddReference(assembly_path) except Exception: pass