From f4df4e4d0614090f13a02b61bce716c327342e8a Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Thu, 2 Apr 2026 23:06:07 -0700 Subject: [PATCH 1/3] no deps --- .pipelines/templates/build-python-steps.yml | 11 +-- .pipelines/templates/test-python-steps.yml | 8 +-- sdk/python/build_backend.py | 76 ++------------------- 3 files changed, 16 insertions(+), 79 deletions(-) diff --git a/.pipelines/templates/build-python-steps.yml b/.pipelines/templates/build-python-steps.yml index 6fd0cd34..5ed3d5e8 100644 --- a/.pipelines/templates/build-python-steps.yml +++ b/.pipelines/templates/build-python-steps.yml @@ -112,15 +112,16 @@ steps: } # Build wheel — standard or WinML variant -# skip-native-deps=true omits foundry-local-core/onnxruntime pinned versions -# from the wheel metadata, since the pipeline pre-installs its own builds. +# The wheel retains all dependencies in its metadata so end users get +# native packages installed automatically. CI uses --no-deps to avoid +# re-downloading packages that were pre-installed from pipeline builds. - ${{ if eq(parameters.isWinML, true) }}: - - script: python -m build --wheel -C winml=true -C skip-native-deps=true --outdir dist/ + - script: python -m build --wheel -C winml=true --outdir dist/ displayName: 'Build wheel (WinML)' workingDirectory: $(repoRoot)/sdk/python - ${{ else }}: - - script: python -m build --wheel -C skip-native-deps=true --outdir dist/ + - script: python -m build --wheel --outdir dist/ displayName: 'Build wheel' workingDirectory: $(repoRoot)/sdk/python @@ -131,7 +132,7 @@ steps: targetType: inline script: | $wheel = (Get-ChildItem "$(repoRoot)/sdk/python/dist/*.whl" | Select-Object -First 1).FullName - pip install $wheel + pip install --no-deps $wheel # Stage output - task: PowerShell@2 diff --git a/.pipelines/templates/test-python-steps.yml b/.pipelines/templates/test-python-steps.yml index f54a9464..51f69daf 100644 --- a/.pipelines/templates/test-python-steps.yml +++ b/.pipelines/templates/test-python-steps.yml @@ -100,18 +100,16 @@ steps: } # Install ORT native packages from the ORT-Nightly feed. -# skip-native-deps strips these from the SDK wheel metadata, so they -# must be installed explicitly for tests to locate the native binaries. - script: pip install onnxruntime-core onnxruntime-genai-core displayName: 'Install ORT native packages' - ${{ if not(parameters.isWinML) }}: - - script: python -m build --wheel -C skip-native-deps=true --outdir dist/ + - script: python -m build --wheel --outdir dist/ displayName: 'Build wheel' workingDirectory: $(repoRoot)/sdk/python - ${{ if parameters.isWinML }}: - - script: python -m build --wheel -C winml=true -C skip-native-deps=true --outdir dist/ + - script: python -m build --wheel -C winml=true --outdir dist/ displayName: 'Build wheel (WinML)' workingDirectory: $(repoRoot)/sdk/python @@ -121,7 +119,7 @@ steps: targetType: inline script: | $wheel = (Get-ChildItem "$(repoRoot)/sdk/python/dist/*.whl" | Select-Object -First 1).FullName - pip install $wheel + pip install --no-deps $wheel - script: pip install coverage pytest>=7.0.0 pytest-timeout>=2.1.0 displayName: 'Install test dependencies' diff --git a/sdk/python/build_backend.py b/sdk/python/build_backend.py index 3789501b..1bdf6cbb 100644 --- a/sdk/python/build_backend.py +++ b/sdk/python/build_backend.py @@ -18,14 +18,13 @@ python -m build --wheel -C winml=true -Skip native deps (use pre-installed foundry-local-core / ORT / GenAI):: - - python -m build --wheel -C skip-native-deps=true - Environment variable fallback (useful in CI pipelines):: FOUNDRY_VARIANT=winml python -m build --wheel - FOUNDRY_SKIP_NATIVE_DEPS=1 python -m build --wheel + +CI usage (install without pulling dependencies):: + + pip install --no-deps """ from __future__ import annotations @@ -51,13 +50,6 @@ _STANDARD_NAME = 'name = "foundry-local-sdk"' _WINML_NAME = 'name = "foundry-local-sdk-winml"' -# Native binary package prefixes to strip when skip-native-deps is active. -_NATIVE_DEP_PREFIXES = ( - "foundry-local-core", - "onnxruntime-core", - "onnxruntime-genai-core", -) - # --------------------------------------------------------------------------- # Variant detection @@ -75,23 +67,6 @@ def _is_winml(config_settings: dict | None) -> bool: return os.environ.get("FOUNDRY_VARIANT", "").lower() == "winml" -def _is_skip_native_deps(config_settings: dict | None) -> bool: - """Return True when native binary dependencies should be omitted. - - When set, ``foundry-local-core``, ``onnxruntime-core``, and - ``onnxruntime-genai-core`` are stripped from requirements.txt so the - wheel is built against whatever versions are already installed. - Useful in CI pipelines that pre-install pipeline-built native wheels. - - Checks ``config_settings["skip-native-deps"]`` first - (set via ``-C skip-native-deps=true``), then falls back to the - ``FOUNDRY_SKIP_NATIVE_DEPS`` environment variable. - """ - if config_settings and str(config_settings.get("skip-native-deps", "")).lower() == "true": - return True - return os.environ.get("FOUNDRY_SKIP_NATIVE_DEPS", "").lower() in ("1", "true") - - # --------------------------------------------------------------------------- # In-place patching context manager # --------------------------------------------------------------------------- @@ -125,48 +100,11 @@ def _patch_for_winml() -> Generator[None, None, None]: _REQUIREMENTS.write_text(requirements_original, encoding="utf-8") -@contextlib.contextmanager -def _strip_native_deps() -> Generator[None, None, None]: - """Temporarily remove native binary deps from requirements.txt. - - Lines starting with any prefix in ``_NATIVE_DEP_PREFIXES`` (case- - insensitive) are removed. The file is restored in the ``finally`` - block. - """ - requirements_original = _REQUIREMENTS.read_text(encoding="utf-8") - try: - filtered = [ - line for line in requirements_original.splitlines(keepends=True) - if not any(line.lstrip().lower().startswith(p) for p in _NATIVE_DEP_PREFIXES) - ] - _REQUIREMENTS.write_text("".join(filtered), encoding="utf-8") - yield - finally: - _REQUIREMENTS.write_text(requirements_original, encoding="utf-8") - - def _apply_patches(config_settings: dict | None): """Return a context manager that applies the appropriate patches.""" - winml = _is_winml(config_settings) - skip_native = _is_skip_native_deps(config_settings) - - @contextlib.contextmanager - def _combined(): - # Stack contexts: WinML swaps requirements first, then strip_native - # removes native deps from whatever requirements are active. - if winml and skip_native: - with _patch_for_winml(), _strip_native_deps(): - yield - elif winml: - with _patch_for_winml(): - yield - elif skip_native: - with _strip_native_deps(): - yield - else: - yield - - return _combined() + if _is_winml(config_settings): + return _patch_for_winml() + return contextlib.nullcontext() # --------------------------------------------------------------------------- From fce2402af8022bc83933e0a45a3d6f86392e6f2c Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Thu, 2 Apr 2026 23:19:56 -0700 Subject: [PATCH 2/3] copilot feedback --- .pipelines/templates/build-python-steps.yml | 6 ++++++ .pipelines/templates/test-python-steps.yml | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.pipelines/templates/build-python-steps.yml b/.pipelines/templates/build-python-steps.yml index 5ed3d5e8..a3b87723 100644 --- a/.pipelines/templates/build-python-steps.yml +++ b/.pipelines/templates/build-python-steps.yml @@ -111,6 +111,12 @@ steps: Write-Warning "No FLC wheel found matching $filter in ${{ parameters.flcWheelsDir }}" } +- script: pip install onnxruntime-core onnxruntime-genai-core + displayName: 'Install ORT native packages' + +- script: pip install pydantic requests openai + displayName: 'Install pure python dependencies' + # Build wheel — standard or WinML variant # The wheel retains all dependencies in its metadata so end users get # native packages installed automatically. CI uses --no-deps to avoid diff --git a/.pipelines/templates/test-python-steps.yml b/.pipelines/templates/test-python-steps.yml index 51f69daf..7887462e 100644 --- a/.pipelines/templates/test-python-steps.yml +++ b/.pipelines/templates/test-python-steps.yml @@ -99,10 +99,12 @@ steps: Write-Warning "No FLC wheel found matching $filter" } -# Install ORT native packages from the ORT-Nightly feed. - script: pip install onnxruntime-core onnxruntime-genai-core displayName: 'Install ORT native packages' +- script: pip install pydantic requests openai + displayName: 'Install pure python dependencies' + - ${{ if not(parameters.isWinML) }}: - script: python -m build --wheel --outdir dist/ displayName: 'Build wheel' From 232e27ba5e617e81e63c44ec92f5fd9ff1a433dc Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Thu, 2 Apr 2026 23:41:59 -0700 Subject: [PATCH 3/3] copilot feedback --- .pipelines/templates/build-python-steps.yml | 5 ++--- .pipelines/templates/test-python-steps.yml | 5 ++--- sdk/js/script/install-standard.cjs | 2 +- sdk/js/script/install-winml.cjs | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.pipelines/templates/build-python-steps.yml b/.pipelines/templates/build-python-steps.yml index a3b87723..8ab4d8d1 100644 --- a/.pipelines/templates/build-python-steps.yml +++ b/.pipelines/templates/build-python-steps.yml @@ -12,7 +12,6 @@ parameters: default: false - name: flcWheelsDir type: string - default: '' displayName: 'Path to directory containing the FLC wheels (for overriding foundry-local-core)' - name: outputDir type: string @@ -111,10 +110,10 @@ steps: Write-Warning "No FLC wheel found matching $filter in ${{ parameters.flcWheelsDir }}" } -- script: pip install onnxruntime-core onnxruntime-genai-core +- script: pip install onnxruntime-core==1.24.3 onnxruntime-genai-core==0.12.1 displayName: 'Install ORT native packages' -- script: pip install pydantic requests openai +- script: pip install "pydantic>=2.0.0" "requests>=2.32.4" "openai>=2.24.0" displayName: 'Install pure python dependencies' # Build wheel — standard or WinML variant diff --git a/.pipelines/templates/test-python-steps.yml b/.pipelines/templates/test-python-steps.yml index 7887462e..1da74ee2 100644 --- a/.pipelines/templates/test-python-steps.yml +++ b/.pipelines/templates/test-python-steps.yml @@ -8,7 +8,6 @@ parameters: default: false - name: flcWheelsDir type: string - default: '' displayName: 'Path to directory containing the FLC wheels' steps: @@ -99,10 +98,10 @@ steps: Write-Warning "No FLC wheel found matching $filter" } -- script: pip install onnxruntime-core onnxruntime-genai-core +- script: pip install onnxruntime-core==1.24.3 onnxruntime-genai-core==0.12.1 displayName: 'Install ORT native packages' -- script: pip install pydantic requests openai +- script: pip install "pydantic>=2.0.0" "requests>=2.32.4" "openai>=2.24.0" displayName: 'Install pure python dependencies' - ${{ if not(parameters.isWinML) }}: diff --git a/sdk/js/script/install-standard.cjs b/sdk/js/script/install-standard.cjs index 319a33d1..dc9a9828 100644 --- a/sdk/js/script/install-standard.cjs +++ b/sdk/js/script/install-standard.cjs @@ -11,7 +11,7 @@ const { NUGET_FEED, ORT_NIGHTLY_FEED, runInstall } = require('./install-utils.cj const useNightly = process.env.npm_config_nightly === 'true'; const ARTIFACTS = [ - { name: 'Microsoft.AI.Foundry.Local.Core', version: '0.9.0.8-rc3', feed: ORT_NIGHTLY_FEED, nightly: useNightly }, + { name: 'Microsoft.AI.Foundry.Local.Core', version: '0.9.0-dev-202603310538-f6efa8d3', feed: ORT_NIGHTLY_FEED, nightly: useNightly }, { name: os.platform() === 'linux' ? 'Microsoft.ML.OnnxRuntime.Gpu.Linux' : 'Microsoft.ML.OnnxRuntime.Foundry', version: '1.24.3', feed: NUGET_FEED, nightly: false }, { name: 'Microsoft.ML.OnnxRuntimeGenAI.Foundry', version: '0.12.2', feed: NUGET_FEED, nightly: false }, ]; diff --git a/sdk/js/script/install-winml.cjs b/sdk/js/script/install-winml.cjs index b46770ca..833802e7 100644 --- a/sdk/js/script/install-winml.cjs +++ b/sdk/js/script/install-winml.cjs @@ -10,7 +10,7 @@ const { NUGET_FEED, ORT_NIGHTLY_FEED, runInstall } = require('./install-utils.cj const useNightly = process.env.npm_config_nightly === 'true'; const ARTIFACTS = [ - { name: 'Microsoft.AI.Foundry.Local.Core.WinML', version: '0.9.0.8-rc3', feed: ORT_NIGHTLY_FEED, nightly: useNightly }, + { name: 'Microsoft.AI.Foundry.Local.Core.WinML', version: '0.9.0-dev-202603310538-f6efa8d3', feed: ORT_NIGHTLY_FEED, nightly: useNightly }, { name: 'Microsoft.ML.OnnxRuntime.Foundry', version: '1.23.2.3', feed: NUGET_FEED, nightly: false }, { name: 'Microsoft.ML.OnnxRuntimeGenAI.WinML', version: '0.12.2', feed: NUGET_FEED, nightly: false }, ];