Skip to content

Commit

Permalink
Install psycopg2 based on platform (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare authored Apr 12, 2024
1 parent 461616f commit 32c8547
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 3,424 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240412-153154.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Determine `psycopg2` based on `platform_system` (Linux or other)
time: 2024-04-12T15:31:54.861201-04:00
custom:
Author: mikealfare
Issue: "60"
30 changes: 28 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
integration:
name: Integration Tests
Expand Down Expand Up @@ -68,14 +72,12 @@ jobs:

- name: Update Adapters and Core branches
if: ${{ github.event_name == 'workflow_call' || github.event_name == 'workflow_dispatch'}}
shell: bash
run: |
./.github/scripts/update_dev_packages.sh \
${{ inputs.dbt_adapters_branch }} \
${{ inputs.core_branch }}
- name: Setup postgres
shell: bash
run: psql -f ./scripts/setup_test_database.sql
env:
PGHOST: localhost
Expand Down Expand Up @@ -106,3 +108,27 @@ jobs:
source-file: "results.csv"
file-name: "integration_results"
python-version: ${{ matrix.python-version }}

psycopg2-check:
name: "Test psycopg2 build version"
runs-on: ${{ matrix.scenario.platform }}
strategy:
fail-fast: false
matrix:
scenario:
- {platform: ubuntu-latest, psycopg2-name: psycopg2}
- {platform: macos-latest, psycopg2-name: psycopg2-binary}
steps:
- name: "Check out repository"
uses: actions/checkout@v4

- name: "Test psycopg2 name"
run: |
python -m pip install .
PSYCOPG2_PIP_ENTRY=$(pip list | grep "psycopg2 " || pip list | grep psycopg2-binary)
echo $PSYCOPG2_PIP_ENTRY
PSYCOPG2_NAME="${PSYCOPG2_PIP_ENTRY%% *}"
echo $PSYCOPG2_NAME
if [[ "${PSYCOPG2_NAME}" != "${{ matrix.scenario.psycopg2-name }}" ]]; then
exit 1
fi
56 changes: 0 additions & 56 deletions hatch_build.py

This file was deleted.

17 changes: 13 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
dynamic = ["version", "dependencies"]
dynamic = ["version"]
name = "dbt-postgres"
description = "The set of adapter protocols and base functionality that supports integration with dbt-core"
readme = "README.md"
Expand All @@ -22,6 +22,18 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
# install `psycopg2` on linux (assumed production)
'psycopg2>=2.9,<3.0; platform_system == "Linux"',
# install `psycopg2-binary` on macos/windows (assumed development)
'psycopg2-binary>=2.9,<3.0; platform_system != "Linux"',
"dbt-adapters>=0.1.0a1,<2.0",
# add dbt-core to ensure backwards compatibility of installation, this is not a functional dependency
"dbt-core>=1.8.0a1",
# installed via dbt-adapters but used directly
"dbt-common>=0.1.0a1,<2.0",
"agate>=1.0,<2.0",
]

[project.urls]
Homepage = "https://github.com/dbt-labs/dbt-postgres"
Expand All @@ -43,9 +55,6 @@ packages = ["dbt"]
[tool.hatch.version]
path = "dbt/adapters/postgres/__version__.py"

[tool.hatch.build.hooks.custom]
path = "./hatch_build.py"

[tool.hatch.envs.default]
dependencies = [
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git",
Expand Down
Loading

0 comments on commit 32c8547

Please sign in to comment.