uranusjr commented on a change in pull request #19189:
URL: https://github.com/apache/airflow/pull/19189#discussion_r738890702
##########
File path: airflow/utils/python_virtualenv.py
##########
@@ -27,13 +28,22 @@
from airflow.utils.process_utils import execute_in_subprocess
-def _generate_virtualenv_cmd(tmp_dir: str, python_bin: str,
system_site_packages: bool) -> List[str]:
- cmd = [sys.executable, '-m', 'virtualenv', tmp_dir]
- if system_site_packages:
- cmd.append('--system-site-packages')
- if python_bin is not None:
- cmd.append(f'--python={python_bin}')
- return cmd
+def _generate_virtualenv_cmd(
+ tmp_dir: str, python_bin: str, system_site_packages: bool,
clone_virtualenv_packages: bool
+) -> List[str]:
+ if clone_virtualenv_packages and sys.prefix != sys.base_prefix and not
python_bin:
+ # Create virtualenv using virtualenv-clone command if we are in
virtualenv and
+ # clone_virtualenv_packages is set and we are using same version of
python
+ # as our virtualenv
+ cmd = ['virtualenv-clone', f'{sys.prefix}', tmp_dir]
+ return cmd
Review comment:
There is a flag for this in the virtual environment configuration file.
The part I'm not sure about is whether `virtualenv-clone` copies the
configuration correctly or not, we need to check. If not, we need to flip that
configuration manually.
https://www.python.org/dev/peps/pep-0405/#isolation-from-system-site-packages
--
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]