GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — build: 본체 기준 44d6e4fe(#793) — 문서 정보 쓰기 우회를 걷고, 저장소 뿌리 빌드 시험을 한 번에 하나씩 · airmang/python-hwpx-automation@3ce1263

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • tests.yml
  • CHANGELOG.md
  • src/hwpx_automation
    • save_dates.py
  • tests
    • repo_build_lock.py
    • test_packaging_wheel_contents.py
    • test_public_artifact_hygiene.py
    • test_readme_python_example.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/tests.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tests.yml
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
# `python -m pip install "python-hwpx>=7.0,<8"` from PyPI instead of
5959
# the editable checkout and point this ref at the v7.0.0 tag (the
6060
# 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' }}
6262
path: python-hwpx
6363
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
6464
with:
@@ -204,7 +204,7 @@ jobs:
204204
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
205205
with:
206206
repository: airmang/python-hwpx
207-
ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '85e1b7c8c2f597a162e6dcf32a1978bdb7a1cb29' }}
207+
ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '44d6e4fea486a7ec1e0a4be0a7cc04094599cc57' }}
208208
path: python-hwpx
209209
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
210210
with:
@@ -239,7 +239,7 @@ jobs:
239239
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
240240
with:
241241
repository: airmang/python-hwpx
242-
ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '85e1b7c8c2f597a162e6dcf32a1978bdb7a1cb29' }}
242+
ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '44d6e4fea486a7ec1e0a4be0a7cc04094599cc57' }}
243243
path: python-hwpx
244244
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
245245
with:
@@ -346,7 +346,7 @@ jobs:
346346
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
347347
with:
348348
repository: airmang/python-hwpx
349-
ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '85e1b7c8c2f597a162e6dcf32a1978bdb7a1cb29' }}
349+
ref: ${{ vars.PYTHON_HWPX_CANDIDATE_REF || '44d6e4fea486a7ec1e0a4be0a7cc04094599cc57' }}
350350
path: python-hwpx
351351
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
352352
with:
Collapse file

‎CHANGELOG.md‎

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 numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ MCP 도구의 이름·인자·출력은 그대로이고, 도구 계약은 python
6464
`hwpx_automation.integrations.langchain.HwpxLoader`와 LlamaIndex 리더 `hwpx_automation.integrations.llama_index.HwpxReader`.
6565
- `hwpx_automation.forms`: `find_cell_by_label(doc, …)`, `form_slots(doc, …)`, `fill_by_path(doc, …)`, `form_choices(doc)`,
6666
`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`도 같은 이름을 내보냅니다.
6770
- `hwpx_automation.mail_merge`: `merge_template_rows`, `load_mail_merge_rows`, `inspect_mail_merge_placeholders`,
6871
`MAIL_MERGE_REPORT_VERSION`.
6972
- `hwpx_automation.preview`: `render_layout_preview`, `render_document_viewer`, 수식 그리기(`render_equation`,
Collapse file

‎src/hwpx_automation/save_dates.py‎

Copy file name to clipboardExpand all lines: src/hwpx_automation/save_dates.py
+2-36Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def stamp_save_dates(document: HwpxDocument) -> None:
8282
fields["created_date"] = stamp
8383
if not (metadata is not None and metadata.date) and created_moment is not None:
8484
fields["date"] = created_moment
85-
_set_metadata(document, **fields)
85+
document.parts.set_document_metadata(**fields) # python-hwpx: only the written fields' text
8686

8787

8888
def date_new_document(document: HwpxDocument) -> None:
@@ -94,7 +94,7 @@ def date_new_document(document: HwpxDocument) -> None:
9494
moment = save_time()
9595
stamp = moment.strftime(_SAVE_TIME_FORMAT)
9696
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)
9898

9999

100100
def _parse_save_time(text: str) -> datetime | None:
@@ -105,40 +105,6 @@ def _parse_save_time(text: str) -> datetime | None:
105105
return moment.replace(tzinfo=timezone.utc)
106106

107107

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-
142108
_SAVE_DATE_META = re.compile(
143109
rb'(<opf:meta name="(CreatedDate|ModifiedDate|date)" content="text")(?:/>|>[^<]*</opf:meta>)'
144110
)
Collapse file

‎tests/repo_build_lock.py‎

Copy file name to clipboard
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

‎tests/test_packaging_wheel_contents.py‎

Copy file name to clipboardExpand all lines: tests/test_packaging_wheel_contents.py
+15-9Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from pathlib import Path
2424

2525
import pytest
26+
from repo_build_lock import repo_build_lock
2627

2728
try:
2829
import tomllib
@@ -67,15 +68,20 @@ def test_wheel_top_level_matches_the_declaration(tmp_path: Path, distribution: s
6768
pytest.importorskip("build")
6869

6970
# 빌드 캐시를 쓰지 않는다. 재사용하는 그 트리가 문제의 원인이다.
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:]}"
7985
)
8086

8187
built = sorted(tmp_path.glob("*.whl"))
Collapse file

‎tests/test_public_artifact_hygiene.py‎

Copy file name to clipboardExpand all lines: tests/test_public_artifact_hygiene.py
+23-21Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pathlib import Path
99

1010
import pytest
11+
from repo_build_lock import repo_build_lock
1112

1213
ROOT = Path(__file__).resolve().parents[1]
1314
SCRIPT = ROOT / "scripts" / "check_public_hygiene.py"
@@ -55,27 +56,28 @@ def public_artifacts(
5556
compat = output / "compat"
5657
canonical.mkdir()
5758
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+
)
7981
return tuple(sorted((*canonical.iterdir(), *compat.iterdir())))
8082

8183

Collapse file

‎tests/test_readme_python_example.py‎

Copy file name to clipboardExpand all lines: tests/test_readme_python_example.py
+16-14Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pathlib import Path
1111

1212
import pytest
13+
from repo_build_lock import repo_build_lock
1314

1415
ROOT = Path(__file__).resolve().parents[1]
1516
PYTHON_FENCE = re.compile(
@@ -101,20 +102,21 @@ def test_readme_python_example_runs_saves_and_reopens_from_base_wheel(
101102
capture_output=True,
102103
text=True,
103104
)
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+
)
118120
core_wheel = next(dist.glob("python_hwpx-*.whl"))
119121
automation_wheel = next(dist.glob("python_hwpx_automation-*.whl"))
120122
with zipfile.ZipFile(automation_wheel) as archive:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.