From b43bb5917fddc7b2450845eb652b13edb264b21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=8B=9C=EC=9B=90?= Date: Wed, 6 May 2026 19:50:32 +0900 Subject: [PATCH] =?UTF-8?q?Rust=20=ED=81=AC=EB=A0=88=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EB=A3=A8=ED=8A=B8=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 맥락: - GUI 이식 전에 Rust crate와 proto schema 위치를 Python package 내부에서 분리한다. - Cargo 작업, IDE 인식, 빌드 산출물 관리를 루트 구조에 맞춘다. 변경: - rust_core를 rust/lost-cities-core로 이동하고 proto/lost_cities.proto를 루트 proto 디렉터리로 옮겼다. - Rust build.rs, Python Rust backend, Rust parity 테스트의 경로를 새 위치로 수정했다. - Python package-data에서 Rust crate와 proto 항목을 제거하고 README/port notes를 갱신했다. 확인: - uv sync --extra gui --reinstall-package coolrl-lost-cities - uv run pytest tests/games/classic - uv run lost-cities-classic --- README.md | 7 +++++++ docs/classic-port-notes.md | 5 ++++- .../games/classic/schemas => proto}/lost_cities.proto | 0 pyproject.toml | 6 ------ .../classic/rust_core => rust/lost-cities-core}/Cargo.lock | 0 .../classic/rust_core => rust/lost-cities-core}/Cargo.toml | 0 .../classic/rust_core => rust/lost-cities-core}/build.rs | 2 +- .../lost-cities-core}/src/bin/lost_cities_probe.rs | 0 .../rust_core => rust/lost-cities-core}/src/config.rs | 0 .../rust_core => rust/lost-cities-core}/src/engine.rs | 0 .../rust_core => rust/lost-cities-core}/src/error.rs | 0 .../classic/rust_core => rust/lost-cities-core}/src/lib.rs | 0 .../rust_core => rust/lost-cities-core}/src/service.rs | 0 .../rust_core => rust/lost-cities-core}/src/state.rs | 0 src/coolrl_lost_cities/games/classic/backends/rust.py | 4 ++-- tests/games/classic/test_rust_parity.py | 2 +- 16 files changed, 15 insertions(+), 11 deletions(-) rename {src/coolrl_lost_cities/games/classic/schemas => proto}/lost_cities.proto (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/Cargo.lock (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/Cargo.toml (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/build.rs (89%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/src/bin/lost_cities_probe.rs (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/src/config.rs (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/src/engine.rs (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/src/error.rs (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/src/lib.rs (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/src/service.rs (100%) rename {src/coolrl_lost_cities/games/classic/rust_core => rust/lost-cities-core}/src/state.rs (100%) diff --git a/README.md b/README.md index 3fe2818..ad64b2c 100644 --- a/README.md +++ b/README.md @@ -50,4 +50,11 @@ backend = build_backend("python", classic_config(), seed=1) snapshot = backend.snapshot() ``` +Rust sources live outside the Python package: + +```text +rust/lost-cities-core/ +proto/lost_cities.proto +``` + See [classic port notes](docs/classic-port-notes.md) for the current direction. diff --git a/docs/classic-port-notes.md b/docs/classic-port-notes.md index 7247fad..40c739c 100644 --- a/docs/classic-port-notes.md +++ b/docs/classic-port-notes.md @@ -30,7 +30,10 @@ src/coolrl_lost_cities/ fixtures/ assets/ docs/ - rust_core/ +rust/ + lost-cities-core/ +proto/ + lost_cities.proto ``` Tests should live outside the package, roughly under: diff --git a/src/coolrl_lost_cities/games/classic/schemas/lost_cities.proto b/proto/lost_cities.proto similarity index 100% rename from src/coolrl_lost_cities/games/classic/schemas/lost_cities.proto rename to proto/lost_cities.proto diff --git a/pyproject.toml b/pyproject.toml index a0ba890..716a969 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,10 +39,4 @@ include = ["coolrl_lost_cities*"] "assets/*.json", "fixtures/*.json", "docs/*.md", - "schemas/*.proto", - "rust_core/Cargo.lock", - "rust_core/Cargo.toml", - "rust_core/build.rs", - "rust_core/src/*.rs", - "rust_core/src/bin/*.rs", ] diff --git a/src/coolrl_lost_cities/games/classic/rust_core/Cargo.lock b/rust/lost-cities-core/Cargo.lock similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/Cargo.lock rename to rust/lost-cities-core/Cargo.lock diff --git a/src/coolrl_lost_cities/games/classic/rust_core/Cargo.toml b/rust/lost-cities-core/Cargo.toml similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/Cargo.toml rename to rust/lost-cities-core/Cargo.toml diff --git a/src/coolrl_lost_cities/games/classic/rust_core/build.rs b/rust/lost-cities-core/build.rs similarity index 89% rename from src/coolrl_lost_cities/games/classic/rust_core/build.rs rename to rust/lost-cities-core/build.rs index 48b2d3e..09a4673 100644 --- a/src/coolrl_lost_cities/games/classic/rust_core/build.rs +++ b/rust/lost-cities-core/build.rs @@ -4,7 +4,7 @@ fn main() { let protoc = protoc_bin_vendored::protoc_bin_path().expect("vendored protoc"); std::env::set_var("PROTOC", protoc); - let proto_dir = PathBuf::from("../schemas"); + let proto_dir = PathBuf::from("../../proto"); let proto_file = proto_dir.join("lost_cities.proto"); println!("cargo:rerun-if-changed={}", proto_file.display()); diff --git a/src/coolrl_lost_cities/games/classic/rust_core/src/bin/lost_cities_probe.rs b/rust/lost-cities-core/src/bin/lost_cities_probe.rs similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/src/bin/lost_cities_probe.rs rename to rust/lost-cities-core/src/bin/lost_cities_probe.rs diff --git a/src/coolrl_lost_cities/games/classic/rust_core/src/config.rs b/rust/lost-cities-core/src/config.rs similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/src/config.rs rename to rust/lost-cities-core/src/config.rs diff --git a/src/coolrl_lost_cities/games/classic/rust_core/src/engine.rs b/rust/lost-cities-core/src/engine.rs similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/src/engine.rs rename to rust/lost-cities-core/src/engine.rs diff --git a/src/coolrl_lost_cities/games/classic/rust_core/src/error.rs b/rust/lost-cities-core/src/error.rs similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/src/error.rs rename to rust/lost-cities-core/src/error.rs diff --git a/src/coolrl_lost_cities/games/classic/rust_core/src/lib.rs b/rust/lost-cities-core/src/lib.rs similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/src/lib.rs rename to rust/lost-cities-core/src/lib.rs diff --git a/src/coolrl_lost_cities/games/classic/rust_core/src/service.rs b/rust/lost-cities-core/src/service.rs similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/src/service.rs rename to rust/lost-cities-core/src/service.rs diff --git a/src/coolrl_lost_cities/games/classic/rust_core/src/state.rs b/rust/lost-cities-core/src/state.rs similarity index 100% rename from src/coolrl_lost_cities/games/classic/rust_core/src/state.rs rename to rust/lost-cities-core/src/state.rs diff --git a/src/coolrl_lost_cities/games/classic/backends/rust.py b/src/coolrl_lost_cities/games/classic/backends/rust.py index a2f7ec2..8938f98 100644 --- a/src/coolrl_lost_cities/games/classic/backends/rust.py +++ b/src/coolrl_lost_cities/games/classic/backends/rust.py @@ -12,6 +12,7 @@ from ..interfaces import BackendName, Snapshot from .common import snapshot_from_trace, snapshot_summary LOGGER = logging.getLogger("coolrl_lost_cities.games.classic.backends.rust") +RUST_CORE_DIR = Path(__file__).resolve().parents[5] / "rust" / "lost-cities-core" class RustLostCitiesBackend: @@ -70,7 +71,6 @@ class RustLostCitiesBackend: "steps": [{"action": None}] + [{"action": action} for action in self.actions], } - rust_core = Path(__file__).resolve().parents[1] / "rust_core" with tempfile.NamedTemporaryFile("w", suffix=".json", delete=False) as handle: json.dump(fixture, handle) fixture_path = Path(handle.name) @@ -86,7 +86,7 @@ class RustLostCitiesBackend: "trace", str(fixture_path), ], - cwd=rust_core, + cwd=RUST_CORE_DIR, check=True, text=True, capture_output=True, diff --git a/tests/games/classic/test_rust_parity.py b/tests/games/classic/test_rust_parity.py index bc6fead..1e7b916 100644 --- a/tests/games/classic/test_rust_parity.py +++ b/tests/games/classic/test_rust_parity.py @@ -5,11 +5,11 @@ import subprocess import coolrl_lost_cities.games.classic as classic from coolrl_lost_cities.games.classic.game import GameState, LostCitiesConfig, build_deck +from coolrl_lost_cities.games.classic.backends.rust import RUST_CORE_DIR LOST_CITIES_DIR = Path(classic.__file__).resolve().parent FIXTURE_DIR = LOST_CITIES_DIR / "fixtures" -RUST_CORE_DIR = LOST_CITIES_DIR / "rust_core" def _run_probe(*args: str) -> dict: