diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 005fce2..963722d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,4 +41,6 @@ jobs: - name: Build run: cargo build --verbose - name: Run tests - run: cargo test --verbose + run: | + source venv/bin/activate + cargo test --verbose 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..3f3b7b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,13 +6,13 @@ 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." 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..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': 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): """ diff --git a/python/socha/starter.py b/python/socha/starter.py index b722f26..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 @@ -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") @@ -141,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" @@ -157,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( @@ -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).", ) diff --git a/requirements.txt b/requirements.txt index 0c0bad1..e69de29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +0,0 @@ -xsdata==22.9 \ 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();