Skip to content

build: cargo test 실행 가능하도록 PyO3 extension-module feature 분리#13

Merged
DanMeon merged 1 commit intomainfrom
build/cargo-test-feature-flag
May 3, 2026
Merged

build: cargo test 실행 가능하도록 PyO3 extension-module feature 분리#13
DanMeon merged 1 commit intomainfrom
build/cargo-test-feature-flag

Conversation

@DanMeon
Copy link
Copy Markdown
Owner

@DanMeon DanMeon commented May 3, 2026

Summary

  • PyO3 extension-module feature 를 default features 에서 분리해 [features] 섹션으로 이동
  • pyproject.toml [tool.maturin] features 를 자기 crate 의 extension-module 가리키도록 변경 (wheel 빌드 동작 동일)
  • cargo-test job 추가 (Linux, Rust unit test 13개 실행)

Why

기존 Cargo.tomlpyo3 = { features = ["extension-module", ...] } 로 default features 에 extension-module 이 들어가 있어 cargo test 가 libpython 링크 시도 → _PyExc_SystemError 등 심볼 부재로 실패. 이 때문에 src/ir.rs#[cfg(test)] 모듈 (특히 assert_position_invariant_panics_on_mismatch#[should_panic] 가드) 이 CI 에서 검증되지 않아, v0.3.1 spec AC-12 는 source-grep 우회 (tests/test_v0_3_1_marker_char_offset.py::test_rust_uses_assert_eq_not_debug_assert) 로만 보호되고 있었다.

PyO3 FAQ "I can't run cargo test" 권장 패턴 적용:

  • default features 에서 `extension-module` 제거 → `cargo test` 정상 작동
  • `[features] extension-module = ["pyo3/extension-module"]` 섹션 분리 → maturin 이 wheel 빌드 시 명시적 활성화 (영향 0)

검증

  • `cargo test --lib` → 13 passed (`utf16_to_cp` / `simple_eq_text_alt` / `field_type_to_str` / `caption_direction_to_str` / `assert_position_invariant_panics_on_mismatch` (#[should_panic]) 포함)
  • `uv run maturin develop --release` → wheel 빌드 정상 (`cp310-abi3-macosx_11_0_arm64.whl`)
  • Python smoke pytest 37 passed → wheel 회귀 없음

Reference 패턴

PyO3 + maturin 동일 스택 OSS 모두 default features 에서 `extension-module` 제거 패턴 사용:

Related Issues

(없음 — build infra 정리)

변경사항:
- Cargo.toml: pyo3 dependency 의 default features 에서 extension-module 제거
- Cargo.toml: [features] extension-module = ["pyo3/extension-module"] 섹션 추가 — wheel 빌드 시에만 활성화
- pyproject.toml: [tool.maturin] features 를 자기 crate 의 extension-module 가리키도록 변경 (wheel 빌드 동작 동일)
- .github/workflows/ci.yml: cargo-test job 추가 (Rust unit test 13개 실행, src/ir.rs 의 #[should_panic] 검증 포함)
- .github/workflows/ci.yml: all-tests-passed aggregator 의 needs/allowed-skips 에 cargo-test 등록

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@DanMeon DanMeon merged commit a264820 into main May 3, 2026
16 checks passed
@DanMeon DanMeon deleted the build/cargo-test-feature-flag branch May 3, 2026 04:43
DanMeon added a commit that referenced this pull request May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant