Skip to content

Commit

Permalink
Specify requests dependency in hook
Browse files Browse the repository at this point in the history
I am not sure exactly why this change is needed now. I think Hatch
[added support for specifying custom build hook dependencies][oops]
directly in the custom build hook in the last release, and this
might have accidentally broken the way in which we used to specify
this dependency.

It might also be that the breakage is intentional, in which case
they [forgot to update the docs][whoopsie]

[oops]: pypa/hatch@c04877c
[whoopsie]: https://hatch.pypa.io/1.9/config/build/#dependencies_1
  • Loading branch information
unflxw committed Mar 18, 2024
1 parent 256b455 commit d6189e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[build-system]
requires = ["hatchling"]
requires = [
"hatchling",
"requests"
]
build-backend = "hatchling.build"

[project]
Expand Down Expand Up @@ -144,7 +147,6 @@ for = "_APPSIGNAL_BUILD_TRIPLE=\"{args}\" hatch build -t wheel"

[tool.hatch.build.targets.wheel.hooks.custom]
path = "src/scripts/build_hook.py"
dependencies = ["requests"]

[tool.hatch.build.targets.sdist.hooks.custom]
path = "src/scripts/sdist_hook.py"
Expand Down
6 changes: 5 additions & 1 deletion src/scripts/build_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from runpy import run_path
from typing import Any

import requests
from hatchling.builders.hooks.plugin.interface import BuildHookInterface


Expand Down Expand Up @@ -79,7 +78,12 @@ class DownloadError(Exception):


class CustomBuildHook(BuildHookInterface):
def dependencies(self) -> list[str]:
return ["requests"]

def initialize(self, _version: str, build_data: dict[str, Any]) -> None:
import requests

"""
This occurs immediately before each build.
Expand Down

0 comments on commit d6189e0

Please sign in to comment.