♻️ refactor: rewrite with standalone python_discovery from virtualenv#28
Merged
Conversation
gaborbernat
marked this pull request as draft
February 24, 2026 14:27
gaborbernat
marked this pull request as ready for review
February 24, 2026 17:16
gaborbernat
force-pushed
the
rewrite
branch
5 times, most recently
from
February 25, 2026 16:33
cbb3365 to
b59b295
Compare
gaborbernat
enabled auto-merge (squash)
February 25, 2026 16:38
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
added a commit
that referenced
this pull request
Jul 3, 2026
Installing python-discovery from source on Python 3.8 or 3.9 fails at the build step with `No matching distribution found for hatchling>=1.28`, reported in #92. The build pin `hatchling>=1.28` requires Python `>=3.10`, yet the project declares `requires-python = ">=3.8"` and tests against 3.8/3.9, so pip cannot find a backend when it builds the sdist on those interpreters. Nothing needs that specific floor; it landed during the standalone rewrite in #28. An environment marker splits the requirement so interpreters below 3.10 pull `hatchling>=1.27`, the last release supporting `<3.10`, while 3.10 and newer keep `hatchling>=1.28`. Published wheels ship prebuilt and skip the backend, so they stay unchanged. This restores source builds on the older interpreters the package already supports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
python_discoverypackage was extracted from virtualenv as a self-contained module with zero virtualenv imports and relative-only internal imports. This rewrites the standalonetox-dev/py-discoveryrepo to use that extracted code, replacing the old implementation entirely.The package now ships as
python-discovery(import namepython_discovery) with full support for Python 3.8 through 3.14. It includes interpreter discovery via PATH and PEP 514 (Windows registry), aDiskCachefor subprocess-basedPythonInforesolution, andPythonSpecparsing 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-envpattern:hatchling+hatch-vcsbuild,tox-uvtest runner,rufflinting withALLrules,tytype checking across 3.8 and 3.14, and 100% branch coverage enforced viacovdefaults. Documentation uses the Diataxis layout withfurotheme on ReadTheDocs.