Skip to content

fix(python): a node's strip_tags and unwrap_tags skipped the node - #132

Merged
jamesconwaydev merged 2 commits into
mainfrom
python-fixes
Nov 20, 2026
Merged

jamesconwaydev merged 2 commits into
mainfrom
python-fixes

Conversation

@jamesconwaydev

Copy link
Copy Markdown
Collaborator

Problem

  • Missing wheels. 0.1.0 had no CPython 3.14 or 3.15 wheels with the GIL on macOS or Windows. On macOS, maturin's --find-interpreter goes by the names on PATH, and the free-threaded installer's python3.14 and python3.15 shadow the ordinary ones, so the free-threaded wheels were built twice and the GIL ones never. Windows lost the same two. The job passed anyway.
  • No licence files. The wheels and the sdist carried no LICENSE or NOTICE.
  • strip_tags and unwrap_tags on a node looked only inside it. selectolax counts the node itself among the matches, and css() on a node here does too.
  • Docs that didn't match behaviour. They said decompose() refuses the root as selectolax does. In fact Parsec refuses only the document node, while selectolax also refuses root, the <html> element. line_col() counts UTF-8 bytes when neither positions nor errors is on, which wasn't said. XPath numbers become strings differently from lxml, also unsaid. HTMLParser and Node had no docstrings, and the README's list of missing selectolax names was short.

Change

  • scripts/find-pythons.py asks each CPython that setup-python installed what version it is and whether the GIL is off, and maturin gets those paths on macOS and Windows. Linux keeps the manylinux images' names. A new step fails the job unless dist/ holds exactly one wheel per expected version, plus the abi3t one.
  • LICENSE and NOTICE copies sit beside pyproject.toml, which names them in license-files, and the python lint job checks they match the repository's. pyproject.toml also gains a classifier for each Python version and one for CPython.
  • strip_tags and unwrap_tags include the node when it's an element that matches.
  • Docstrings, the stub and the README say what decompose() refuses and how line_col() counts. The README says how XPath numbers become strings next to lxml's: Parsec keeps XPath 1.0's rule and doesn't copy libxml2's 15-digit rounding. The missing-names list is complete.

Tests

  • pytest: a node's strip_tags and unwrap_tags take the node when it matches, and only the inside when it doesn't; root.decompose() works and the document node raises; XPath numbers as strings; the installed wheel lists LICENSE and NOTICE. 42 passed, 1 skipped (the free-threaded-only test) on CPython 3.14, built with maturin into a fresh venv.

  • maturin sdist holds both files at the top and in bindings/python.

  • A workflow_dispatch run of release-python.yml on this branch, run 44786280589, succeeded. Its artifacts:

    • macOS arm64 and x86-64, Windows x64, manylinux and musllinux on x86-64 and aarch64: 10 wheels each, cp39 to cp315, cp314t, cp315t and cp315-abi3.abi3t.
    • Windows arm64: 8 wheels, cp311 to cp315, cp314t, cp315t and abi3t.
    • The sdist.

    On macOS arm64 the step picked hostedtoolcache/Python/3.14.10/arm64/bin/python3 for 3.14 and …/arm64-freethreaded/bin/python3 for 3.14t, and the same for 3.15. The Windows wheels carry LICENSE and NOTICE under .dist-info/licenses/.

  • cargo clippy -- -D warnings and cargo fmt --check on the binding, and actionlint on both workflows.

maturin's --find-interpreter goes by the names on PATH, and on macOS
the free-threaded installer's python3.14 and python3.15 shadow the
ordinary ones, so 0.1.0 built 3.14t and 3.15t twice and the GIL builds
never; Windows lost the same two. The job still passed.

scripts/find-pythons.py now asks each installed CPython what version
it is and whether the GIL is off, and maturin is given those paths.
After the build, the job fails unless dist/ holds exactly one wheel for
each version it should, the abi3t one included.
selectolax counts the node itself among the matches, and css() on a
node here does too; strip_tags and unwrap_tags looked only inside it.

The wheels and the sdist carried no LICENSE or NOTICE. Copies now sit
beside pyproject.toml, named in license-files, and CI checks they match
the repository's. PyPI also gets a classifier per Python version.

The docs said decompose() refuses the root as selectolax does. It
refuses the document node; root, the <html> element, can be
decomposed, which selectolax refuses. The docs now say so, and say
that line_col() counts UTF-8 bytes when neither positions nor errors
is on, and how XPath numbers become strings differently from lxml.
HTMLParser and Node have docstrings.

@foothillsdigital foothillsdigital left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked d70d894:

  • strip_tags and unwrap_tags: matches_of passing true takes in the scope when it's an element that matches. They still gather every match before changing any, so decomposing the node itself mid-loop can't happen. The new test covers the node matching, the node unwrapped, and the node only a scope.
  • Licence files: bindings/python/LICENSE and NOTICE are byte-identical to the root's (cmp), python.yml now checks that, and test_wheel_carries_the_licence_and_notice checks the built wheel.
  • find-pythons.py: asking each interpreter for version_info and Py_GIL_DISABLED is the right fix for the shadowed python3.14. A missing version exits 1 with what it found, so a release job fails rather than going out short. The new "Every wheel is there" step also checks each cpXY-cpXY and cpXYt tag and the exact count, with abi3t as one more.
  • The docstrings and README now say where decompose, line_col and XPath number formatting differ from selectolax and lxml.
  • CI: the Python tests pass on 3.9 to 3.15t, free-threaded included, on Linux, macOS and Windows. All 33 checks pass.

One thing CI here can't show: release-python.yml's new interpreter discovery only runs on a tag or by hand. Its workflow_dispatch builds without publishing, so one dispatch on main after this merges would show the macOS and Windows jobs finding all nine interpreters (seven on Windows ARM) before 0.1.1 is tagged. That matters most on Windows, where I'm not sure every free-threaded tool-cache folder has a python.exe rather than only python3.14t.exe. If one doesn't, the script will say so.

Approving.

@jamesconwaydev
jamesconwaydev added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit d2323e0 Nov 20, 2026
43 checks passed
@jamesconwaydev
jamesconwaydev deleted the python-fixes branch November 20, 2026 19:02
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.

2 participants