MCPcopy
hub / github.com/tox-dev/tox / provision

Function provision

src/tox/provision.py:57–133  ·  view source on GitHub ↗
(state: State)

Source from the content-addressed store, hash-verified

55
56
57def provision(state: State) -> int | bool:
58 # remove the dev and marker to allow local development of the package
59 state.conf.core.add_config(
60 keys=["min_version", "minversion"],
61 of_type=Version,
62 # do not include local version specifier (because it's not allowed in version spec per PEP-440)
63 default=None, # Optional[Version] translates to object
64 desc="Define the minimal tox version required to run",
65 )
66 state.conf.core.add_config(
67 keys="provision_tox_env",
68 of_type=str,
69 default=".tox",
70 desc="Name of the virtual environment used to provision a tox.",
71 )
72
73 def add_tox_requires_min_version(reqs: list[Requirement]) -> list[Requirement]:
74 min_version: Version = state.conf.core["min_version"]
75 reqs.append(Requirement(f"tox{f'>={min_version}' if min_version else ''}"))
76 return reqs
77
78 state.conf.core.add_config(
79 keys="requires",
80 of_type=list[Requirement],
81 default=[],
82 desc="Name of the virtual environment used to provision a tox.",
83 post_process=add_tox_requires_min_version,
84 )
85
86 from tox.plugin.manager import MANAGER # noqa: PLC0415
87
88 MANAGER.tox_add_core_config(state.conf.core, state)
89
90 requires: list[Requirement] = state.conf.core["requires"]
91 missing = _get_missing(requires)
92
93 deps = ", ".join(f"{p}{'' if v is None else f' ({v})'}" for p, v in missing)
94 loader = MemoryLoader( # these configuration values are loaded from in-memory always (no file conf)
95 base=[], # disable inheritance for provision environments
96 package="skip", # no packaging for this please
97 # use our own dependency specification
98 deps=PythonDeps(requires, root=state.conf.core["tox_root"]),
99 pass_env=["*"], # do not filter environment variables, will be handled by provisioned tox
100 recreate=state.conf.options.recreate and not state.conf.options.no_recreate_provision,
101 )
102 provision_tox_env: str = state.conf.core["provision_tox_env"]
103 state.conf.memory_seed_loaders[provision_tox_env].append(loader)
104 state.envs._mark_provision(bool(missing), provision_tox_env) # noqa: SLF001
105
106 if not missing:
107 if remainder := getattr(state.conf.options, "remainder", []):
108 msg = (
109 f"unrecognized arguments: {' '.join(remainder)}\n"
110 "hint: if you tried to pass arguments to a command use -- to separate them from tox ones"
111 )
112 raise HandledError(msg)
113 return False
114

Callers 1

mainFunction · 0.90

Calls 9

MemoryLoaderClass · 0.90
PythonDepsClass · 0.90
HandledErrorClass · 0.90
_get_missingFunction · 0.85
run_provisionFunction · 0.85
add_configMethod · 0.80
tox_add_core_configMethod · 0.80
joinMethod · 0.80
_mark_provisionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…