- ruff profile in pyproject (E/W/F/I/B/RUF); clean src/ + tests/ - remove dead code: threaded_len/s/d/coat/first_rec_for_size, self.cat in gui - 59 public re-exports added to __all__ (sorted) - renamed l->ln (E741), zip(strict=True), split long lines, [*list, x] (RUF005) - CI: quality job (ruff), test runs tests/ -k 'not gen_all' w/ coverage - README rewritten (commands, API modules, tests/lint/coverage, CI) - docs/tasks.md: P4 recorded - 136 passed, 3 deselected (regen); ruff: all checks passed
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
"""Packaging sanity: pyproject.toml is parseable and declares expected metadata.
|
|
|
|
Verifies the metadata we rely on (name, version, console-script entry points)
|
|
is well-formed, so `pip install .` + `fastengen` CLI work. Runs without network
|
|
or install; reads the toml file directly (Python 3.11+ tomllib) or a minimal
|
|
fallback parser for 3.10.
|
|
|
|
No em-dash in code: Python 3.10 source lacks UTF-8 mode (no PEP 540).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
|
|
try:
|
|
import tomllib # Python 3.11+
|
|
def _load_toml(path: str) -> dict:
|
|
with open(path, "rb") as f:
|
|
return tomllib.load(f)
|
|
except ModuleNotFoundError: # Python 3.10
|
|
tomllib = None
|
|
|
|
def _load_toml(path: str) -> dict:
|
|
# Minimal parser for the flat pyproject we own: name/version/deps/scripts.
|
|
# Sufficient to assert presence of the keys we depend on.
|
|
# configparser can't parse TOML; fall back to simple key scanning.
|
|
text = open(path, encoding="utf-8").read()
|
|
def _field(name):
|
|
import re
|
|
m = re.search(name + r'\s*=\s*"([^"]+)"', text)
|
|
return m.group(1) if m else None
|
|
return {
|
|
"name": _field("name"),
|
|
"version": _field("version"),
|
|
"scripts_present": "fastengen" in text,
|
|
}
|
|
|
|
|
|
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
def _pyproject():
|
|
return _load_toml(os.path.join(PROJECT_ROOT, "pyproject.toml"))
|
|
|
|
|
|
def test_pyproject_has_name_and_version():
|
|
cfg = _pyproject()
|
|
# tomllib result has [project] table; minimal fallback has top-level keys.
|
|
if tomllib is not None:
|
|
assert cfg["project"]["name"]
|
|
assert cfg["project"]["version"]
|
|
assert "cadquery" in cfg["project"]["dependencies"]
|
|
assert "fastengen" in cfg["project"]["scripts"]
|
|
else:
|
|
assert cfg["name"] == "FastenGen"
|
|
assert cfg["version"]
|
|
assert cfg["scripts_present"]
|