Skip to content

♻️ refactor: rewrite with standalone python_discovery from virtualenv#28

Merged
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:rewrite
Feb 25, 2026
Merged

♻️ refactor: rewrite with standalone python_discovery from virtualenv#28
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:rewrite

Conversation

@gaborbernat
Copy link
Member

@gaborbernat gaborbernat commented Feb 24, 2026

The python_discovery package was extracted from virtualenv as a self-contained module with zero virtualenv imports and relative-only internal imports. This rewrites the standalone tox-dev/py-discovery repo to use that extracted code, replacing the old implementation entirely.

The package now ships as python-discovery (import name python_discovery) with full support for Python 3.8 through 3.14. It includes interpreter discovery via PATH and PEP 514 (Windows registry), a DiskCache for subprocess-based PythonInfo resolution, and PythonSpec parsing with architecture, machine ISA, and free-threading support. Runtime features like @dataclass(kw_only=True, slots=True) are conditionally enabled on Python 3.10+ while maintaining compatibility with older versions.

Project tooling follows the pytest-env pattern: hatchling + hatch-vcs build, tox-uv test runner, ruff linting with ALL rules, ty type checking across 3.8 and 3.14, and 100% branch coverage enforced via covdefaults. Documentation uses the Diataxis layout with furo theme on ReadTheDocs.

@gaborbernat gaborbernat marked this pull request as draft February 24, 2026 14:27
@gaborbernat gaborbernat changed the title Rewrite with standalone py_discovery from virtualenv ✨ feat: rewrite as standalone package from virtualenv Feb 24, 2026
@gaborbernat gaborbernat marked this pull request as ready for review February 24, 2026 17:16
@gaborbernat gaborbernat force-pushed the rewrite branch 5 times, most recently from cbb3365 to b59b295 Compare February 25, 2026 16:33
@gaborbernat gaborbernat enabled auto-merge (squash) February 25, 2026 16:38
@gaborbernat gaborbernat disabled auto-merge February 25, 2026 16:41
The original py-discovery package was a thin stub. This replaces it with
the battle-tested interpreter discovery engine extracted from virtualenv,
renamed from py_discovery to python_discovery.

The rewrite brings a complete implementation: spec-based interpreter
matching, filesystem and registry discovery, caching with file locks,
PEP 514 Windows support, version specifiers, and version manager shim
resolution (pyenv/mise/asdf). Full type annotations target Python 3.8+
with ty verification against both 3.8 and 3.14. Documentation follows
Diataxis structure with tutorial, how-to, explanation, and API reference.
@gaborbernat gaborbernat merged commit 1696086 into tox-dev:main Feb 25, 2026
12 checks passed
@gaborbernat gaborbernat changed the title ✨ feat: rewrite as standalone package from virtualenv ♻️ refactor: rewrite with standalone python_discovery from virtualenv Feb 25, 2026
@gaborbernat gaborbernat added the enhancement New feature or request label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant