Skip to content

Commit f569369

Browse files
authored
feat: support python 3.14 (#1766)
* support python 3.14 * tentative * update nuspec * sync with ADO * comments * rc nix deps * clean up scripts * rename artifact * pyproject miss * extra space
1 parent 5da04c1 commit f569369

File tree

10 files changed

+320
-17
lines changed

10 files changed

+320
-17
lines changed

eng/pack/Microsoft.Azure.Functions.V4.PythonWorker.nuspec

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
<file src="..\..\3.13_OSX_X64\**" target="tools\3.13\OSX\X64" />
4949
<file src="..\..\3.13_OSX_ARM64\**" target="tools\3.13\OSX\Arm64" />
5050
<file src="..\..\3.13_LINUX_ARM64\**" target="tools\3.13\LINUX\Arm64" />
51+
<file src="..\..\3.14_WINDOWS_X64\**" target="tools\3.14\WINDOWS\X64" />
52+
<file src="..\..\3.14_WINDOWS_X86\**" target="tools\3.14\WINDOWS\X86" />
53+
<file src="..\..\3.14_LINUX_X64\**" target="tools\3.14\LINUX\X64" />
54+
<file src="..\..\3.14_OSX_X64\**" target="tools\3.14\OSX\X64" />
55+
<file src="..\..\3.14_OSX_ARM64\**" target="tools\3.14\OSX\Arm64" />
5156
<file src="..\..\workers\python\prodV4\worker.config.json" target="tools" />
5257
<file src="Microsoft.Azure.Functions.PythonWorker.targets" target="build" />
5358
<file src="..\..\_manifest\spdx_2.2\manifest.spdx.json" target="SBOM\manifest.spdx.json" />
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
echo "=== Upgrading pip and installing build dependencies ==="
4+
python -m pip install --upgrade pip setuptools wheel cython
5+
6+
echo "=== Cloning gRPC repo ==="
7+
rm -rf grpc
8+
git clone --recursive https://github.com/grpc/grpc
9+
10+
echo "=== Building grpcio wheel from source ==="
11+
cd grpc
12+
git submodule update --init --recursive
13+
export GRPC_PYTHON_BUILD_WITH_CYTHON=1
14+
15+
# Build the wheel into dist/
16+
python -m pip wheel . -w dist
17+
18+
# Log contents of dist
19+
echo "=== Checking dist directory ==="
20+
if [ -d dist ]; then
21+
ls -lh dist
22+
else
23+
echo "dist/ directory not found!"
24+
fi
25+
26+
# Log and install grpcio
27+
GRPC_WHEEL=$(ls dist/grpcio-*.whl | head -n 1)
28+
echo "Built grpcio wheel: $(basename "$GRPC_WHEEL")"
29+
echo "=== Install grpcio wheel $(basename "$GRPC_WHEEL") into root ==="
30+
python -m pip install "$GRPC_WHEEL"
31+
32+
cd ..
33+
34+
# Change back to project root
35+
cd workers
36+
37+
echo "=== Install other deps into root ==="
38+
python -m pip install .
39+
python -m pip install grpcio-tools==1.70.0
40+
41+
echo "=== Installing grpcio into deps/ ==="
42+
python -m pip install "$GRPC_WHEEL" --target "$BUILD_SOURCESDIRECTORY/deps"
43+
44+
echo "=== Installing other deps into deps/ ==="
45+
python -m pip install --upgrade pip setuptools wheel cython --target "$BUILD_SOURCESDIRECTORY/deps"
46+
python -m pip install . azure-functions --no-compile --target "$BUILD_SOURCESDIRECTORY/deps" --find-links ../grpc/dist
47+
python -m pip install grpcio-tools==1.70.0 --no-compile --target "$BUILD_SOURCESDIRECTORY/deps" --find-links ../grpc/dist
48+
49+
echo "=== Install invoke and build protos ==="
50+
python -m pip install invoke
51+
cd tests
52+
python -m invoke -c test_setup build-protos
53+
54+
echo "=== Copying .artifactignore ==="
55+
cd ..
56+
cp .artifactignore "$BUILD_SOURCESDIRECTORY/deps"
57+
58+
echo "=== Copying protos ==="
59+
version_minor=$(echo $1 | cut -d '.' -f 2)
60+
if [[ $version_minor -lt 13 ]]; then
61+
cp -r azure_functions_worker/protos "$BUILD_SOURCESDIRECTORY/deps/azure_functions_worker"
62+
else
63+
cp -r proxy_worker/protos "$BUILD_SOURCESDIRECTORY/deps/proxy_worker"
64+
fi

eng/pack/scripts/rc_nix_deps.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
python -m venv .env
4+
source .env/bin/activate
5+
python -m pip install --upgrade pip
6+
7+
cd workers
8+
python -m pip install .
9+
python -m pip install grpcio~=1.70.0
10+
python -m pip install grpcio-tools~=1.70.0
11+
12+
python -m pip install . --no-compile --target "$BUILD_SOURCESDIRECTORY/deps"
13+
python -m pip install grpcio~=1.70.0 --no-compile --target "$BUILD_SOURCESDIRECTORY/deps"
14+
python -m pip install grpcio-tools~=1.70.0 --no-compile --target "$BUILD_SOURCESDIRECTORY/deps"
15+
16+
python -m pip install invoke
17+
cd tests
18+
python -m invoke -c test_setup build-protos
19+
20+
cd ..
21+
cp .artifactignore "$BUILD_SOURCESDIRECTORY/deps"
22+
23+
version_minor=$(echo $1 | cut -d '.' -f 2)
24+
if [[ $version_minor -lt 13 ]]; then
25+
cp -r azure_functions_worker/protos "$BUILD_SOURCESDIRECTORY/deps/azure_functions_worker"
26+
else
27+
cp -r proxy_worker/protos "$BUILD_SOURCESDIRECTORY/deps/proxy_worker"
28+
fi

eng/pack/scripts/rc_win_deps.ps1

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
param (
2+
[string]$pythonVersion
3+
)
4+
$versionParts = $pythonVersion -split '\.' # Splitting by dot
5+
$versionMinor = [int]$versionParts[1]
6+
7+
Write-Host "=== Upgrading pip and installing build dependencies ==="
8+
python -m pip install --upgrade pip setuptools wheel cython
9+
10+
Write-Host "=== Cloning gRPC repo ==="
11+
if (Test-Path grpc) {
12+
Remove-Item -Recurse -Force grpc
13+
}
14+
git clone --recursive https://github.com/grpc/grpc
15+
16+
Write-Host "=== Building grpcio from source ==="
17+
Set-Location grpc
18+
$env:GRPC_PYTHON_BUILD_WITH_CYTHON = "1"
19+
20+
# Build the wheel into dist/
21+
python -m pip wheel . -w dist
22+
23+
# Log contents of dist
24+
Write-Host "=== Checking dist directory ==="
25+
if (Test-Path dist) {
26+
Get-ChildItem dist
27+
} else {
28+
Write-Host "dist/ directory not found!"
29+
}
30+
31+
# Log and install grpc
32+
$grpcWheel = Get-ChildItem dist\grpcio-*.whl | Select-Object -First 1
33+
Write-Host "Built grpcio wheel: $($grpcWheel.Name)"
34+
Write-Host "=== Install grpcio wheel $($grpcWheel.Name) into root ==="
35+
$grpcWheel = Get-ChildItem dist\grpcio-*.whl | Select-Object -First 1
36+
python -m pip install $grpcWheel.FullName
37+
38+
cd ..
39+
40+
# Change back to project root
41+
Set-Location workers
42+
43+
Write-Host "=== Install other deps into root ==="
44+
python -m pip install .
45+
python -m pip install grpcio-tools==1.70.0
46+
47+
$depsPath = Join-Path -Path $env:BUILD_SOURCESDIRECTORY -ChildPath "deps"
48+
49+
# Install both grpc wheels into deps
50+
Write-Host "=== Installing grpcio into deps/ ==="
51+
python -m pip install $grpcWheel.FullName --target $depsPath
52+
53+
Write-Host "=== Installing other deps into deps/ ==="
54+
python -m pip install --upgrade pip setuptools wheel cython --target $depsPath
55+
python -m pip install . azure-functions --no-compile --target $depsPath --find-links ..\grpc\dist
56+
python -m pip install grpcio-tools==1.70.0 --no-compile --target $depsPath --find-links ..\grpc\dist
57+
58+
Write-Host "=== Install invoke and build protos ==="
59+
python -m pip install invoke
60+
cd tests
61+
python -m invoke -c test_setup build-protos
62+
63+
Write-Host "=== Copying .artifactignore ==="
64+
cd ..
65+
Copy-Item -Path ".artifactignore" -Destination $depsPath.ToString()
66+
67+
Write-Host "=== Copying protos ==="
68+
if ($versionMinor -lt 13) {
69+
$protosPath = Join-Path -Path $depsPath -ChildPath "azure_functions_worker/protos"
70+
Copy-Item -Path "azure_functions_worker/protos/*" -Destination $protosPath.ToString() -Recurse -Force
71+
} else {
72+
$protosPath = Join-Path -Path $depsPath -ChildPath "proxy_worker/protos"
73+
Copy-Item -Path "proxy_worker/protos/*" -Destination $protosPath.ToString() -Recurse -Force
74+
}

eng/pack/templates/macos_64_env_gen.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ steps:
77
- task: UsePythonVersion@0
88
inputs:
99
versionSpec: ${{ parameters.pythonVersion }}
10+
allowUnstable: true
1011
addToPath: true
1112
- powershell: |
1213
# Parse the Python minor version
@@ -22,6 +23,16 @@ steps:
2223
Write-Host "Minor version: $PY_MINOR"
2324
Write-Host "##vso[task.setvariable variable=minorVersion;]$PY_MINOR"
2425
26+
# Detect if this is an RC build
27+
if ($PY_VER -match "rc") {
28+
Write-Host "RC version detected"
29+
Write-Host "##vso[task.setvariable variable=isRC;]true"
30+
}
31+
else {
32+
Write-Host "Stable version detected"
33+
Write-Host "##vso[task.setvariable variable=isRC;]false"
34+
}
35+
2536
# Set build-related variables based on Python minor version
2637
if( $PY_MINOR -ge 13 )
2738
{
@@ -45,7 +56,15 @@ steps:
4556
disableAutoCwd: true
4657
scriptPath: 'eng/pack/scripts/mac_arm64_deps.sh'
4758
args: '${{ parameters.pythonVersion }}'
48-
displayName: 'Install Dependencies'
59+
displayName: 'Install dependencies'
60+
condition: eq(variables['isRC'], 'false')
61+
- task: ShellScript@2
62+
inputs:
63+
disableAutoCwd: true
64+
scriptPath: 'eng/pack/scripts/rc_mac_arm64_deps.sh'
65+
args: '${{ parameters.pythonVersion }}'
66+
displayName: 'Build dependencies from source'
67+
condition: eq(variables['isRC'], 'true')
4968
- bash: |
5069
pip install pip-audit
5170
cd workers
@@ -161,6 +180,14 @@ steps:
161180
!werkzeug/debug/shared/debugger.js
162181
!azure_functions_worker/**
163182
!dateutil/**
183+
!Cython/**
184+
!__pycache__/**
185+
!bin/**
186+
!cython.py
187+
!pip/**
188+
!pyximport/**
189+
!typing_extensions.py
190+
!wheel/**
164191
targetFolder: '$(Build.ArtifactStagingDirectory)'
165192
condition: eq(variables['proxyWorker'], true)
166193
displayName: 'Copy proxy_worker files'

eng/pack/templates/nix_env_gen.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ steps:
77
- task: UsePythonVersion@0
88
inputs:
99
versionSpec: ${{ parameters.pythonVersion }}
10+
allowUnstable: true
1011
addToPath: true
1112
- powershell: |
1213
# Parse the Python minor version
@@ -22,6 +23,16 @@ steps:
2223
Write-Host "Minor version: $PY_MINOR"
2324
Write-Host "##vso[task.setvariable variable=minorVersion;]$PY_MINOR"
2425
26+
# Detect if this is an RC build
27+
if ($PY_VER -match "rc") {
28+
Write-Host "RC version detected"
29+
Write-Host "##vso[task.setvariable variable=isRC;]true"
30+
}
31+
else {
32+
Write-Host "Stable version detected"
33+
Write-Host "##vso[task.setvariable variable=isRC;]false"
34+
}
35+
2536
# Set build-related variables based on Python minor version
2637
if( $PY_MINOR -ge 13 )
2738
{
@@ -46,6 +57,14 @@ steps:
4657
scriptPath: 'eng/pack/scripts/nix_deps.sh'
4758
args: '${{ parameters.pythonVersion }}'
4859
displayName: 'Install Dependencies'
60+
condition: eq(variables['isRC'], 'false')
61+
- task: ShellScript@2
62+
inputs:
63+
disableAutoCwd: true
64+
scriptPath: 'eng/pack/scripts/rc_nix_deps.sh'
65+
args: '${{ parameters.pythonVersion }}'
66+
displayName: 'Build dependencies from source'
67+
condition: eq(variables['isRC'], 'true')
4968
- bash: |
5069
pip install pip-audit
5170
cd workers

eng/pack/templates/win_env_gen.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ steps:
77
- task: UsePythonVersion@0
88
inputs:
99
versionSpec: ${{ parameters.pythonVersion }}
10+
allowUnstable: true
1011
architecture: ${{ parameters.architecture }}
1112
addToPath: true
1213
- powershell: |
@@ -23,6 +24,16 @@ steps:
2324
Write-Host "Minor version: $PY_MINOR"
2425
Write-Host "##vso[task.setvariable variable=minorVersion;]$PY_MINOR"
2526
27+
# Detect if this is an RC build
28+
if ($PY_VER -match "rc") {
29+
Write-Host "RC version detected"
30+
Write-Host "##vso[task.setvariable variable=isRC;]true"
31+
}
32+
else {
33+
Write-Host "Stable version detected"
34+
Write-Host "##vso[task.setvariable variable=isRC;]false"
35+
}
36+
2637
# Set build-related variables based on Python minor version
2738
if( $PY_MINOR -ge 13 )
2839
{
@@ -45,6 +56,14 @@ steps:
4556
inputs:
4657
filePath: 'eng\pack\scripts\win_deps.ps1'
4758
arguments: '${{ parameters.pythonVersion }}'
59+
displayName: 'Install dependencies'
60+
condition: eq(variables['isRC'], 'false')
61+
- task: PowerShell@2
62+
inputs:
63+
filePath: 'eng\pack\scripts\rc_win_deps.ps1'
64+
arguments: '${{ parameters.pythonVersion }}'
65+
displayName: 'Build dependencies from source'
66+
condition: eq(variables['isRC'], 'true')
4867
- bash: |
4968
pip install pip-audit
5069
cd workers
@@ -160,6 +179,14 @@ steps:
160179
!werkzeug\debug\shared\debugger.js
161180
!dateutil\**
162181
!azure_functions_worker\**
182+
!Cython\**
183+
!__pycache__\**
184+
!bin\**
185+
!cython.py
186+
!pip\**
187+
!pyximport\**
188+
!typing_extensions.py
189+
!wheel\**
163190
targetFolder: '$(Build.ArtifactStagingDirectory)'
164191
condition: eq(variables['proxyWorker'], true)
165192
displayName: 'Copy proxy_worker files'

0 commit comments

Comments
 (0)