Skip to content

Commit 6bbe940

Browse files
authored
📝 docs: add package description and usage to README (#46)
1 parent c4ec5ca commit 6bbe940

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,43 @@
11
# [`python-discovery`](https://python-discovery.readthedocs.io/en/latest/)
22

33
[![PyPI](https://img.shields.io/pypi/v/python-discovery?style=flat-square)](https://pypi.org/project/python-discovery/)
4-
[![Supported Python
5-
versions](https://img.shields.io/pypi/pyversions/python-discovery.svg)](https://pypi.org/project/python-discovery/)
4+
[![Supported Python versions](https://img.shields.io/pypi/pyversions/python-discovery.svg)](https://pypi.org/project/python-discovery/)
65
[![Downloads](https://static.pepy.tech/badge/python-discovery/month)](https://pepy.tech/project/python-discovery)
76
[![check](https://github.com/tox-dev/python-discovery/actions/workflows/check.yaml/badge.svg)](https://github.com/tox-dev/python-discovery/actions/workflows/check.yaml)
87
[![Documentation Status](https://readthedocs.org/projects/python-discovery/badge/?version=latest)](https://python-discovery.readthedocs.io/en/latest/?badge=latest)
8+
9+
## What is python-discovery?
10+
11+
`python-discovery` is a library for discovering Python interpreters installed on your machine. You may have multiple
12+
Python versions from system packages, [pyenv](https://github.com/pyenv/pyenv), [mise](https://mise.jdx.dev/),
13+
[asdf](https://asdf-vm.com/), [uv](https://docs.astral.sh/uv/), or the Windows registry (PEP 514). This library finds
14+
the right one for you.
15+
16+
Give it a requirement like `python3.12` or `>=3.11,<3.13`, and it searches all known locations, verifies each candidate,
17+
and returns detailed metadata about the match. Results are cached to disk so repeated lookups are fast.
18+
19+
## Usage
20+
21+
```python
22+
from pathlib import Path
23+
24+
from python_discovery import DiskCache, get_interpreter
25+
26+
cache = DiskCache(root=Path("~/.cache/python-discovery").expanduser())
27+
result = get_interpreter("python3.12", cache=cache)
28+
if result is not None:
29+
print(result.executable) # /usr/bin/python3.12
30+
print(result.implementation) # CPython
31+
print(result.version_info[:3]) # (3, 12, 1)
32+
```
33+
34+
The `get_interpreter()` function accepts various specification formats:
35+
36+
- Absolute path: `/usr/bin/python3.12`
37+
- Version: `3.12`
38+
- Implementation prefix: `cpython3.12`
39+
- PEP 440 specifier: `>=3.10`, `>=3.11,<3.13`
40+
41+
## Documentation
42+
43+
Full documentation is available at [python-discovery.readthedocs.io](https://python-discovery.readthedocs.io/en/latest/)

0 commit comments

Comments
 (0)