Skip to content

Commit 19e5a52

Browse files
committed
update post-build hook to a pre-build hook
1 parent 94da850 commit 19e5a52

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

hatch_hooks.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import os
2-
import subprocess
3-
import sys
42

53
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
64
from hatchling.plugin import hookimpl
@@ -14,20 +12,15 @@ class Psycopg2NoBinary(BuildHookInterface):
1412

1513
PLUGIN_NAME = "psycopg2"
1614

17-
def finalize(self, version, build_data, artifact_path) -> None:
15+
def initialize(self, version, build_data) -> None:
1816
if os.getenv("DBT_PSYCOPG2_NAME", "") == "psycopg2":
1917
psycopg2_binary_pinned = [
2018
package
2119
for package in build_data["dependencies"]
2220
if package.startswith("psycopg2-binary")
2321
].pop()
2422
psycopg2_pinned = psycopg2_binary_pinned.replace("-binary", "")
25-
subprocess.check_call(
26-
[sys.executable, "-m", "pip", "-y", "uninstall", "psycopg2-binary"]
27-
)
28-
subprocess.check_call(
29-
[sys.executable, "-m", "pip", "-y", "install", f'"{psycopg2_pinned}"']
30-
)
23+
build_data["dependencies"].append(psycopg2_pinned)
3124

3225

3326
@hookimpl

0 commit comments

Comments
 (0)