potiuk commented on PR #37796:
URL: https://github.com/apache/airflow/pull/37796#issuecomment-1971240313

   Aftere a looong time I've finally found a way how to get rid of the `--user` 
flag for PROD airflow lmage and keep backwards compatibility. I attempted it 
already in the past https://github.com/apache/airflow/pull/19189 (loong time 
ago( and could not find a good way to keep compatibility. Mainly it was about 
`python -m venv --system-site-packages` creting venv dynamically with 
preinstalled airflow and all its dependencies. This was not working well when 
airflow was **just** a virtualenv.
   
   But now I revised it  - in order to bring `uv` on board for production image 
(`uv` does not support `--user` flag) and I found out that simply recreating a 
`~/.local` directory as venv, adding `~/.local/bin` to the  PATH and setting 
`VIRTUAL_ENV` variable pointing to `~/.local/` does the job well. It has all 
the properties we need:
   
   * nicely installs all packages locally without the need to have root access
   * allows to create new venvs: empty (default) or with installed airflow 
(when `--system-site-packages` are used)
   * works with `uv` out-of-the-box (thoug `uv venv` acts a little differently 
than `python -m venv` because `uv` still does not consider  --user / .local 
directories as `special` 
   * allows to build our images with `uv` which brings 40% - 55% percent 
improvements in build times.
   
   The request to add `--user` flag to `--uv` is in 
https://github.com/astral-sh/uv/issues/2077 - but we do not need it any more to 
handle that case.
   


-- 
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