diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 3093a7c4..40211b66 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -106,17 +106,21 @@ jobs: strategy: fail-fast: false matrix: - platform: - - ubuntu-24.04 - - macos-12 + platform: [ubuntu-24.04, macos-12] + python-version: ["3.8", "3.11"] steps: - name: "Check out repository" uses: actions/checkout@v4 + - name: Setup `hatch` + uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main + with: + python-version: ${{ matrix.python-version }} + - name: "Test psycopg2 name - default" run: | hatch env prune - PSYCOPG2_NAME=$(hatch run pip show psycopg2 || pip show psycopg2-binary | grep Name | cut -d " " -f 2) + PSYCOPG2_NAME=$(hatch run pip show psycopg2 || hatch run pip show psycopg2-binary | grep Name | cut -d " " -f 2) if [[ "$PSYCOPG2_NAME" != "$PSYCOPG2_EXPECTED_NAME" ]]; then exit 1 @@ -127,7 +131,7 @@ jobs: - name: "Test psycopg2 name - invalid override" run: | hatch env prune - PSYCOPG2_NAME=$(hatch run pip show psycopg2 || pip show psycopg2-binary | grep Name | cut -d " " -f 2) + PSYCOPG2_NAME=$(hatch run pip show psycopg2 || hatch run pip show psycopg2-binary | grep Name | cut -d " " -f 2) if [[ "$PSYCOPG2_NAME" != "$PSYCOPG2_EXPECTED_NAME" ]]; then exit 1 @@ -139,7 +143,7 @@ jobs: - name: "Test psycopg2 name - override" run: | hatch env prune - PSYCOPG2_NAME=$(hatch run pip show psycopg2 || pip show psycopg2-binary | grep Name | cut -d " " -f 2) + PSYCOPG2_NAME=$(hatch run pip show psycopg2 || hatch run pip show psycopg2-binary | grep Name | cut -d " " -f 2) if [[ "$PSYCOPG2_NAME" != "$PSYCOPG2_EXPECTED_NAME" ]]; then exit 1 @@ -147,3 +151,21 @@ jobs: env: DBT_PSYCOPG2_NAME: psycopg2 PSYCOPG2_EXPECTED_NAME: psycopg2-binary # this is not yet implemented + + - name: "Test psycopg2 name - manual override" + run: | + hatch env prune + + # this is the work around + PSYCOPG2_VERSION = $(hatch run pip show psycopg2-binary | grep Version | cut -d " " -f 2) + hatch run pip uninstall -y psycopg2-binary + hatch run pip install psycopg2==$PSYCOPG2_VERSION + # this is the end of the work around + + PSYCOPG2_NAME=$(hatch run pip show psycopg2 || hatch run pip show psycopg2-binary | grep Name | cut -d " " -f 2) + + if [[ "$PSYCOPG2_NAME" != "$PSYCOPG2_EXPECTED_NAME" ]]; then + exit 1 + fi + env: + PSYCOPG2_EXPECTED_NAME: psycopg2 diff --git a/README.md b/README.md index d5b8900a..3462fe86 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,18 @@ more information on using dbt with Postgres, consult [the docs](https://docs.get - [Install dbt](https://docs.getdbt.com/docs/installation) - Read the [introduction](https://docs.getdbt.com/docs/introduction/) and [viewpoint](https://docs.getdbt.com/docs/about/viewpoint/) +### `psycopg2-binary` vs. `psycopg2` + +By default, `dbt-postgres` installs `psycopg2-binary`. This is great for development, and even testing, as it does not require any OS dependencies; it's a pre-built wheel. However, building `psycopg2` from source will grant performance improvements that are desired in a production environment. In order to install `psycopg2`, use the following steps: + +```bash +PSYCOPG2_VERSION = $(pip show psycopg2-binary | grep Version | cut -d " " -f 2) +pip uninstall -y psycopg2-binary +pip install psycopg2==$PSYCOPG2_VERSION +``` + +This ensures the version of `psycopg2` will match that of `psycopg2-binary`. + ## Join the dbt Community - Be part of the conversation in the [dbt Community Slack](http://community.getdbt.com/)