From 5e026e4b2765f1d21218060762039ad5e0949807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Brand=C3=A9ho?= Date: Thu, 12 Dec 2024 00:10:51 -0800 Subject: [PATCH] Support python 3.13 (#4206) * bump playwright and run tests with 3.13 * test with psycopg3 * typo * update everything for psycopg 3. --- .../workflows/check_outdated_dependencies.yml | 2 +- .github/workflows/integration_app_harness.yml | 4 ++-- .github/workflows/integration_tests.yml | 8 ++++---- .github/workflows/unit_tests.yml | 4 ++-- .../production-app-platform/Dockerfile | 2 +- docker-example/production-compose/Dockerfile | 2 +- .../production-compose/compose.prod.yaml | 2 +- poetry.lock | 16 ++++++++-------- reflex/config.py | 6 +++--- tests/units/test_db_config.py | 18 +++++++++--------- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml index fe8c42608c..a7465defb6 100644 --- a/.github/workflows/check_outdated_dependencies.yml +++ b/.github/workflows/check_outdated_dependencies.yml @@ -58,7 +58,7 @@ jobs: working-directory: ./reflex-web run: poetry run uv pip install -r requirements.txt - name: Install additional dependencies for DB access - run: poetry run uv pip install psycopg2-binary + run: poetry run uv pip install psycopg - name: Init Website for reflex-web working-directory: ./reflex-web run: poetry run reflex init diff --git a/.github/workflows/integration_app_harness.yml b/.github/workflows/integration_app_harness.yml index 6ac5fe6abf..e6ea793774 100644 --- a/.github/workflows/integration_app_harness.yml +++ b/.github/workflows/integration_app_harness.yml @@ -22,9 +22,9 @@ jobs: timeout-minutes: 30 strategy: matrix: - state_manager: ["redis", "memory"] + state_manager: ['redis', 'memory'] + python-version: ['3.11.5', '3.12.0', '3.13.0'] split_index: [1, 2] - python-version: ["3.11.5", "3.12.0"] fail-fast: false runs-on: ubuntu-22.04 services: diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 3e22234b80..2ed68ad9f1 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -43,7 +43,7 @@ jobs: matrix: # Show OS combos first in GUI os: [ubuntu-latest, windows-latest] - python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0'] + python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0', '3.13.0'] exclude: - os: windows-latest python-version: '3.10.13' @@ -73,7 +73,7 @@ jobs: run: | poetry run uv pip install -r requirements.txt - name: Install additional dependencies for DB access - run: poetry run uv pip install psycopg2-binary + run: poetry run uv pip install psycopg - name: Check export --backend-only before init for counter example working-directory: ./reflex-examples/counter run: | @@ -147,7 +147,7 @@ jobs: working-directory: ./reflex-web run: poetry run uv pip install $(grep -ivE "reflex " requirements.txt) - name: Install additional dependencies for DB access - run: poetry run uv pip install psycopg2-binary + run: poetry run uv pip install psycopg - name: Init Website for reflex-web working-directory: ./reflex-web run: poetry run reflex init @@ -216,7 +216,7 @@ jobs: working-directory: ./reflex-web run: poetry run uv pip install -r requirements.txt - name: Install additional dependencies for DB access - run: poetry run uv pip install psycopg2-binary + run: poetry run uv pip install psycopg - name: Init Website for reflex-web working-directory: ./reflex-web run: poetry run reflex init diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index c769185833..a6e39354ce 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -28,7 +28,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0'] + python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0', '3.13.0'] # Windows is a bit behind on Python version availability in Github exclude: - os: windows-latest @@ -88,7 +88,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0'] + python-version: ['3.9.18', '3.10.13', '3.11.5', '3.12.0', '3.13.0'] runs-on: macos-12 steps: - uses: actions/checkout@v4 diff --git a/docker-example/production-app-platform/Dockerfile b/docker-example/production-app-platform/Dockerfile index fec3b13f18..7bf71943bb 100644 --- a/docker-example/production-app-platform/Dockerfile +++ b/docker-example/production-app-platform/Dockerfile @@ -52,7 +52,7 @@ FROM python:3.13-slim WORKDIR /app RUN adduser --disabled-password --home /app reflex COPY --chown=reflex --from=init /app /app -# Install libpq-dev for psycopg2 (skip if not using postgres). +# Install libpq-dev for psycopg (skip if not using postgres). RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/* USER reflex ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1 diff --git a/docker-example/production-compose/Dockerfile b/docker-example/production-compose/Dockerfile index 757c03b8e7..9e69c1778b 100644 --- a/docker-example/production-compose/Dockerfile +++ b/docker-example/production-compose/Dockerfile @@ -39,7 +39,7 @@ FROM python:3.13-slim WORKDIR /app RUN adduser --disabled-password --home /app reflex COPY --chown=reflex --from=init /app /app -# Install libpq-dev for psycopg2 (skip if not using postgres). +# Install libpq-dev for psycopg (skip if not using postgres). RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/* USER reflex ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1 diff --git a/docker-example/production-compose/compose.prod.yaml b/docker-example/production-compose/compose.prod.yaml index 2255395151..7ed5b4eca4 100644 --- a/docker-example/production-compose/compose.prod.yaml +++ b/docker-example/production-compose/compose.prod.yaml @@ -15,7 +15,7 @@ services: app: environment: - DB_URL: postgresql+psycopg2://postgres:secret@db/postgres + DB_URL: postgresql+psycopg://postgres:secret@db/postgres REDIS_URL: redis://redis:6379 depends_on: - db diff --git a/poetry.lock b/poetry.lock index aa826e4b0a..cc778d19b3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1542,18 +1542,18 @@ type = ["mypy (>=1.11.2)"] [[package]] name = "playwright" -version = "1.49.0" +version = "1.49.1" description = "A high-level API to automate web browsers" optional = false python-versions = ">=3.9" files = [ - {file = "playwright-1.49.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:704532a2d8ba580ec9e1895bfeafddce2e3d52320d4eb8aa38e80376acc5cbb0"}, - {file = "playwright-1.49.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:e453f02c4e5cc2db7e9759c47e7425f32e50ac76c76b7eb17c69eed72f01c4d8"}, - {file = "playwright-1.49.0-py3-none-macosx_11_0_universal2.whl", hash = "sha256:37ae985309184472946a6eb1a237e5d93c9e58a781fa73b75c8751325002a5d4"}, - {file = "playwright-1.49.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:68d94beffb3c9213e3ceaafa66171affd9a5d9162e0c8a3eed1b1132c2e57598"}, - {file = "playwright-1.49.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f12d2aecdb41fc25a624cb15f3e8391c252ebd81985e3d5c1c261fe93779345"}, - {file = "playwright-1.49.0-py3-none-win32.whl", hash = "sha256:91103de52d470594ad375b512d7143fa95d6039111ae11a93eb4fe2f2b4a4858"}, - {file = "playwright-1.49.0-py3-none-win_amd64.whl", hash = "sha256:34d28a2c2d46403368610be4339898dc9c34eb9f7c578207b4715c49743a072a"}, + {file = "playwright-1.49.1-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:1041ffb45a0d0bc44d698d3a5aa3ac4b67c9bd03540da43a0b70616ad52592b8"}, + {file = "playwright-1.49.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:9f38ed3d0c1f4e0a6d1c92e73dd9a61f8855133249d6f0cec28648d38a7137be"}, + {file = "playwright-1.49.1-py3-none-macosx_11_0_universal2.whl", hash = "sha256:3be48c6d26dc819ca0a26567c1ae36a980a0303dcd4249feb6f59e115aaddfb8"}, + {file = "playwright-1.49.1-py3-none-manylinux1_x86_64.whl", hash = "sha256:753ca90ee31b4b03d165cfd36e477309ebf2b4381953f2a982ff612d85b147d2"}, + {file = "playwright-1.49.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd9bc8dab37aa25198a01f555f0a2e2c3813fe200fef018ac34dfe86b34994b9"}, + {file = "playwright-1.49.1-py3-none-win32.whl", hash = "sha256:43b304be67f096058e587dac453ece550eff87b8fbed28de30f4f022cc1745bb"}, + {file = "playwright-1.49.1-py3-none-win_amd64.whl", hash = "sha256:47b23cb346283278f5b4d1e1990bcb6d6302f80c0aa0ca93dd0601a1400191df"}, ] [package.dependencies] diff --git a/reflex/config.py b/reflex/config.py index c40abcb39a..ae2c0ea0e8 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -82,7 +82,7 @@ def postgresql( ) @classmethod - def postgresql_psycopg2( + def postgresql_psycopg( cls, database: str, username: str, @@ -90,7 +90,7 @@ def postgresql_psycopg2( host: str | None = None, port: int | None = 5432, ) -> DBConfig: - """Create an instance with postgresql+psycopg2 engine. + """Create an instance with postgresql+psycopg engine. Args: database: Database name. @@ -103,7 +103,7 @@ def postgresql_psycopg2( DBConfig instance. """ return cls( - engine="postgresql+psycopg2", + engine="postgresql+psycopg", username=username, password=password, host=host, diff --git a/tests/units/test_db_config.py b/tests/units/test_db_config.py index b8d7c07cb0..5b716e6bba 100644 --- a/tests/units/test_db_config.py +++ b/tests/units/test_db_config.py @@ -164,7 +164,7 @@ def test_constructor_postgresql(username, password, host, port, database, expect "localhost", 5432, "db", - "postgresql+psycopg2://user:pass@localhost:5432/db", + "postgresql+psycopg://user:pass@localhost:5432/db", ), ( "user", @@ -172,17 +172,17 @@ def test_constructor_postgresql(username, password, host, port, database, expect "localhost", None, "db", - "postgresql+psycopg2://user@localhost/db", + "postgresql+psycopg://user@localhost/db", ), - ("user", "", "", None, "db", "postgresql+psycopg2://user@/db"), - ("", "", "localhost", 5432, "db", "postgresql+psycopg2://localhost:5432/db"), - ("", "", "", None, "db", "postgresql+psycopg2:///db"), + ("user", "", "", None, "db", "postgresql+psycopg://user@/db"), + ("", "", "localhost", 5432, "db", "postgresql+psycopg://localhost:5432/db"), + ("", "", "", None, "db", "postgresql+psycopg:///db"), ], ) -def test_constructor_postgresql_psycopg2( +def test_constructor_postgresql_psycopg( username, password, host, port, database, expected_url ): - """Test DBConfig.postgresql_psycopg2 constructor creates the instance correctly. + """Test DBConfig.postgresql_psycopg constructor creates the instance correctly. Args: username: Database username. @@ -192,10 +192,10 @@ def test_constructor_postgresql_psycopg2( database: Database name. expected_url: Expected database URL generated. """ - db_config = DBConfig.postgresql_psycopg2( + db_config = DBConfig.postgresql_psycopg( username=username, password=password, host=host, port=port, database=database ) - assert db_config.engine == "postgresql+psycopg2" + assert db_config.engine == "postgresql+psycopg" assert db_config.username == username assert db_config.password == password assert db_config.host == host