File: hatch_build.py

package info (click to toggle)
libmongocrypt 1.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,572 kB
  • sloc: ansic: 70,067; python: 4,547; cpp: 615; sh: 460; makefile: 44; awk: 8
file content (36 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""A custom hatch build hook for pymongo."""
from __future__ import annotations

import os
import sys
from pathlib import Path

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


class CustomHook(BuildHookInterface):
    """The pymongocrypt build hook."""

    def initialize(self, version, build_data):
        """Initialize the hook."""
        if self.target_name == "sdist":
            return

        # Ensure wheel is marked as binary.
        # On linux, we use auditwheel to set the name.
        if sys.platform == "darwin":
            os.environ["MACOSX_DEPLOYMENT_TARGET"] = "11.0"
            build_data["tag"] = "py3-none-macosx_11_0_universal2"
            patt = ".dylib"
        elif os.name == "nt":
            build_data["tag"] = "py3-none-win_amd64"
            patt = ".dll"
        else:
            patt = ".so"

        here = Path(__file__).parent.resolve()
        dpath = here / "pymongocrypt"
        for fpath in dpath.glob(f"*{patt}"):
            relpath = os.path.relpath(fpath, here)
            build_data["artifacts"].append(relpath)
            build_data["force_include"][relpath] = relpath