Add build backend scaffolding (#7662)

This commit is contained in:
konsti
2024-09-24 19:23:17 +02:00
committed by GitHub
parent 9a6f455cbf
commit c4c5378c0b
11 changed files with 308 additions and 42 deletions
+25 -36
View File
@@ -1,41 +1,30 @@
from __future__ import annotations
import os
import sys
import sysconfig
if os.environ.get("UV_PREVIEW"):
from ._build_backend import *
from ._find_uv import find_uv_bin
def find_uv_bin() -> str:
"""Return the uv binary path."""
uv_exe = "uv" + sysconfig.get_config_var("EXE")
path = os.path.join(sysconfig.get_path("scripts"), uv_exe)
if os.path.isfile(path):
return path
if sys.version_info >= (3, 10):
user_scheme = sysconfig.get_preferred_scheme("user")
elif os.name == "nt":
user_scheme = "nt_user"
elif sys.platform == "darwin" and sys._framework:
user_scheme = "osx_framework_user"
else:
user_scheme = "posix_user"
path = os.path.join(sysconfig.get_path("scripts", scheme=user_scheme), uv_exe)
if os.path.isfile(path):
return path
# Search in `bin` adjacent to package root (as created by `pip install --target`).
pkg_root = os.path.dirname(os.path.dirname(__file__))
target_path = os.path.join(pkg_root, "bin", uv_exe)
if os.path.isfile(target_path):
return target_path
raise FileNotFoundError(path)
__all__ = [
"find_uv_bin",
]
if os.environ.get("UV_PREVIEW"):
__all__ = [
"find_uv_bin",
# PEP 517 hook `build_sdist`.
"build_sdist",
# PEP 517 hook `build_wheel`.
"build_wheel",
# PEP 660 hook `build_editable`.
"build_editable",
# PEP 517 hook `get_requires_for_build_sdist`.
"get_requires_for_build_sdist",
# PEP 517 hook `get_requires_for_build_wheel`.
"get_requires_for_build_wheel",
# PEP 517 hook `prepare_metadata_for_build_wheel`.
"prepare_metadata_for_build_wheel",
# PEP 660 hook `get_requires_for_build_editable`.
"get_requires_for_build_editable",
# PEP 660 hook `prepare_metadata_for_build_editable`.
"prepare_metadata_for_build_editable",
]
else:
__all__ = ["find_uv_bin"]