phi-friday commented on code in PR #41039:
URL: https://github.com/apache/airflow/pull/41039#discussion_r1708236351


##########
airflow/utils/python_virtualenv_script.jinja2:
##########
@@ -64,6 +64,20 @@ with open(sys.argv[3], "r") as file:
     virtualenv_string_args = list(map(lambda x: x.strip(), list(file)))
 {% endif %}
 
+{% if use_airflow_context | default(false) -%}
+if len(sys.argv) > 5:
+    import json
+    from types import ModuleType
+
+    class _MockPython(ModuleType):
+        @staticmethod
+        def get_current_context():
+            with open(sys.argv[5]) as file:
+                return json.load(file)

Review Comment:
   I used `json` to make it usable in environments without `airflow`.
   Would I change it to use `BaseSerialization` if the user has `airflow`, and 
`json` if not?
   
   However, in that situation, it might be a good idea to set 
`system_site_packages` to `True`.
   (I've never used `system_site_packages` before, so I may be misunderstanding 
it.)
   
   This seems to be a difficult decision for me.
   What do you think I should do?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to