Initialize the hook.
(self, version, build_data)
| 13 | """The pymongo build hook.""" |
| 14 | |
| 15 | def initialize(self, version, build_data): |
| 16 | """Initialize the hook.""" |
| 17 | if self.target_name == "sdist": |
| 18 | return |
| 19 | here = Path(__file__).parent.resolve() |
| 20 | sys.path.insert(0, str(here)) |
| 21 | |
| 22 | subprocess.run([sys.executable, "_setup.py", "build_ext", "-i"], check=True) |
| 23 | |
| 24 | # Ensure wheel is marked as binary and contains the binary files. |
| 25 | build_data["infer_tag"] = True |
| 26 | build_data["pure_python"] = False |
| 27 | if os.name == "nt": |
| 28 | patt = ".pyd" |
| 29 | else: |
| 30 | patt = ".so" |
| 31 | for pkg in ["bson", "pymongo"]: |
| 32 | dpath = here / pkg |
| 33 | for fpath in dpath.glob(f"*{patt}"): |
| 34 | relpath = os.path.relpath(fpath, here) |
| 35 | build_data["artifacts"].append(relpath) |
| 36 | build_data["force_include"][relpath] = relpath |