11import pathlib
22import typing as T
33
4+ import packaging .markers
45import tomli
56
67from .config .util import parse_input
@@ -23,6 +24,19 @@ def __init__(self, pyproject_path: T.Optional[pathlib.Path] = None) -> None:
2324
2425 self ._all_deps = None
2526
27+ self ._evaluated_markers : T .Dict [str , bool ] = {}
28+
29+ def _enable_if (self , condition : str ) -> bool :
30+ """
31+ Evaluates a string containing PEP 508 environment markers
32+ """
33+ ok = self ._evaluated_markers .get (condition )
34+ if ok is None :
35+ ok = packaging .markers .Marker (condition ).evaluate ()
36+ self ._evaluated_markers [condition ] = ok
37+
38+ return ok
39+
2640 @property
2741 def package_root (self ) -> pathlib .Path :
2842 if self ._package_root is None :
@@ -40,12 +54,6 @@ def package_root(self) -> pathlib.Path:
4054
4155 return self ._package_root
4256
43- @property
44- def platform (self ):
45- if self ._platform is None :
46- self ._platform = get_platform ()
47- return self ._platform
48-
4957 @property
5058 def project (self ):
5159 if self ._project is None :
@@ -59,12 +67,6 @@ def project(self):
5967
6068 self .project_dict = self .pyproject .get ("tool" , {}).get ("semiwrap" , {})
6169
62- # Overrides are applied before pydantic does processing, so that
63- # we can easily override anything without needing to make the
64- # pydantic schemas messy with needless details
65- override_keys = get_platform_override_keys (self .platform )
66- apply_overrides (self .project_dict , override_keys )
67-
6870 try :
6971 self ._project = parse_input (
7072 self .project_dict , SemiwrapToolConfig , project_fname
@@ -85,3 +87,12 @@ def get_extension_deps(self, extension: ExtensionModuleConfig) -> T.List[str]:
8587 deps .append (wrap )
8688 deps .extend (extension .depends )
8789 return deps
90+
91+ def get_extension_headers (
92+ self , extension : ExtensionModuleConfig
93+ ) -> T .Generator [T .Tuple [str , str ], None , None ]:
94+ for yml , hdr in extension .headers .items ():
95+ if isinstance (hdr , str ):
96+ yield yml , hdr
97+ elif self ._enable_if (hdr .enable_if ):
98+ yield yml , hdr .header
0 commit comments