1818
1919 python -m build --wheel -C winml=true
2020
21- Skip native deps (use pre-installed foundry-local-core / ORT / GenAI)::
22-
23- python -m build --wheel -C skip-native-deps=true
24-
2521Environment variable fallback (useful in CI pipelines)::
2622
2723 FOUNDRY_VARIANT=winml python -m build --wheel
28- FOUNDRY_SKIP_NATIVE_DEPS=1 python -m build --wheel
24+
25+ CI usage (install without pulling dependencies)::
26+
27+ pip install --no-deps <wheel>
2928"""
3029
3130from __future__ import annotations
5150_STANDARD_NAME = 'name = "foundry-local-sdk"'
5251_WINML_NAME = 'name = "foundry-local-sdk-winml"'
5352
54- # Native binary package prefixes to strip when skip-native-deps is active.
55- _NATIVE_DEP_PREFIXES = (
56- "foundry-local-core" ,
57- "onnxruntime-core" ,
58- "onnxruntime-genai-core" ,
59- )
60-
6153
6254# ---------------------------------------------------------------------------
6355# Variant detection
@@ -75,23 +67,6 @@ def _is_winml(config_settings: dict | None) -> bool:
7567 return os .environ .get ("FOUNDRY_VARIANT" , "" ).lower () == "winml"
7668
7769
78- def _is_skip_native_deps (config_settings : dict | None ) -> bool :
79- """Return True when native binary dependencies should be omitted.
80-
81- When set, ``foundry-local-core``, ``onnxruntime-core``, and
82- ``onnxruntime-genai-core`` are stripped from requirements.txt so the
83- wheel is built against whatever versions are already installed.
84- Useful in CI pipelines that pre-install pipeline-built native wheels.
85-
86- Checks ``config_settings["skip-native-deps"]`` first
87- (set via ``-C skip-native-deps=true``), then falls back to the
88- ``FOUNDRY_SKIP_NATIVE_DEPS`` environment variable.
89- """
90- if config_settings and str (config_settings .get ("skip-native-deps" , "" )).lower () == "true" :
91- return True
92- return os .environ .get ("FOUNDRY_SKIP_NATIVE_DEPS" , "" ).lower () in ("1" , "true" )
93-
94-
9570# ---------------------------------------------------------------------------
9671# In-place patching context manager
9772# ---------------------------------------------------------------------------
@@ -125,48 +100,11 @@ def _patch_for_winml() -> Generator[None, None, None]:
125100 _REQUIREMENTS .write_text (requirements_original , encoding = "utf-8" )
126101
127102
128- @contextlib .contextmanager
129- def _strip_native_deps () -> Generator [None , None , None ]:
130- """Temporarily remove native binary deps from requirements.txt.
131-
132- Lines starting with any prefix in ``_NATIVE_DEP_PREFIXES`` (case-
133- insensitive) are removed. The file is restored in the ``finally``
134- block.
135- """
136- requirements_original = _REQUIREMENTS .read_text (encoding = "utf-8" )
137- try :
138- filtered = [
139- line for line in requirements_original .splitlines (keepends = True )
140- if not any (line .lstrip ().lower ().startswith (p ) for p in _NATIVE_DEP_PREFIXES )
141- ]
142- _REQUIREMENTS .write_text ("" .join (filtered ), encoding = "utf-8" )
143- yield
144- finally :
145- _REQUIREMENTS .write_text (requirements_original , encoding = "utf-8" )
146-
147-
148103def _apply_patches (config_settings : dict | None ):
149104 """Return a context manager that applies the appropriate patches."""
150- winml = _is_winml (config_settings )
151- skip_native = _is_skip_native_deps (config_settings )
152-
153- @contextlib .contextmanager
154- def _combined ():
155- # Stack contexts: WinML swaps requirements first, then strip_native
156- # removes native deps from whatever requirements are active.
157- if winml and skip_native :
158- with _patch_for_winml (), _strip_native_deps ():
159- yield
160- elif winml :
161- with _patch_for_winml ():
162- yield
163- elif skip_native :
164- with _strip_native_deps ():
165- yield
166- else :
167- yield
168-
169- return _combined ()
105+ if _is_winml (config_settings ):
106+ return _patch_for_winml ()
107+ return contextlib .nullcontext ()
170108
171109
172110# ---------------------------------------------------------------------------
0 commit comments