-
-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python import parser does not support subprocess_environment or some other way to leak env vars. #16565
Comments
The more interesting thing here @stuhood is that a data dependency (on a binary) has an implicit data dependency on the env vars (or at least 1 of them, |
Yea, this is tricky. It's definitely not implicit that if Process 1 has consumed something from an environment variable, that Process 2 downstream will also need to consume it.
The tack that I have been trying to encourage for the "options which declare environment variables which need to be leaked" pattern is to attempt to make them use-case or tool specific: "all subprocesses" is just too broad. This ticket represents a really good example of that I think: in this case, the tool that requires a leaked environment variable is the Python interpreter. So as a strawimpl, you could imagine having And this relates to #12203 as well. Similar to a
|
The original problem (with python import parsing) might be obsoleted by the new Rust-based parser #18854, once that fully replaces the Python-based one. Once that's the case, the docs in #18900 referencing this issue could probably be removed too. That does nothing for the broader problem of propagating env var dependencies, of course. |
Would it perhaps make sense to also capture which env vars to leak in the pants/src/python/pants/core/util_rules/system_binaries.py Lines 46 to 48 in a4436e3
If the request indicates which env vars are potentially relevant, those could be leaked into the result if defined. Then a call site requesting a search for a Python binary could include |
I think, for this case, what the root problem is is that plugin authors can ask for a Python executable, and in most (every?) case they shouldn't be using it. |
FYI I just fixed this for Django dep inference as well: #19008 |
The code has never used a
PexProcess
orVenvPexProcess
or manually plumbedSubprocessEnvironment
or else its own bespoke env var leaking option:pants/src/python/pants/backend/python/dependency_inference/parse_python_dependencies.py
Lines 88 to 106 in 37bf607
This results in situations where other Pants rules can use a given Python interpreter but the dependency inference rules cannot when those other rules have the benefit of
--subprocess-environment-env-vars='+["LD_LIBRARY_PATH"]'
- for example. This particular example comes up when trying to use GH actions provided Pythons where they are not statically linked Python and use a .so and that .so is not in the default linker cache / linker search path.The text was updated successfully, but these errors were encountered: