1"""All non private names (no leading underscore) here are part of the tox API.
2
3They live in the tox namespace and can be accessed as tox.[NAMESPACE.]NAME
4"""
5import os
6import re
7import sys
8
9_THIS_FILE = os.path.realpath(os.path.abspath(__file__))
10
11
12def _construct_default_factors(cpython_versions, pypy_versions, other_interpreters):
13    default_factors = {"py": sys.executable, "py2": "python2", "py3": "python3"}
14    default_factors.update(
15        {
16            "py{}{}".format(major, minor): "python{}.{}".format(major, minor)
17            for major, minor in cpython_versions
18        }
19    )
20    default_factors.update({exc: exc for exc in ["pypy", "pypy2", "pypy3"]})
21    default_factors.update(
22        {
23            "pypy{}{}".format(major, minor): "pypy{}.{}".format(major, minor)
24            for major, minor in pypy_versions
25        }
26    )
27    default_factors.update({interpreter: interpreter for interpreter in other_interpreters})
28    return default_factors
29
30
31class PYTHON:
32    PY_FACTORS_RE = re.compile("^(?!py$)(py|pypy|jython)([2-9][0-9]?)?$")
33    CPYTHON_VERSION_TUPLES = [(2, 7), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)]
34    PYPY_VERSION_TUPLES = [(2, 7), (3, 5)]
35    OTHER_PYTHON_INTERPRETERS = ["jython"]
36    DEFAULT_FACTORS = _construct_default_factors(
37        CPYTHON_VERSION_TUPLES, PYPY_VERSION_TUPLES, OTHER_PYTHON_INTERPRETERS
38    )
39    CURRENT_RELEASE_ENV = "py36"
40    """Should hold currently released py -> for easy updating"""
41    QUICKSTART_PY_ENVS = ["py27", "py34", "py35", CURRENT_RELEASE_ENV, "pypy", "jython"]
42    """For choices in tox-quickstart"""
43
44
45class INFO:
46    DEFAULT_CONFIG_NAME = "tox.ini"
47    CONFIG_CANDIDATES = ("pyproject.toml", "tox.ini", "setup.cfg")
48    IS_WIN = sys.platform == "win32"
49    IS_PYPY = hasattr(sys, "pypy_version_info")
50
51
52class PIP:
53    SHORT_OPTIONS = ["c", "e", "r", "b", "t", "d"]
54    LONG_OPTIONS = [
55        "build",
56        "cache-dir",
57        "client-cert",
58        "constraint",
59        "download",
60        "editable",
61        "exists-action",
62        "extra-index-url",
63        "global-option",
64        "find-links",
65        "index-url",
66        "install-options",
67        "prefix",
68        "proxy",
69        "no-binary",
70        "only-binary",
71        "requirement",
72        "retries",
73        "root",
74        "src",
75        "target",
76        "timeout",
77        "trusted-host",
78        "upgrade-strategy",
79    ]
80    INSTALL_SHORT_OPTIONS_ARGUMENT = ["-{}".format(option) for option in SHORT_OPTIONS]
81    INSTALL_LONG_OPTIONS_ARGUMENT = ["--{}".format(option) for option in LONG_OPTIONS]
82
83
84_HELP_DIR = os.path.join(os.path.dirname(_THIS_FILE), "helper")
85VERSION_QUERY_SCRIPT = os.path.join(_HELP_DIR, "get_version.py")
86SITE_PACKAGE_QUERY_SCRIPT = os.path.join(_HELP_DIR, "get_site_package_dir.py")
87BUILD_REQUIRE_SCRIPT = os.path.join(_HELP_DIR, "build_requires.py")
88BUILD_ISOLATED = os.path.join(_HELP_DIR, "build_isolated.py")
89PARALLEL_RESULT_JSON_PREFIX = ".tox-result"
90PARALLEL_RESULT_JSON_SUFFIX = ".json"
91