Skip to content

Commit

Permalink
Use pre-processed options in quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Jun 4, 2024
1 parent dc21bfe commit 7ab73da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/py_build_cmake/config/options/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class StringOption:
prepend_path: str | None = None
remove: list[str] | None = None

@classmethod
def create(cls, value: str):
return cls(value=value)

@classmethod
def from_values(cls, values: ValueReference): # noqa: PLR0911
val = values.values
Expand Down
11 changes: 8 additions & 3 deletions src/py_build_cmake/config/quirks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
)
from .options.cmake_opt import CMakeOption
from .options.config_path import ConfPath
from .options.string import StringOption
from .options.value_reference import ValueReference

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -66,7 +67,7 @@ def cross_compile_win(
assert not config.is_value_set("cross")
cross_cfg = {
"os": "windows",
"arch": platform_to_platform_tag(plat_name),
"arch": StringOption.create(platform_to_platform_tag(plat_name)),
"cmake": {
"options": {
"CMAKE_SYSTEM_NAME": CMakeOption.create("Windows", "STRING"),
Expand Down Expand Up @@ -167,12 +168,16 @@ def cross_compile_mac(config: ValueReference, archs):
if plat_tag:
cross_arch = get_platform_dashes().split("-")
cross_arch[-1] = plat_tag
cross_cfg["arch"] = platform_to_platform_tag("_".join(cross_arch))
cross_cfg["arch"] = StringOption.create(
platform_to_platform_tag("_".join(cross_arch))
)
if sys.implementation.name == "cpython":
version = "".join(map(str, sys.version_info[:2]))
abi = getattr(sys, "abiflags", "")
env = cross_cfg["cmake"]["env"] = {}
env["SETUPTOOLS_EXT_SUFFIX"] = f".cpython-{version}{abi}-darwin.so"
env["SETUPTOOLS_EXT_SUFFIX"] = StringOption.create(
f".cpython-{version}{abi}-darwin.so"
)
config.set_value("cross", cross_cfg)


Expand Down

0 comments on commit 7ab73da

Please sign in to comment.