Skip to content

BUG Update initialise_virtualenv.py to use uv sync#44096

Merged
potiuk merged 2 commits into
apache:mainfrom
SuccessMoses:fix-init-venv
Nov 17, 2024
Merged

BUG Update initialise_virtualenv.py to use uv sync#44096
potiuk merged 2 commits into
apache:mainfrom
SuccessMoses:fix-init-venv

Conversation

@SuccessMoses
Copy link
Copy Markdown
Contributor

closes: #44078

uv is the recommended tool for installing airflow and other dependecies. I updated the ./scripts/tool/initialise_virtualenv.py file to use uv sync instead of pip unstall

@SuccessMoses
Copy link
Copy Markdown
Contributor Author

SuccessMoses commented Nov 16, 2024

even with this changes there is still a bug:

airflow version

Observation:

airflow) success@success-HP-Laptop-14-cf3xxx:~/Desktop/airflow$ airflow version
Traceback (most recent call last):
  File "/home/success/Desktop/airflow/.venv/bin/airflow", line 5, in <module>
    from airflow.__main__ import main
  File "/home/success/Desktop/airflow/airflow/__init__.py", line 78, in <module>
    settings.initialize()
  File "/home/success/Desktop/airflow/airflow/settings.py", line 787, in initialize
    configure_orm()
  File "/home/success/Desktop/airflow/airflow/settings.py", line 494, in configure_orm
    async_engine = create_async_engine(SQL_ALCHEMY_CONN_ASYNC, future=True)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/success/Desktop/airflow/.venv/lib/python3.12/site-packages/sqlalchemy/ext/asyncio/engine.py", line 43, in create_async_engine
    sync_engine = _create_engine(*arg, **kw)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 2, in create_engine
  File "/home/success/Desktop/airflow/.venv/lib/python3.12/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/success/Desktop/airflow/.venv/lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 544, in create_engine
    dbapi = dialect_cls.dbapi(**dbapi_args)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/success/Desktop/airflow/.venv/lib/python3.12/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 321, in dbapi
    __import__("aiosqlite"), __import__("sqlite3")

@potiuk
Copy link
Copy Markdown
Member

potiuk commented Nov 16, 2024

If we use uv to create venv. You should either activate it with sourcing . ./.venv/bin/activatefirst or using uv run to run the command in the venv you just created (the venv is created in projects's root .venv sub-folder.

Might be worth to describe this behaviour and where the venv is created in the docs which refer to this script.

@SuccessMoses
Copy link
Copy Markdown
Contributor Author

Should I add aiosqlite to dependencies in ./pyproject.toml

@potiuk
Copy link
Copy Markdown
Member

potiuk commented Nov 17, 2024

No - it's already added by "hatch_build.py" via sqlite dependency. What you needed to do (see the fixup I added) - is to run the airflow commands via "uv run" command.

@potiuk potiuk merged commit 987c50a into apache:main Nov 17, 2024
kandharvishnu pushed a commit to kandharvishnu/airflow that referenced this pull request Nov 19, 2024
* Update initialse_virtualenv.py to use uv sync

* fixup! Update initialse_virtualenv.py to use uv sync

---------

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG ./scripts/tools/initialize_virtualenv.py

2 participants