GeezerVison is showing github.com — build: 본체 기준 44d6e4fe(#793) — 문서 정보 쓰기 우회를 걷고, 저장소 뿌리 빌드 시험을 한 번에 하나씩 · airmang/python-hwpx-automation@3ce1263
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/tests.yml +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 58 | 58 | # `python -m pip install "python-hwpx>=7.0,<8"` from PyPI instead of | 59 | 59 | # the editable checkout and point this ref at the v7.0.0 tag (the | 60 | 60 | # runtime-parity suites still read fixtures from this checkout). | 61 | | - ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '85e1b7c8c2f597a162e6dcf32a1978bdb7a1cb29' }} | | 61 | + ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '44d6e4fea486a7ec1e0a4be0a7cc04094599cc57' }} | 62 | 62 | path: python-hwpx | 63 | 63 | - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | 64 | 64 | with: | @@ -204,7 +204,7 @@ jobs: | 204 | 204 | - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | 205 | 205 | with: | 206 | 206 | repository: airmang/python-hwpx | 207 | | - ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '85e1b7c8c2f597a162e6dcf32a1978bdb7a1cb29' }} | | 207 | + ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '44d6e4fea486a7ec1e0a4be0a7cc04094599cc57' }} | 208 | 208 | path: python-hwpx | 209 | 209 | - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | 210 | 210 | with: | @@ -239,7 +239,7 @@ jobs: | 239 | 239 | - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | 240 | 240 | with: | 241 | 241 | repository: airmang/python-hwpx | 242 | | - ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '85e1b7c8c2f597a162e6dcf32a1978bdb7a1cb29' }} | | 242 | + ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '44d6e4fea486a7ec1e0a4be0a7cc04094599cc57' }} | 243 | 243 | path: python-hwpx | 244 | 244 | - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | 245 | 245 | with: | @@ -346,7 +346,7 @@ jobs: | 346 | 346 | - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | 347 | 347 | with: | 348 | 348 | repository: airmang/python-hwpx | 349 | | - ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '85e1b7c8c2f597a162e6dcf32a1978bdb7a1cb29' }} | | 349 | + ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '44d6e4fea486a7ec1e0a4be0a7cc04094599cc57' }} | 350 | 350 | path: python-hwpx | 351 | 351 | - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | 352 | 352 | with: | |
Collapse file Copy file name to clipboardExpand all lines: CHANGELOG.md +3Lines changed: 3 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,6 +64,9 @@ MCP 도구의 이름·인자·출력은 그대로이고, 도구 계약은 python | 64 | 64 | `hwpx_automation.integrations.langchain.HwpxLoader`와 LlamaIndex 리더 `hwpx_automation.integrations.llama_index.HwpxReader`. | 65 | 65 | - `hwpx_automation.forms`: `find_cell_by_label(doc, …)`, `form_slots(doc, …)`, `fill_by_path(doc, …)`, `form_choices(doc)`, | 66 | 66 | `choose(doc, …)`. | | 67 | +- `hwpx_automation.save_dates`: 이 패키지가 쓰는 문서의 날짜(`stamp_save_dates`, `date_new_document`)와 그 시각 | | 68 | + (`save_time`), 재현 시험·견줌에서만 쓰는 시각 고정(`fixed_save_time`), 저장 날짜만 다른지 보는 | | 69 | + `same_but_save_dates`. `hwpx_automation.upstream`도 같은 이름을 내보냅니다. | 67 | 70 | - `hwpx_automation.mail_merge`: `merge_template_rows`, `load_mail_merge_rows`, `inspect_mail_merge_placeholders`, | 68 | 71 | `MAIL_MERGE_REPORT_VERSION`. | 69 | 72 | - `hwpx_automation.preview`: `render_layout_preview`, `render_document_viewer`, 수식 그리기(`render_equation`, | |
Collapse file Copy file name to clipboardExpand all lines: src/hwpx_automation/save_dates.py +2-36Lines changed: 2 additions & 36 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -82,7 +82,7 @@ def stamp_save_dates(document: HwpxDocument) -> None: | 82 | 82 | fields["created_date"] = stamp | 83 | 83 | if not (metadata is not None and metadata.date) and created_moment is not None: | 84 | 84 | fields["date"] = created_moment | 85 | | - _set_metadata(document, **fields) | | 85 | + document.parts.set_document_metadata(**fields) # python-hwpx: only the written fields' text | 86 | 86 |
| 87 | 87 |
| 88 | 88 | def date_new_document(document: HwpxDocument) -> None: | @@ -94,7 +94,7 @@ def date_new_document(document: HwpxDocument) -> None: | 94 | 94 | moment = save_time() | 95 | 95 | stamp = moment.strftime(_SAVE_TIME_FORMAT) | 96 | 96 | document.parts.clear_document_authors() | 97 | | - _set_metadata(document, created_date=stamp, modified_date=stamp, date=moment) | | 97 | + document.parts.set_document_metadata(created_date=stamp, modified_date=stamp, date=moment) | 98 | 98 |
| 99 | 99 |
| 100 | 100 | def _parse_save_time(text: str) -> datetime | None: | @@ -105,40 +105,6 @@ def _parse_save_time(text: str) -> datetime | None: | 105 | 105 | return moment.replace(tzinfo=timezone.utc) | 106 | 106 |
| 107 | 107 |
| 108 | | -_OPF_META = "{http://www.idpf.org/2007/opf/}meta" | 109 | | -_OPF_METADATA = "{http://www.idpf.org/2007/opf/}metadata" | 110 | | -_META_NAMES = {"created_date": "CreatedDate", "modified_date": "ModifiedDate", "date": "date"} | 111 | | - | 112 | | - | 113 | | -def _set_metadata(document: HwpxDocument, **fields: Any) -> None: | 114 | | - """python-hwpx's ``set_document_metadata`` (it changes only the text of the fields it writes and | 115 | | - keeps the rest of ``content.hpf`` as read, python-hwpx #790), except while the manifest holds | 116 | | - changes its part does not yet (a section just added): then the setter writes the part from the | 117 | | - stale tree and the save fails, so the fields go into the manifest tree the save writes.""" | 118 | | - | 119 | | - from lxml import etree | 120 | | - | 121 | | - package = document.package | 122 | | - name = package.main_content.full_path | 123 | | - tree = package.manifest_tree() | 124 | | - if etree.tostring(tree, method="c14n") == etree.tostring(package.get_xml(name), method="c14n"): | 125 | | - document.parts.set_document_metadata(**fields) | 126 | | - return | 127 | | - from hwpx.oxml.document_metadata import hangul_date_text | 128 | | - | 129 | | - metadata = tree.find(_OPF_METADATA) | 130 | | - if metadata is None: | 131 | | - return | 132 | | - for key, value in fields.items(): | 133 | | - field = _META_NAMES[key] | 134 | | - text = hangul_date_text(value) if isinstance(value, datetime) else value | 135 | | - element = next((meta for meta in metadata.iter(_OPF_META) if meta.get("name") == field), None) | 136 | | - if element is None: | 137 | | - element = metadata.makeelement(_OPF_META, {"name": field, "content": "text"}) | 138 | | - metadata.append(element) | 139 | | - element.text = text or None | 140 | | - | 141 | | - | 142 | 108 | _SAVE_DATE_META = re.compile( | 143 | 109 | rb'(<opf:meta name="(CreatedDate|ModifiedDate|date)" content="text")(?:/>|>[^<]*</opf:meta>)' | 144 | 110 | ) | |
Collapse file Copy file name to clipboard +51Lines changed: 51 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# SPDX-License-Identifier: Apache-2.0 | | 2 | +"""One ``python -m build`` of the repository root at a time, across pytest-xdist workers. | | 3 | +
| | 4 | +A build in the root writes ``build/`` and ``src/*.egg-info``, and the wheel-contents test removes | | 5 | +``build/`` before it builds. Two workers doing that at once broke one another's build (the full run | | 6 | +failed one of them, a different one each time). The lock is a file created exclusively in the | | 7 | +temporary directory, named after the checkout; a lock left by a killed run is taken over after | | 8 | +``STALE_SECONDS``. | | 9 | +""" | | 10 | + | | 11 | +from __future__ import annotations | | 12 | + | | 13 | +import hashlib | | 14 | +import os | | 15 | +import tempfile | | 16 | +import time | | 17 | +from collections.abc import Iterator | | 18 | +from contextlib import contextmanager | | 19 | +from pathlib import Path | | 20 | + | | 21 | +ROOT = Path(__file__).resolve().parents[1] | | 22 | +STALE_SECONDS = 900.0 | | 23 | +_LOCK = Path(tempfile.gettempdir()) / ( | | 24 | + "hwpx-automation-build-" + hashlib.sha256(str(ROOT).encode("utf-8")).hexdigest()[:12] + ".lock" | | 25 | +) | | 26 | + | | 27 | + | | 28 | +@contextmanager | | 29 | +def repo_build_lock(timeout: float = 1800.0) -> Iterator[None]: | | 30 | + deadline = time.monotonic() + timeout | | 31 | + while True: | | 32 | + try: | | 33 | + handle = os.open(_LOCK, os.O_CREAT | os.O_EXCL | os.O_WRONLY) | | 34 | + except FileExistsError: | | 35 | + try: | | 36 | + if time.time() - _LOCK.stat().st_mtime > STALE_SECONDS: | | 37 | + _LOCK.unlink(missing_ok=True) | | 38 | + continue | | 39 | + except FileNotFoundError: | | 40 | + continue | | 41 | + if time.monotonic() > deadline: | | 42 | + raise TimeoutError(f"repository build lock still held: {_LOCK}") from None | | 43 | + time.sleep(0.5) | | 44 | + continue | | 45 | + os.write(handle, str(os.getpid()).encode("ascii")) | | 46 | + os.close(handle) | | 47 | + break | | 48 | + try: | | 49 | + yield | | 50 | + finally: | | 51 | + _LOCK.unlink(missing_ok=True) |
Collapse file Copy file name to clipboardExpand all lines: tests/test_packaging_wheel_contents.py +15-9Lines changed: 15 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 23 | 23 | from pathlib import Path | 24 | 24 |
| 25 | 25 | import pytest | | 26 | +from repo_build_lock import repo_build_lock | 26 | 27 |
| 27 | 28 | try: | 28 | 29 | import tomllib | @@ -67,15 +68,20 @@ def test_wheel_top_level_matches_the_declaration(tmp_path: Path, distribution: s | 67 | 68 | pytest.importorskip("build") | 68 | 69 |
| 69 | 70 | # 빌드 캐시를 쓰지 않는다. 재사용하는 그 트리가 문제의 원인이다. | 70 | | - stale = ROOT / "build" | 71 | | - if stale.exists(): | 72 | | - shutil.rmtree(stale) | 73 | | - | 74 | | - subprocess.run( | 75 | | - [sys.executable, "-m", "build", f"--{distribution}", "--outdir", str(tmp_path)], | 76 | | - cwd=ROOT, | 77 | | - check=True, | 78 | | - capture_output=True, | | 71 | + with repo_build_lock(): # one build of the repository root at a time (xdist workers) | | 72 | + stale = ROOT / "build" | | 73 | + if stale.exists(): | | 74 | + shutil.rmtree(stale) | | 75 | + | | 76 | + completed = subprocess.run( | | 77 | + [sys.executable, "-m", "build", f"--{distribution}", "--outdir", str(tmp_path)], | | 78 | + cwd=ROOT, | | 79 | + capture_output=True, | | 80 | + text=True, | | 81 | + ) | | 82 | + assert completed.returncode == 0, ( | | 83 | + f"python -m build --{distribution} 실패({completed.returncode}):\n" | | 84 | + f"{completed.stdout[-2000:]}\n{completed.stderr[-4000:]}" | 79 | 85 | ) | 80 | 86 |
| 81 | 87 | built = sorted(tmp_path.glob("*.whl")) | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_public_artifact_hygiene.py +23-21Lines changed: 23 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | from pathlib import Path | 9 | 9 |
| 10 | 10 | import pytest | | 11 | +from repo_build_lock import repo_build_lock | 11 | 12 |
| 12 | 13 | ROOT = Path(__file__).resolve().parents[1] | 13 | 14 | SCRIPT = ROOT / "scripts" / "check_public_hygiene.py" | @@ -55,27 +56,28 @@ def public_artifacts( | 55 | 56 | compat = output / "compat" | 56 | 57 | canonical.mkdir() | 57 | 58 | compat.mkdir() | 58 | | - subprocess.run( | 59 | | - [sys.executable, "-m", "build", "--outdir", str(canonical)], | 60 | | - cwd=ROOT, | 61 | | - check=True, | 62 | | - capture_output=True, | 63 | | - text=True, | 64 | | - ) | 65 | | - subprocess.run( | 66 | | - [ | 67 | | - sys.executable, | 68 | | - "-m", | 69 | | - "build", | 70 | | - "--outdir", | 71 | | - str(compat), | 72 | | - str(ROOT / "compat" / "hwpx-mcp-server"), | 73 | | - ], | 74 | | - cwd=ROOT, | 75 | | - check=True, | 76 | | - capture_output=True, | 77 | | - text=True, | 78 | | - ) | | 59 | + with repo_build_lock(): # one build of the repository root at a time (xdist workers) | | 60 | + subprocess.run( | | 61 | + [sys.executable, "-m", "build", "--outdir", str(canonical)], | | 62 | + cwd=ROOT, | | 63 | + check=True, | | 64 | + capture_output=True, | | 65 | + text=True, | | 66 | + ) | | 67 | + subprocess.run( | | 68 | + [ | | 69 | + sys.executable, | | 70 | + "-m", | | 71 | + "build", | | 72 | + "--outdir", | | 73 | + str(compat), | | 74 | + str(ROOT / "compat" / "hwpx-mcp-server"), | | 75 | + ], | | 76 | + cwd=ROOT, | | 77 | + check=True, | | 78 | + capture_output=True, | | 79 | + text=True, | | 80 | + ) | 79 | 81 | return tuple(sorted((*canonical.iterdir(), *compat.iterdir()))) | 80 | 82 |
| 81 | 83 |
| |
Collapse file Copy file name to clipboardExpand all lines: tests/test_readme_python_example.py +16-14Lines changed: 16 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | from pathlib import Path | 11 | 11 |
| 12 | 12 | import pytest | | 13 | +from repo_build_lock import repo_build_lock | 13 | 14 |
| 14 | 15 | ROOT = Path(__file__).resolve().parents[1] | 15 | 16 | PYTHON_FENCE = re.compile( | @@ -101,20 +102,21 @@ def test_readme_python_example_runs_saves_and_reopens_from_base_wheel( | 101 | 102 | capture_output=True, | 102 | 103 | text=True, | 103 | 104 | ) | 104 | | - subprocess.run( | 105 | | - [ | 106 | | - sys.executable, | 107 | | - "-m", | 108 | | - "build", | 109 | | - "--wheel", | 110 | | - "--outdir", | 111 | | - str(dist), | 112 | | - ], | 113 | | - cwd=ROOT, | 114 | | - check=True, | 115 | | - capture_output=True, | 116 | | - text=True, | 117 | | - ) | | 105 | + with repo_build_lock(): # one build of the repository root at a time (xdist workers) | | 106 | + subprocess.run( | | 107 | + [ | | 108 | + sys.executable, | | 109 | + "-m", | | 110 | + "build", | | 111 | + "--wheel", | | 112 | + "--outdir", | | 113 | + str(dist), | | 114 | + ], | | 115 | + cwd=ROOT, | | 116 | + check=True, | | 117 | + capture_output=True, | | 118 | + text=True, | | 119 | + ) | 118 | 120 | core_wheel = next(dist.glob("python_hwpx-*.whl")) | 119 | 121 | automation_wheel = next(dist.glob("python_hwpx_automation-*.whl")) | 120 | 122 | with zipfile.ZipFile(automation_wheel) as archive: | |
|