2022-07-06 21:37:19 +00:00
|
|
|
import os
|
2022-11-17 01:05:14 +00:00
|
|
|
from pathlib import Path
|
2022-07-06 21:37:19 +00:00
|
|
|
|
2023-11-29 10:57:54 +00:00
|
|
|
from build import ConfigSettingsType
|
|
|
|
|
2023-06-26 12:20:12 +00:00
|
|
|
from .. import build_env, common, pypabuild
|
2024-04-27 02:30:06 +00:00
|
|
|
from ..build_env import get_pyodide_root
|
2023-07-07 02:52:45 +00:00
|
|
|
from ..io import _BuildSpecExports
|
2022-07-06 21:37:19 +00:00
|
|
|
|
|
|
|
|
2023-07-07 02:52:45 +00:00
|
|
|
def run(
|
2023-11-29 10:57:54 +00:00
|
|
|
srcdir: Path,
|
|
|
|
outdir: Path,
|
|
|
|
exports: _BuildSpecExports,
|
|
|
|
config_settings: ConfigSettingsType,
|
2023-07-07 02:52:45 +00:00
|
|
|
) -> Path:
|
2023-04-12 15:43:57 +00:00
|
|
|
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-09-20 07:00:04 +00:00
|
|
|
target_install_dir = os.environ.get(
|
|
|
|
"TARGETINSTALLDIR", build_env.get_build_flag("TARGETINSTALLDIR")
|
|
|
|
)
|
2023-01-24 01:09:31 +00:00
|
|
|
env = os.environ.copy()
|
2024-04-27 02:30:06 +00:00
|
|
|
env.update(build_env.get_build_environment_vars(get_pyodide_root()))
|
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,
|
2023-09-20 07:00:04 +00:00
|
|
|
target_install_dir=target_install_dir,
|
2022-07-06 21:37:19 +00:00
|
|
|
exports=exports,
|
|
|
|
)
|
|
|
|
|
|
|
|
with build_env_ctx as env:
|
2023-11-29 10:57:54 +00:00
|
|
|
built_wheel = pypabuild.build(srcdir, outdir, env, config_settings)
|
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
|