2022-07-06 21:37:19 +00:00
|
|
|
import os
|
2022-11-17 01:05:14 +00:00
|
|
|
from pathlib import Path
|
2023-01-04 23:45:20 +00:00
|
|
|
from typing import Any
|
2022-07-06 21:37:19 +00:00
|
|
|
|
2023-06-26 12:20:12 +00:00
|
|
|
from .. import build_env, common, pypabuild
|
2022-07-06 21:37:19 +00:00
|
|
|
|
|
|
|
|
2023-04-12 15:43:57 +00:00
|
|
|
def run(srcdir: Path, outdir: Path, exports: Any, args: list[str]) -> Path:
|
|
|
|
outdir = outdir.resolve()
|
2023-06-26 12:20:12 +00:00
|
|
|
cflags = build_env.get_build_flag("SIDE_MODULE_CFLAGS")
|
2022-07-06 21:37:19 +00:00
|
|
|
cflags += f" {os.environ.get('CFLAGS', '')}"
|
2023-06-26 12:20:12 +00:00
|
|
|
cxxflags = build_env.get_build_flag("SIDE_MODULE_CXXFLAGS")
|
2022-07-06 21:37:19 +00:00
|
|
|
cxxflags += f" {os.environ.get('CXXFLAGS', '')}"
|
2023-06-26 12:20:12 +00:00
|
|
|
ldflags = build_env.get_build_flag("SIDE_MODULE_LDFLAGS")
|
2022-07-06 21:37:19 +00:00
|
|
|
ldflags += f" {os.environ.get('LDFLAGS', '')}"
|
2023-01-24 01:09:31 +00:00
|
|
|
env = os.environ.copy()
|
2023-06-26 12:20:12 +00:00
|
|
|
env.update(build_env.get_build_environment_vars())
|
2022-11-17 01:05:14 +00:00
|
|
|
|
2023-01-17 04:31:45 +00:00
|
|
|
build_env_ctx = pypabuild.get_build_env(
|
2023-01-24 01:09:31 +00:00
|
|
|
env=env,
|
2022-07-06 21:37:19 +00:00
|
|
|
pkgname="",
|
|
|
|
cflags=cflags,
|
|
|
|
cxxflags=cxxflags,
|
|
|
|
ldflags=ldflags,
|
|
|
|
target_install_dir="",
|
|
|
|
exports=exports,
|
|
|
|
)
|
|
|
|
|
|
|
|
with build_env_ctx as env:
|
2023-04-12 15:43:57 +00:00
|
|
|
built_wheel = pypabuild.build(srcdir, outdir, env, " ".join(args))
|
2023-06-17 20:39:33 +00:00
|
|
|
|
|
|
|
wheel_path = Path(built_wheel)
|
|
|
|
with common.modify_wheel(wheel_path) as wheel_dir:
|
2023-06-26 12:20:12 +00:00
|
|
|
build_env.replace_so_abi_tags(wheel_dir)
|
2023-06-17 20:39:33 +00:00
|
|
|
|
|
|
|
return wheel_path
|