Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/build-python-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build Python SDK

on:
workflow_call:
inputs:
version:
required: true
type: string
useWinML:
required: false
type: boolean
default: false
platform:
required: false
type: string
default: 'windows'

permissions:
contents: read

jobs:
build:
runs-on: ${{ inputs.platform }}-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
clean: true

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

# Needed to download Foundry Local Core from Azure Artifacts
- name: Setup .NET SDK for NuGet authentication
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
env:
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }}

# Clone test-data-shared from Azure DevOps (models for integration tests)
- name: Checkout test-data-shared from Azure DevOps
shell: pwsh
working-directory: ${{ github.workspace }}/..
run: |
$pat = "${{ secrets.AZURE_DEVOPS_PAT }}"
$encodedPat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))

git config --global http.https://dev.azure.com.extraheader "AUTHORIZATION: Basic $encodedPat"

git lfs install
git clone --depth 1 https://dev.azure.com/microsoft/windows.ai.toolkit/_git/test-data-shared test-data-shared

Write-Host "Clone completed successfully to ${{ github.workspace }}/../test-data-shared"

- name: Checkout specific commit in test-data-shared
shell: pwsh
working-directory: ${{ github.workspace }}/../test-data-shared
run: |
git checkout 231f820fe285145b7ea4a449b112c1228ce66a41
if ($LASTEXITCODE -ne 0) {
Write-Error "Git checkout failed."
exit 1
}

- name: Install dependencies
working-directory: sdk_v2/python
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
python -m pip install -e .

- name: Download native binaries (WinML)
if: ${{ inputs.useWinML == true }}
working-directory: sdk_v2/python
run: foundry-local-install --winml

- name: Download native binaries (Standard)
if: ${{ inputs.useWinML == false }}
working-directory: sdk_v2/python
run: foundry-local-install

- name: Set package version
shell: pwsh
working-directory: sdk_v2/python
run: |
$versionFile = "src/version.py"
$content = Get-Content $versionFile -Raw
$content = $content -replace '__version__\s*=\s*"[^"]*"', "__version__ = `"${{ inputs.version }}`""
Set-Content -Path $versionFile -Value $content
Write-Host "Updated version to ${{ inputs.version }}"

- name: Run tests
working-directory: sdk_v2/python
run: python -m pytest test/ -v --junitxml=test-results.xml

- name: Build wheel
working-directory: sdk_v2/python
run: python -m build --wheel --outdir dist/

- name: Upload Python packages
uses: actions/upload-artifact@v4
with:
name: python-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}
path: sdk_v2/python/dist/*

- name: Upload flcore logs
uses: actions/upload-artifact@v4
if: always()
with:
name: python-sdk-${{ inputs.platform }}${{ inputs.useWinML == true && '-winml' || '' }}-logs
path: sdk_v2/python/logs/**
22 changes: 21 additions & 1 deletion .github/workflows/foundry-local-sdk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
version: '0.9.0.${{ github.run_number }}'
platform: 'windows'
secrets: inherit
build-python-windows:
uses: ./.github/workflows/build-python-steps.yml
with:
version: '0.9.0.${{ github.run_number }}'
platform: 'windows'
secrets: inherit

build-cs-windows-WinML:
uses: ./.github/workflows/build-cs-steps.yml
Expand All @@ -44,6 +50,13 @@ jobs:
platform: 'windows'
useWinML: true
secrets: inherit
build-python-windows-WinML:
uses: ./.github/workflows/build-python-steps.yml
with:
version: '0.9.0.${{ github.run_number }}'
platform: 'windows'
useWinML: true
secrets: inherit

build-cs-macos:
uses: ./.github/workflows/build-cs-steps.yml
Expand All @@ -56,4 +69,11 @@ jobs:
with:
version: '0.9.0.${{ github.run_number }}'
platform: 'macos'
secrets: inherit
secrets: inherit
build-python-macos:
uses: ./.github/workflows/build-python-steps.yml
with:
version: '0.9.0.${{ github.run_number }}'
platform: 'macos'
secrets: inherit

20 changes: 20 additions & 0 deletions sdk_v2/python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Native binaries downloaded from NuGet (per-platform)
packages/

# Build / egg info
*.egg-info/
dist/
build/
*.whl
*.tar.gz
__pycache__/

# Logs
logs/

# IDE
.vscode/
.idea/

# pytest
.pytest_cache/
21 changes: 21 additions & 0 deletions sdk_v2/python/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading