diff --git a/hatch_build.py b/hatch_build.py deleted file mode 100644 index a44d06c7..00000000 --- a/hatch_build.py +++ /dev/null @@ -1,56 +0,0 @@ -import os -from typing import Any, Dict - -from hatchling.builders.config import BuilderConfig -from hatchling.builders.hooks.plugin.interface import BuildHookInterface -from hatchling.plugin import hookimpl - -BASE_DEPS = [ - # psycopg2 dependency installed in custom hatch_build.py - "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", -] - -PSYCOPG2_MESSAGE = """ -No package name override was set. -Using 'psycopg2-binary' package to satisfy 'psycopg2' - -If you experience segmentation faults, silent crashes, or installation errors, -consider retrying with the 'DBT_PSYCOPG2_NAME' environment variable set to -'psycopg2'. It may require a compiler toolchain and development libraries! -""".strip() - - -def _dbt_psycopg2_name(): - # if the user chose something, use that - package_name = os.getenv("DBT_PSYCOPG2_NAME", "") - if package_name: - return package_name - - # default to psycopg2-binary for all OSes/versions - print(PSYCOPG2_MESSAGE) - return "psycopg2-binary" - - -class CustomBuildHook(BuildHookInterface[BuilderConfig]): - """ - Custom build hook to install psycopg2 instead of psycopg2-binary based on the presence of `DBT_PSYCOPG2_NAME` env - var. This is necessary as psycopg2-binary is better for local development, but psycopg2 is better for production. - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - def initialize(self, version: str, build_data: Dict) -> None: - build_data["dependencies"] = BASE_DEPS - psycopg2_pkg_name = _dbt_psycopg2_name() - build_data["dependencies"].append(f"{psycopg2_pkg_name}>=2.9,<3.0") - - -@hookimpl -def hatch_register_build_hook(): - return CustomBuildHook diff --git a/pyproject.toml b/pyproject.toml index e9d880a2..bb479c47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"