-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
core operator python: check virtualenv is importable by importing #43403
Conversation
This imports the module to check for `ModuleNotFoundError`. A soft import is possible but then we importlib anyway and this will be most robust.
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
Actually - this is not correct/complete - is really a breaking change. So far PythonVirtualenv operator used Note that virtualenv is stil maintained till today, even if venv became available This is mostly due to historical reasons, but also because I do not think we are bound to any specifics of So while I sympathise with the change - since Also this change is plainly wrong - creating virtualenv currently actually uses "virtualenv" command line not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes until the actual scope of the change and whether we want to change from virtualenv to venv (and it should be complete change if we do).
Thanks for taking a look, I, for some reason though venv and virtualenv were the same. As you say this would be breaking. https://peps.python.org/pep-0405/ - is relevant for any future readers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better (and I do recognise a need of synchronizing the check with the venv creation command), but not necessary ideal.
The actual virtualenv creation happens by
cmd = [sys.executable, "-m", "virtualenv", tmp_dir]
While the check for importing virtualenv is good and "sys.executable" should generally provide good results, but I can imagine some cases where your PYTHONPATH is modified after running the interpreter where it can still provide different results.
Maybe a better check will be checking if that works:
python -m virtualenv --version
which means runing this:
cmd = [sys.executable, "-m", "virtualenv", "--help"]
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved accidentally
Switching to venv in #43568 - closing that one |
This imports the module to check for
ModuleNotFoundError
. A soft import is possible but then will then import it later anyway and this will be most robust. This change is needed as a systemvirtualenv
is not always available in a venv that airflow is not running in.Closes #40420