witty-crayon-22786
08/29/2022, 5:23 PMPlatform
from a singleton to a param, and then possibly looking into consuming it to construct Process
… will that step on any toes?witty-crayon-22786
08/29/2022, 5:29 PMwitty-crayon-22786
08/29/2022, 5:29 PMsrc/python/pants/jvm/resolve/coursier_setup.py
263: coursier_subsystem.get_request(Platform.current),
witty-crayon-22786
08/29/2022, 5:30 PMwitty-crayon-22786
08/29/2022, 5:36 PMEnvironment
is important, but almost no callsites should actually consume “the entire environment”, or even the environment id: they will almost all consume things derived from the environment. and the Platform
is one of those things (i.e., the environment id gets pushed down to select the environment, and the Platform
is computed from the environment config).witty-crayon-22786
08/29/2022, 5:38 PMPlatform
from singleton to parameter.hundreds-father-404
08/29/2022, 5:39 PMlocal_environment
? Rn, it's global, no per-target settings.
The plan is still that rules will request something like how pex_cli.py
already requests the type PexEnvironment
. That rule will now request which environment to use to populate those env varswitty-crayon-22786
08/29/2022, 5:39 PMProcess
quite yet, because we need to figure out how the platform and docker image interface with that for @fast-nail-55400’s changewitty-crayon-22786
08/29/2022, 5:40 PMThat rule will now request which environment to use to populate those env varssure… temporarily, that makes sense. the Environment (id) should become a global param here: https://github.com/pantsbuild/pants/blob/489b1e2fb1ffee2864cf7dc1308bd2afa4fa2f47/src/python/pants/init/engine_initializer.py#L87-L88
witty-crayon-22786
08/29/2022, 5:43 PMGet
syntax will be used for changing the environment in certain subgraphs, but it will still be a global/default paramwitty-crayon-22786
08/29/2022, 5:44 PMPlatform
changefast-nail-55400
08/29/2022, 5:53 PMPlatform
churn before actually using it.fast-nail-55400
08/29/2022, 5:53 PMdocker
--platform
option.witty-crayon-22786
08/29/2022, 5:54 PMwitty-crayon-22786
08/29/2022, 5:54 PMfast-nail-55400
08/29/2022, 5:55 PMProcess.platform
for the short term and no big deal to migrate to whatever it changes tofast-nail-55400
08/29/2022, 5:55 PMhundreds-father-404
08/29/2022, 7:48 PMlocal_environment
, whereas right now it's only [python-bootstrap]
2. Allow individual targets to change the environment. (requires more design work)
3. introduce docker_environment
target
We may want to have me do #2 and #3 first, as they are more conceptual and blocking imo. Maybe Chris could help with #1witty-crayon-22786
08/29/2022, 8:09 PMwitty-crayon-22786
08/29/2022, 8:12 PMactually (continuing to think out loud): thei’ve begun on thisis important, but almost no callsites should actually consume “the entire environment”, or even the environment id: they will almost all consume things derived from the environment. and theEnvironment
is one of those things (i.e., the environment id gets pushed down to select the environment, and thePlatform
is computed from the environment config).Platform
Platform
change, but it looks like it is going to need to introduce an initial cut at some sort of EnvironmentId or EnvironmentMatcher. needing to do it early is for annoying rule-graph reasons, but i do think that it will be the long term factoring anyway, so maybe that’s a blessing in disguisewitty-crayon-22786
08/29/2022, 8:14 PMwitty-crayon-22786
08/29/2022, 8:15 PMhundreds-father-404
08/29/2022, 8:27 PMpytest_runner.py
are going to need to ask for the environment for a particular target, i.e. give inputwitty-crayon-22786
08/29/2022, 8:28 PMRight now, to determine the environment is easy because it’s global. Soon, I think the consumers likethat’s what my current change begins to doare going to need to ask for the environment for a particular target, i.e. give inputpytest_runner.py
witty-crayon-22786
08/29/2022, 8:28 PMPlatform
change” commentwitty-crayon-22786
08/29/2022, 8:30 PMEnvironmentMatcher
contains. basically, a root target like python_tests
is going to have a Field which can be converted into an EnvironmentMatcher
witty-crayon-22786
08/29/2022, 8:30 PMEnvironmentMatcher
that matches the local environment (which i need to introduce currently)witty-crayon-22786
08/29/2022, 8:32 PMwitty-crayon-22786
08/29/2022, 8:36 PMpants.engine.environment.Environment
for env vars)hundreds-father-404
08/29/2022, 8:38 PM(relatedly: I'm regretting having gone with the shorter name and reserving pants.engine.environment.Environment for env varsIt's annoying to change the Plugin API, but I think we can consider it. Much less stable than user API
witty-crayon-22786
08/29/2022, 8:39 PMEnvironmentMatcher
in that module, and then we can deprecate/move Environment
, etc later if things work out.witty-crayon-22786
08/29/2022, 8:40 PMhundreds-father-404
08/29/2022, 8:44 PMpython_bootstrap.py
and the rule to return PythonBootstrap
. That impacts a lot, including any PEX that gets built. If one target uses env1, and other uses env2, then we need to build pytest.pex
twice I think. I'm not totally clear on how we will pass the target down into python_bootstrap.py
witty-crayon-22786
08/29/2022, 8:45 PMwitty-crayon-22786
08/29/2022, 8:46 PMsrc/python/pants/init/engine_initializer.py
in there, imagine that rather than a Platform
at the root, there is an EnvironmentMatcher
at the rootwitty-crayon-22786
08/29/2022, 8:47 PMawait Get(TestResult, {field_set: TestFieldSet, env_matcher: EnvironmentMatcher})
…to change it in the subgraph.witty-crayon-22786
08/29/2022, 8:48 PM