File: index.rst

package info (click to toggle)
python-discovery 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 492 kB
  • sloc: python: 4,511; makefile: 9; sh: 8
file content (49 lines) | stat: -rw-r--r-- 1,349 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
python-discovery
================

You may have multiple Python versions installed on your machine -- system Python, versions from
`pyenv <https://github.com/pyenv/pyenv>`_, `mise <https://mise.jdx.dev/>`_,
`asdf <https://asdf-vm.com/>`_, `uv <https://docs.astral.sh/uv/>`_, or the Windows registry
(:pep:`514`). ``python-discovery`` finds the right one for you.

Give it a requirement like ``python3.12`` or ``>=3.11,<3.13``, and it searches all known locations,
verifies each candidate, and returns detailed metadata about the match. Results are cached to disk so
repeated lookups are fast.

.. code-block:: python

   from pathlib import Path

   from python_discovery import DiskCache, get_interpreter

   cache = DiskCache(root=Path("~/.cache/python-discovery").expanduser())
   result = get_interpreter("python3.12", cache=cache)
   if result is not None:
       print(result.executable)       # /usr/bin/python3.12
       print(result.implementation)   # CPython
       print(result.version_info[:3]) # (3, 12, 1)

.. toctree::
   :caption: Tutorials
   :hidden:

   tutorial/getting-started

.. toctree::
   :caption: How-to Guides
   :hidden:

   how-to/standalone-usage

.. toctree::
   :caption: Reference
   :hidden:

   reference/api
   reference/environment-variables

.. toctree::
   :caption: Explanation
   :hidden:

   explanation