Is there a way to detect that this is running with...
# general
Is there a way to detect that this is running with pants? So I can flag in resource loading logic conditionally. Specifically python logic.
When we were migrating to pants, we handled potentially-similar situations (e.g. the way we initialised a database within tests was slightly different when running within pants vs. the old style of running with poetry) by doing both: first try the pants way, and if it fails (in the expected way), try the old way. Alternatively, you might be able to set a
variable within I'm just guessing at what you're doing, though. What type of logic are you having to conditiionalise? Deciding when to use
Essentially yes.
Currently a bunch of http sources are pulled onto a host to the users home dir for a "cache" it's clunky, but underpins a bunch of thing. So preserving that for the transition would be critical.
Can we set subprocess environment variables in the pants.toml?
yeah, all options can be set via env vars, via CLI options and via pants.toml. For the pages like the one linked above "Config section" says the heading (
in this case), and the bold heading for each option says the config key (
). So, for that one, it'd be something like:
Copy code
env_vars = ["RUNNING_WITHIN_PANTS=1"]
Ah - not _ 😃