X Tutup
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/actions/install-mono/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: 'Install Mono'
description: 'Install Mono'
branding:
icon: package
color: blue
inputs:
arch:
description: Architecture to install for
required: true
runs:
using: "composite"
steps:
# Windows Cache
- name: Cache setup on Windows
if: runner.os == 'Windows'
run: |
mkdir -p .choco-cache
choco config set cacheLocation $(pwd)/.choco-cache
shell: bash

- name: Cache on Windows
if: runner.os == 'Windows'
uses: actions/cache@v5
with:
path: .choco-cache
key: mono-${{ runner.os }}-${{ inputs.arch }}

# macOS Cache
- name: Set Homebrew Cache Path
if: runner.os == 'macOS'
run: |
mkdir -p .brew-cache
echo "HOMEBREW_CACHE=$(pwd)/.brew-cache" >> $GITHUB_ENV
shell: bash

- name: Cache Homebrew on macOS
if: runner.os == 'macOS'
uses: actions/cache@v5
with:
path: .brew-cache
key: mono-brew-${{ runner.os }}-${{ inputs.arch }}

# ===================================

- name: Install on Linux
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: mono-runtime-sgen

# ===================================

- name: Install on Windows (x86)
if: runner.os == 'Windows' && inputs.arch == 'x86'
run: choco install --x86 -y mono
shell: sh

- name: Install on Windows
if: runner.os == 'Windows' && inputs.arch != 'x86'
run: choco install -y mono
shell: sh

# ===================================
#
- name: Install on macOS (x86_64)
if: runner.os == 'macOS' && inputs.arch == 'x64'
run: |
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew install --ignore-dependencies mono
shell: sh

- name: Install on macOS (arm64)
if: runner.os == 'macOS' && inputs.arch != 'x64'
run: |
brew update
brew install --ignore-dependencies mono
shell: sh

87 changes: 58 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,88 +16,117 @@ jobs:
fail-fast: false
matrix:
os:
# Disabled for now, will require some work (#2653)
#
# - category: windows
# platform: x86
# instance: windows-latest
- category: windows
platform: x86
instance: windows-latest
suffix: -windows-x86-none

- category: windows
platform: x64
instance: windows-latest
suffix: -windows-x86_64-none

- category: ubuntu
platform: x64
instance: ubuntu-22.04
suffix: ""

- category: ubuntu
platform: arm64
instance: ubuntu-22.04-arm
suffix: ""

- category: macos
platform: x64
instance: macos-14
instance: macos-15
suffix: -macos-x86_64-none

- category: macos
platform: arm64
instance: macos-14-arm64
instance: macos-15
suffix: -macos-aarch64-none

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

exclude:
# Fails with initfs_encoding error
- os:
category: windows
platform: x86
python: "3.10"

# broken ctypes find_library
- os:
category: macos
platform: arm64
python: '3.10'
- os:
category: macos
platform: arm64
python: '3.11'
- os:
category: macos
platform: arm64
python: '3.12'

# fails to call mono methods
- os:
category: windows
platform: x86
python: '3.13'

env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- name: Set Environment on macOS
uses: maxim-lobanov/setup-xamarin@v1
if: ${{ matrix.os.category == 'macos' }}
with:
mono-version: latest

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

# Use main until support for architecture lands
- name: Setup .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@main
with:
dotnet-version: '10.0'
architecture: ${{ matrix.os.platform }}

- run: dotnet restore

- name: Install Mono
uses: ./.github/actions/install-mono
with:
dotnet-version: '10.0.x'
arch: ${{ matrix.os.platform }}

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

- name: Synchronize the virtual environment
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/
if: always()
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net472 --logger "console;verbosity=detailed" src/embed_tests/
env:
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466

- name: Embedding tests (.NET Core)
if: always()
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net10.0 --logger "console;verbosity=detailed" src/embed_tests/

- name: Python Tests (.NET Core)
if: always()
run: pytest --runtime coreclr

- name: Python Tests (Mono)
if: ${{ matrix.os.category != 'windows' }}
if: always()
run: pytest --runtime mono

- name: Python Tests (.NET Core)
run: pytest --runtime coreclr

- name: Python Tests (.NET Framework)
if: ${{ matrix.os.category == 'windows' }}
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/
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.12.0">
<PackageReference Include="Microsoft.CSharp" Version="4.*" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="5.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT"
readme = "README.rst"

dependencies = [
"clr_loader>=0.2.7,<0.3.0"
"clr_loader>=0.3.0,<0.4.0"
]

requires-python = ">=3.10, <3.15"
Expand Down
1 change: 1 addition & 0 deletions src/embed_tests/Codecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public void IterableDecoderTest()

// regression for https://github.com/pythonnet/pythonnet/issues/1427
[Test]
[Ignore("Broken, the list_encoder object ends up in builtins and fails during GC")]
public void PythonRegisteredDecoder_NoStackOverflowOnSystemType()
{
const string PyCode = @"
Expand Down
4 changes: 2 additions & 2 deletions src/embed_tests/Python.EmbeddingTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference -->
<PackageReference Include="NUnit3TestAdapter" Version="6.0.0">
<PackageReference Include="NUnit3TestAdapter" Version="6.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.*" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Condition="$(MSBuildRuntimeType) == 'Core'">
<Version>1.0.0</Version>
<Version>1.*</Version>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/python_tests_runner/Python.PythonTestsRunner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="NUnit" Version="4.*" />
<PackageReference Include="NUnit3TestAdapter" Version="5.*">
<PackageReference Include="NUnit3TestAdapter" Version="6.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/Python.Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<ItemGroup>
<PackageReference Include="Lost.Compat.NullabilityAttributes" Version="0.0.4" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.*" PrivateAssets="All" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions tests/domain_tests/Python.DomainReloadTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\runtime\Python.Runtime.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Condition="$(MSBuildRuntimeType) == 'Core'">
<Version>1.*</Version>
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
Loading
Loading
X Tutup