From 1341f6dfdd4a34fc8fbc952eb3dc638e553cac94 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Sat, 1 Nov 2025 08:45:01 +0100 Subject: [PATCH 01/15] upgrade libs to python 3.14 etc NOT WORKING RN has print statements and xsdata makes problems --- .gitignore | 2 +- Cargo.toml | 4 ++-- pyproject.toml | 3 ++- python/socha/api/networking/xml_protocol_interface.py | 2 ++ requirements.txt | 2 +- src/lib.rs | 1 + src/plugin2026/test/game_state_test.rs | 4 +++- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 311c305..12b6116 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ __pycache__/ # Distribution / packaging socha_builds/ .Python -.venv/ +venv*/ env/ bin/ build/ diff --git a/Cargo.toml b/Cargo.toml index 6c406ae..1a87dcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ name = "socha" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.21.2" } -pyo3-log = "0.10.0" +pyo3 = { version = "0.27.1", features = ["extension-module"] } +pyo3-log = "0.13.2" log = "0.4.20" itertools = "0.13.0" diff --git a/pyproject.toml b/pyproject.toml index 48f75f5..20ee84a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ authors = [ description = "Dieses Paket ist für die Software-Challenge Germany 2026, bei der in dieser Saison das Spiel 'Piranhas' im Mittelpunkt steht." readme = "README.md" requires-python = ">=3.10" -dependencies = ["xsdata==22.9"] +dependencies = ["xsdata==25.7", "setuptools==80.9.0"] classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: MacOS", @@ -23,6 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python", "Programming Language :: Rust", diff --git a/python/socha/api/networking/xml_protocol_interface.py b/python/socha/api/networking/xml_protocol_interface.py index c8507fa..25f85c3 100644 --- a/python/socha/api/networking/xml_protocol_interface.py +++ b/python/socha/api/networking/xml_protocol_interface.py @@ -150,6 +150,8 @@ def _receive(self): for i, t in enumerate(unicodes): receiving = receiving.replace(t, replaces[i]) + print(receiving) + cls = self._deserialize_object(receiving) return cls except OSError: diff --git a/requirements.txt b/requirements.txt index 0c0bad1..846425b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -xsdata==22.9 \ No newline at end of file +xsdata==25.7 \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index c746fe7..ecdc195 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ use pyo3::*; use types::PyModule; +use pyo3::types::PyModuleMethods; pub mod plugin2026; diff --git a/src/plugin2026/test/game_state_test.rs b/src/plugin2026/test/game_state_test.rs index 532a053..7ff0cb7 100644 --- a/src/plugin2026/test/game_state_test.rs +++ b/src/plugin2026/test/game_state_test.rs @@ -1,5 +1,7 @@ #[cfg(test)] mod tests { + use pyo3::Python; + use crate::plugin2026::{ field_type::FieldType, r#move::Move, test::common::create_test_game_state, utils::{coordinate::Coordinate, direction::Direction} }; @@ -39,7 +41,7 @@ mod tests { #[test] pub fn perform_move_test() { - pyo3::prepare_freethreaded_python(); + Python::initialize(); let mut state = create_test_game_state(); From af95babdc4dcbf3818d3ec72b9739dd020d213cd Mon Sep 17 00:00:00 2001 From: YoEnte Date: Sat, 1 Nov 2025 10:04:47 +0100 Subject: [PATCH 02/15] add module annotations and remove prints now seems to be working --- python/socha/api/networking/xml_protocol_interface.py | 4 ---- python/socha/api/protocol/protocol.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/python/socha/api/networking/xml_protocol_interface.py b/python/socha/api/networking/xml_protocol_interface.py index 25f85c3..908dc83 100644 --- a/python/socha/api/networking/xml_protocol_interface.py +++ b/python/socha/api/networking/xml_protocol_interface.py @@ -76,8 +76,6 @@ def map_last_move(last_move: LastMove, params: dict): def custom_class_factory(clazz, params: dict): - # print("TEST01: ", clazz, params) - if clazz.__name__ == 'Data': return map_object(clazz, params) if clazz.__name__ == 'LastMove': @@ -150,8 +148,6 @@ def _receive(self): for i, t in enumerate(unicodes): receiving = receiving.replace(t, replaces[i]) - print(receiving) - cls = self._deserialize_object(receiving) return cls except OSError: diff --git a/python/socha/api/protocol/protocol.py b/python/socha/api/protocol/protocol.py index f4d9d0c..7397010 100644 --- a/python/socha/api/protocol/protocol.py +++ b/python/socha/api/protocol/protocol.py @@ -1,3 +1,4 @@ +from __future__ import annotations from dataclasses import dataclass, field from typing import List, Optional @@ -493,7 +494,6 @@ class Meta: }, ) - @dataclass class Joined(ResponsePacket): """ From 2ba96652750fb7459520d7fbc08048ef61ba7899 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Sat, 1 Nov 2025 10:23:19 +0100 Subject: [PATCH 03/15] update starter arguments --- python/socha/starter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/socha/starter.py b/python/socha/starter.py index b722f26..1022660 100644 --- a/python/socha/starter.py +++ b/python/socha/starter.py @@ -56,6 +56,7 @@ def __init__( log: If True the client write a log file to the current directory. verbose: Verbose option for logging. build: If set, the client will build a zip package with the given name. + python_version: When building, takes string for specified python version. Standard: "3.10". """ VERBOSE = 15 logging.addLevelName(VERBOSE, "VERBOSE") @@ -241,10 +242,11 @@ def _handle_start_args(): parser.add_argument( "-a", "--architecture", - help="Specifies the build architecture (e.g.: manylinux1_x86_64).", + help="Specifies the build architecture (e.g.: manylinux2014_x86_64).", ) parser.add_argument( + "-pyv", "--python-version", help="Specifies the build python version (e.g.: 3.10 - this is standard).", ) From ae15c0a5addf9b240beaf2dd186580ecc6c08d15 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Sun, 16 Nov 2025 14:38:53 +0100 Subject: [PATCH 04/15] fix: update setuptools and replace pkg_resources --- pyproject.toml | 2 +- python/socha/starter.py | 6 +++--- requirements.txt | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 20ee84a..3f3b7b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "maturin" name = "socha" version = "4.3.4" authors = [ - { name = "yoente", email = "stu250140@mail.uni-kiel.de" }, + { name = "yoente", email = "anthony@software-challenge.de" }, { name = "maxblan", email = "stu222782@mail.uni-kiel.de" }, ] description = "Dieses Paket ist für die Software-Challenge Germany 2026, bei der in dieser Saison das Spiel 'Piranhas' im Mittelpunkt steht." diff --git a/python/socha/starter.py b/python/socha/starter.py index 1022660..2ebdec8 100644 --- a/python/socha/starter.py +++ b/python/socha/starter.py @@ -8,7 +8,7 @@ import logging import urllib.request -import pkg_resources +from importlib.metadata import version, PackageNotFoundError from socha.api.networking.game_client import GameClient, IClientHandler from socha.utils.package_builder import SochaPackageBuilder @@ -142,7 +142,7 @@ def _setup_debugger(self, verbose: bool, log_level: int): def check_socha_version(): package_name = "socha" try: - installed_version = pkg_resources.get_distribution(package_name).version + installed_version = version(package_name) # trunk-ignore(bandit/B310) response = urllib.request.urlopen( f"https://pypi.org/pypi/{package_name}/json" @@ -158,7 +158,7 @@ def check_socha_version(): logging.info( f"You're running the latest version of {package_name} ({latest_version})" ) - except pkg_resources.DistributionNotFound: + except PackageNotFoundError: logging.error(f"{package_name} is not installed.") except urllib.error.URLError as e: logging.warning( diff --git a/requirements.txt b/requirements.txt index 846425b..e69de29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +0,0 @@ -xsdata==25.7 \ No newline at end of file From 73eaf44895f6028e712249b8c1be45bf79639845 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:16:35 +0100 Subject: [PATCH 05/15] fix: ci rust verbose test --- .github/workflows/ci.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 005fce2..eab49e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,10 +22,11 @@ jobs: # Clippy - Rust linter - name: Install Rust toolchain run: rustup toolchain install stable + - name: Run Clippy run: rustup component add clippy && cargo clippy -- -D warnings - # Install dependencies and run unittests within the virtual environment + # Python linting + PyO3 develop mode - name: Setup and run tests in virtual environment run: | python -m venv venv @@ -36,9 +37,10 @@ jobs: maturin develop python -m unittest discover -s tests -p '*.py' - - # Build and test steps for Rust + # Build Rust - name: Build run: cargo build --verbose + + # Run Rust tests without PyO3 linking - name: Run tests - run: cargo test --verbose + run: cargo test --no-default-features --verbose From fe9d36824dff7c2304772a4f2a05cf3cf3c286cd Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:21:50 +0100 Subject: [PATCH 06/15] fix: cargo toml for tests --- Cargo.toml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1a87dcd..89b8d30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,11 +7,12 @@ edition = "2021" name = "socha" crate-type = ["cdylib"] +[features] +default = [] +extension-module = ["pyo3/extension-module"] + [dependencies] -pyo3 = { version = "0.27.1", features = ["extension-module"] } -pyo3-log = "0.13.2" +pyo3 = { version = "0.27.1", optional = true } +pyo3-log = { version = "0.13.2", optional = true } log = "0.4.20" itertools = "0.13.0" - -[features] -extension-module = ["pyo3/extension-module"] From 053919726270721812fe85a0bd9c2617259a94b2 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:28:01 +0100 Subject: [PATCH 07/15] fix: now i hope --- .github/workflows/ci.yaml | 42 +++++++++++++++++++++++++++++---------- Cargo.toml | 12 +++++------ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eab49e7..7561e3f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,25 +22,45 @@ jobs: # Clippy - Rust linter - name: Install Rust toolchain run: rustup toolchain install stable - - name: Run Clippy run: rustup component add clippy && cargo clippy -- -D warnings - # Python linting + PyO3 develop mode - - name: Setup and run tests in virtual environment + # Setup Python virtual environment for PyO3 + - name: Setup Python environment run: | python -m venv venv source venv/bin/activate - pip install ruff + pip install --upgrade pip setuptools maturin ruff + python -m pip list + + # Lint Python + - name: Lint Python + run: | + source venv/bin/activate ruff check . - pip install maturin - maturin develop + + # Build PyO3 extension in-place + - name: Build PyO3 extension + run: | + source venv/bin/activate + maturin develop --release + + # Run Python unit tests + - name: Run Python tests + run: | + source venv/bin/activate python -m unittest discover -s tests -p '*.py' - # Build Rust - - name: Build - run: cargo build --verbose + # Build Rust without features (for pure Rust tests) + - name: Rust build (no features) + run: cargo build --no-default-features --verbose - # Run Rust tests without PyO3 linking - - name: Run tests + # Run Rust tests without PyO3 + - name: Rust tests (no PyO3) run: cargo test --no-default-features --verbose + + # Run Rust tests with PyO3 linked + - name: Rust tests (with PyO3) + run: | + source venv/bin/activate + cargo test --features extension-module --verbose diff --git a/Cargo.toml b/Cargo.toml index 89b8d30..27e90aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,12 +7,12 @@ edition = "2021" name = "socha" crate-type = ["cdylib"] -[features] -default = [] -extension-module = ["pyo3/extension-module"] - [dependencies] -pyo3 = { version = "0.27.1", optional = true } -pyo3-log = { version = "0.13.2", optional = true } +pyo3 = { version = "0.27.1", optional = true, features = ["extension-module"] } +pyo3-log = "0.13.2" log = "0.4.20" itertools = "0.13.0" + +[features] +extension-module = ["pyo3/extension-module"] +default = [] From c3c99e033b00834659cad1c8442bc5e3c640b587 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:32:14 +0100 Subject: [PATCH 08/15] now? --- .github/workflows/ci.yaml | 37 +++++++++++++------------------------ Cargo.toml | 4 ++-- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7561e3f..5318bc7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,13 +2,11 @@ name: Continuous Integration on: push: - branches: - - master + branches: [master] pull_request: types: [opened, synchronize, reopened] permissions: read-all - env: CARGO_TERM_COLOR: always @@ -19,19 +17,20 @@ jobs: steps: - uses: actions/checkout@v3 - # Clippy - Rust linter + # Install Rust - name: Install Rust toolchain run: rustup toolchain install stable + + # Clippy (all features including PyO3) - name: Run Clippy - run: rustup component add clippy && cargo clippy -- -D warnings + run: cargo clippy --all-targets --all-features -- -D warnings - # Setup Python virtual environment for PyO3 - - name: Setup Python environment + # Setup Python environment + - name: Setup Python run: | python -m venv venv source venv/bin/activate pip install --upgrade pip setuptools maturin ruff - python -m pip list # Lint Python - name: Lint Python @@ -39,28 +38,18 @@ jobs: source venv/bin/activate ruff check . - # Build PyO3 extension in-place + # Build PyO3 extension - name: Build PyO3 extension run: | source venv/bin/activate maturin develop --release - # Run Python unit tests - - name: Run Python tests + # Run Python tests + - name: Python tests run: | source venv/bin/activate python -m unittest discover -s tests -p '*.py' - # Build Rust without features (for pure Rust tests) - - name: Rust build (no features) - run: cargo build --no-default-features --verbose - - # Run Rust tests without PyO3 - - name: Rust tests (no PyO3) - run: cargo test --no-default-features --verbose - - # Run Rust tests with PyO3 linked - - name: Rust tests (with PyO3) - run: | - source venv/bin/activate - cargo test --features extension-module --verbose + # Run Rust tests with all features + - name: Rust tests + run: cargo test --all-features --verbose diff --git a/Cargo.toml b/Cargo.toml index 27e90aa..f8d30c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,11 +8,11 @@ name = "socha" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.27.1", optional = true, features = ["extension-module"] } +pyo3 = { version = "0.27.1", features = ["extension-module"] } pyo3-log = "0.13.2" log = "0.4.20" itertools = "0.13.0" [features] extension-module = ["pyo3/extension-module"] -default = [] +default = ["extension-module"] From 4f506f6d7b288b26ceb83621afa160a5e33d73a6 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:35:59 +0100 Subject: [PATCH 09/15] lets see --- .github/workflows/ci.yaml | 48 ++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5318bc7..62692d7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,11 +2,13 @@ name: Continuous Integration on: push: - branches: [master] + branches: + - master pull_request: types: [opened, synchronize, reopened] permissions: read-all + env: CARGO_TERM_COLOR: always @@ -15,41 +17,45 @@ jobs: runs-on: ubuntu-latest steps: + # Checkout code - uses: actions/checkout@v3 - # Install Rust + # Install Rust toolchain - name: Install Rust toolchain run: rustup toolchain install stable - # Clippy (all features including PyO3) + # Clippy - Rust linter - name: Run Clippy - run: cargo clippy --all-targets --all-features -- -D warnings + run: | + rustup component add clippy + cargo clippy -- -D warnings + + # Install Python dev headers (needed for PyO3) + - name: Install Python dev dependencies + run: sudo apt-get update && sudo apt-get install -y python3-dev python3-venv - # Setup Python environment - - name: Setup Python + # Setup Python virtual environment + - name: Setup Python environment run: | - python -m venv venv + python3 -m venv venv source venv/bin/activate - pip install --upgrade pip setuptools maturin ruff + pip install --upgrade pip - # Lint Python - - name: Lint Python + # Python linting + - name: Python linting run: | source venv/bin/activate + pip install ruff ruff check . - # Build PyO3 extension - - name: Build PyO3 extension + # Build and test PyO3 extension + Python tests using maturin + - name: Build and test Rust + PyO3 run: | source venv/bin/activate + pip install maturin maturin develop --release + maturin test --release - # Run Python tests - - name: Python tests - run: | - source venv/bin/activate - python -m unittest discover -s tests -p '*.py' - - # Run Rust tests with all features - - name: Rust tests - run: cargo test --all-features --verbose + # Optional: build Rust without Python (for pure Rust CI) + - name: Build Rust only + run: cargo build --verbose From fa53d350d7c73d714b0a48b5dffecb63ed015b34 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:42:25 +0100 Subject: [PATCH 10/15] now again? --- .github/workflows/ci.yaml | 50 ++++++++++++++++++--------------------- Cargo.toml | 1 - 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62692d7..5ab0415 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,45 +17,41 @@ jobs: runs-on: ubuntu-latest steps: - # Checkout code - uses: actions/checkout@v3 + # Set up Python first + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + # Install Rust toolchain - name: Install Rust toolchain - run: rustup toolchain install stable - - # Clippy - Rust linter - - name: Run Clippy run: | + rustup toolchain install stable + rustup default stable rustup component add clippy - cargo clippy -- -D warnings - # Install Python dev headers (needed for PyO3) - - name: Install Python dev dependencies - run: sudo apt-get update && sudo apt-get install -y python3-dev python3-venv + # Clippy - Rust linter + - name: Run Clippy + run: cargo clippy -- -D warnings - # Setup Python virtual environment - - name: Setup Python environment - run: | - python3 -m venv venv - source venv/bin/activate - pip install --upgrade pip + # Build Rust code first + - name: Build + run: cargo build --verbose - # Python linting - - name: Python linting + # Set up Python virtual environment and run Python tests + - name: Setup and run Python tests run: | + python -m venv venv source venv/bin/activate - pip install ruff + pip install ruff maturin ruff check . + maturin develop + python -m unittest discover -s tests -p '*.py' - # Build and test PyO3 extension + Python tests using maturin - - name: Build and test Rust + PyO3 + # Run Rust tests with Python environment available + - name: Run tests run: | source venv/bin/activate - pip install maturin - maturin develop --release - maturin test --release - - # Optional: build Rust without Python (for pure Rust CI) - - name: Build Rust only - run: cargo build --verbose + cargo test --verbose \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f8d30c1..1a87dcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,3 @@ itertools = "0.13.0" [features] extension-module = ["pyo3/extension-module"] -default = ["extension-module"] From 552567604099ef57f1c51c15c66cef91c6a725a1 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:47:17 +0100 Subject: [PATCH 11/15] pyo3 --- .github/workflows/ci.yaml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5ab0415..97c70f8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,12 +19,18 @@ jobs: steps: - uses: actions/checkout@v3 - # Set up Python first + # Set up Python with development headers first - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.x' + # Install Python development packages + - name: Install Python dev dependencies + run: | + sudo apt-get update + sudo apt-get install -y python3-dev + # Install Rust toolchain - name: Install Rust toolchain run: | @@ -32,6 +38,16 @@ jobs: rustup default stable rustup component add clippy + # Set environment variables for PyO3 + - name: Configure PyO3 + run: | + # Find Python library path and set environment variables + python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))" + python -c "import sysconfig; print(sysconfig.get_config_var('INCLUDEPY'))" + + # Set PyO3 environment variables + echo "PYO3_PYTHON=$(which python)" >> $GITHUB_ENV + # Clippy - Rust linter - name: Run Clippy run: cargo clippy -- -D warnings @@ -50,8 +66,11 @@ jobs: maturin develop python -m unittest discover -s tests -p '*.py' - # Run Rust tests with Python environment available - - name: Run tests + # Run Rust tests with proper Python linkage + - name: Run Rust tests run: | source venv/bin/activate + # Ensure Python is in the path and libraries are available + export PYTHON_SYS_EXECUTABLE=$(which python) + # Run tests with explicit Python configuration cargo test --verbose \ No newline at end of file From 46a4dec7a89e26411dbcc8b7b95226238bd3124c Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 21:53:00 +0100 Subject: [PATCH 12/15] maturin --- .github/workflows/ci.yaml | 41 +++++++++++++++------------------------ 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 97c70f8..7b39407 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,18 +19,12 @@ jobs: steps: - uses: actions/checkout@v3 - # Set up Python with development headers first + # Set up Python first - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.x' - # Install Python development packages - - name: Install Python dev dependencies - run: | - sudo apt-get update - sudo apt-get install -y python3-dev - # Install Rust toolchain - name: Install Rust toolchain run: | @@ -38,16 +32,6 @@ jobs: rustup default stable rustup component add clippy - # Set environment variables for PyO3 - - name: Configure PyO3 - run: | - # Find Python library path and set environment variables - python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))" - python -c "import sysconfig; print(sysconfig.get_config_var('INCLUDEPY'))" - - # Set PyO3 environment variables - echo "PYO3_PYTHON=$(which python)" >> $GITHUB_ENV - # Clippy - Rust linter - name: Run Clippy run: cargo clippy -- -D warnings @@ -56,21 +40,28 @@ jobs: - name: Build run: cargo build --verbose - # Set up Python virtual environment and run Python tests - - name: Setup and run Python tests + # Set up Python virtual environment FIRST + - name: Setup Python environment run: | python -m venv venv source venv/bin/activate - pip install ruff maturin - ruff check . + pip install maturin ruff + + # Run maturin develop to build the extension and set up environment + - name: Build Python extension + run: | + source venv/bin/activate maturin develop + + # Run Python tests + - name: Run Python tests + run: | + source venv/bin/activate + ruff check . python -m unittest discover -s tests -p '*.py' - # Run Rust tests with proper Python linkage + # Run Rust tests - they should work now with the extension built - name: Run Rust tests run: | source venv/bin/activate - # Ensure Python is in the path and libraries are available - export PYTHON_SYS_EXECUTABLE=$(which python) - # Run tests with explicit Python configuration cargo test --verbose \ No newline at end of file From dfd1d4c02984b6fc3972d2bf1839a86baa342e7d Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 22:00:26 +0100 Subject: [PATCH 13/15] hopefully --- .github/workflows/ci.yaml | 48 ++++++++++++++------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b39407..56a5c84 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,49 +19,35 @@ jobs: steps: - uses: actions/checkout@v3 - # Set up Python first - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - # Install Rust toolchain - - name: Install Rust toolchain - run: | - rustup toolchain install stable - rustup default stable - rustup component add clippy + - name: Install Rust + run: rustup toolchain install stable - # Clippy - Rust linter + # Run Clippy (Rust linter) - name: Run Clippy - run: cargo clippy -- -D warnings - - # Build Rust code first - - name: Build - run: cargo build --verbose + run: rustup component add clippy && cargo clippy -- -D warnings - # Set up Python virtual environment FIRST - - name: Setup Python environment + # Setup Python virtual environment and run Python lint/tests + - name: Setup Python and run tests run: | python -m venv venv source venv/bin/activate - pip install maturin ruff - - # Run maturin develop to build the extension and set up environment - - name: Build Python extension - run: | - source venv/bin/activate + pip install --upgrade pip + pip install ruff maturin + ruff check . maturin develop + python -m unittest discover -s tests -p '*.py' - # Run Python tests - - name: Run Python tests + # Build Rust with PyO3 + - name: Build Rust run: | source venv/bin/activate - ruff check . - python -m unittest discover -s tests -p '*.py' + export PYTHON_SYS_EXECUTABLE=$(which python) + cargo build --verbose - # Run Rust tests - they should work now with the extension built + # Run Rust tests with all features (including PyO3) - name: Run Rust tests run: | source venv/bin/activate - cargo test --verbose \ No newline at end of file + export PYTHON_SYS_EXECUTABLE=$(which python) + cargo test --all-features --verbose From 5e896ca42f05ecf5156a1da2318881d1f6818015 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 22:04:41 +0100 Subject: [PATCH 14/15] ubuntu --- .github/workflows/ci.yaml | 40 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 56a5c84..b528db2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,40 +14,46 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - # Install Rust toolchain - - name: Install Rust + # Install Rust + - name: Install Rust toolchain run: rustup toolchain install stable - # Run Clippy (Rust linter) + # Run Clippy - name: Run Clippy run: rustup component add clippy && cargo clippy -- -D warnings - # Setup Python virtual environment and run Python lint/tests - - name: Setup Python and run tests + # Install Python dependencies for PyO3 + - name: Setup Python run: | - python -m venv venv + sudo apt-get update + sudo apt-get install -y python3-dev python3-venv python3-pip + python3 -m venv venv source venv/bin/activate pip install --upgrade pip - pip install ruff maturin + pip install maturin ruff ruff check . + + # Build Rust extension in develop mode + - name: Build Python extension + run: | + source venv/bin/activate maturin develop - python -m unittest discover -s tests -p '*.py' - # Build Rust with PyO3 - - name: Build Rust + # Run Python tests + - name: Run Python unittests run: | source venv/bin/activate - export PYTHON_SYS_EXECUTABLE=$(which python) - cargo build --verbose + python -m unittest discover -s tests -p '*.py' + + # Build Rust normally + - name: Build Rust + run: cargo build --verbose # Run Rust tests with all features (including PyO3) - name: Run Rust tests - run: | - source venv/bin/activate - export PYTHON_SYS_EXECUTABLE=$(which python) - cargo test --all-features --verbose + run: cargo test --all-features --verbose From be9bca877080ee10004504db3efd40e637eb38a3 Mon Sep 17 00:00:00 2001 From: YoEnte Date: Mon, 17 Nov 2025 22:19:20 +0100 Subject: [PATCH 15/15] set back and python env --- .github/workflows/ci.yaml | 41 +++++++++++++-------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b528db2..963722d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,46 +14,33 @@ env: jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - # Install Rust + # Clippy - Rust linter - name: Install Rust toolchain run: rustup toolchain install stable - - # Run Clippy - name: Run Clippy run: rustup component add clippy && cargo clippy -- -D warnings - # Install Python dependencies for PyO3 - - name: Setup Python + # Install dependencies and run unittests within the virtual environment + - name: Setup and run tests in virtual environment run: | - sudo apt-get update - sudo apt-get install -y python3-dev python3-venv python3-pip - python3 -m venv venv + python -m venv venv source venv/bin/activate - pip install --upgrade pip - pip install maturin ruff + pip install ruff ruff check . - - # Build Rust extension in develop mode - - name: Build Python extension - run: | - source venv/bin/activate + pip install maturin maturin develop - - # Run Python tests - - name: Run Python unittests - run: | - source venv/bin/activate python -m unittest discover -s tests -p '*.py' - # Build Rust normally - - name: Build Rust - run: cargo build --verbose - # Run Rust tests with all features (including PyO3) - - name: Run Rust tests - run: cargo test --all-features --verbose + # Build and test steps for Rust + - name: Build + run: cargo build --verbose + - name: Run tests + run: | + source venv/bin/activate + cargo test --verbose