Debian Codegraph @

maturin/bootstrap.py

raw
1 """Support installing rust before compiling (bootstrapping) maturin.
2
3 Installing a package that uses maturin as build backend on a platform without maturin
4 binaries, we install rust in a cache directory if the user doesn't have a rust
5 installation already. Since this bootstrapping requires more dependencies but is only
6 required if rust is missing, we check if cargo is present before requesting those
7 dependencies.
8
9 https://setuptools.pypa.io/en/stable/build_meta.html#dynamic-build-dependencies-and-other-build-meta-tweaks
10 """
11
12 from __future__ import annotations
13
14 import os
15 import shutil
16 from typing import Any
17
18 # noinspection PyUnresolvedReferences
19 from setuptools.build_meta import * # noqa:F403
20
21
22 def get_requires_for_build_wheel(config_settings: dict[str, Any] | None = None) -> list[str]:
23 if not os.environ.get("MATURIN_NO_INSTALL_RUST") and not shutil.which("cargo"):
24 return ["puccinialin>=0.1,<0.2"]
25 return []
26
27
28 def get_requires_for_build_sdist(config_settings: dict[str, Any] | None = None) -> list[str]:
29 if not os.environ.get("MATURIN_NO_INSTALL_RUST") and not shutil.which("cargo"):
30 return ["puccinialin>=0.1,<0.2"]
31 return []