-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PYTHON-4451 Use Hatch as Build Backend (#1644)
(cherry picked from commit 2b03001)
- Loading branch information
Showing
12 changed files
with
100 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""A custom hatch build hook for pymongo.""" | ||
from __future__ import annotations | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
|
||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface | ||
|
||
|
||
class CustomHook(BuildHookInterface): | ||
"""The pymongo build hook.""" | ||
|
||
def initialize(self, version, build_data): | ||
"""Initialize the hook.""" | ||
if self.target_name == "sdist": | ||
return | ||
here = Path(__file__).parent.resolve() | ||
sys.path.insert(0, str(here)) | ||
|
||
subprocess.check_call([sys.executable, "setup.py", "build_ext", "-i"]) | ||
|
||
# Ensure wheel is marked as binary and contains the binary files. | ||
build_data["infer_tag"] = True | ||
build_data["pure_python"] = False | ||
if os.name == "nt": | ||
patt = ".pyd" | ||
else: | ||
patt = ".so" | ||
for pkg in ["bson", "pymongo"]: | ||
dpath = here / pkg | ||
for fpath in dpath.glob(f"*{patt}"): | ||
relpath = os.path.relpath(fpath, here) | ||
build_data["artifacts"].append(relpath) | ||
build_data["force_include"][relpath] = relpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters