Skip to content

Commit ff97a66

Browse files
authored
Updating the dependencies and build pipelines to support Arm64 macOS (#1267)
* Updating the protobuf dependency and build pipelines for ARM64 mac * Moving to use macOS-latest * Creating a mechanism to generate packages * Converting GeneratePackage to a Variable * Explicit Generate Package check
1 parent cd16cf0 commit ff97a66

6 files changed

+77
-13
lines changed

azure-pipelines.yml

+24-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trigger:
77

88
variables:
99
patchBuildNumberForDev: $(Build.BuildNumber)
10-
PROD_V4_WORKER_PY : 'python/prodV4/worker.py'
10+
PROD_V4_WORKER_PY: 'python/prodV4/worker.py'
1111

1212
jobs:
1313
- job: Build_WINDOWS_X64
@@ -98,7 +98,7 @@ jobs:
9898
artifactName: '$(pythonVersion)_LINUX_X64'
9999
- job: Build_OSX_X64
100100
pool:
101-
vmImage: 'macOS-12'
101+
vmImage: 'macOS-latest'
102102
strategy:
103103
matrix:
104104
Python37V4:
@@ -122,10 +122,30 @@ jobs:
122122
pythonVersion: '$(pythonVersion)'
123123
workerPath: '$(workerPath)'
124124
artifactName: '$(pythonVersion)_OSX_X64'
125+
- job: Build_OSX_ARM64
126+
pool:
127+
vmImage: 'macOS-latest'
128+
strategy:
129+
matrix:
130+
Python39V4:
131+
pythonVersion: '3.9'
132+
workerPath: $(PROD_V4_WORKER_PY)
133+
Python310V4:
134+
pythonVersion: '3.10'
135+
workerPath: $(PROD_V4_WORKER_PY)
136+
Python311V4:
137+
pythonVersion: '3.11'
138+
workerPath: $(PROD_V4_WORKER_PY)
139+
steps:
140+
- template: pack/templates/macos_64_env_gen.yml
141+
parameters:
142+
pythonVersion: '$(pythonVersion)'
143+
workerPath: '$(workerPath)'
144+
artifactName: '$(pythonVersion)_OSX_ARM64'
125145

126146
- job: PackageWorkers
127-
dependsOn: ['Build_WINDOWS_X64', 'Build_WINDOWS_X86', 'Build_LINUX_X64', 'Build_OSX_X64']
128-
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq(variables['Build.SourceBranch'], 'refs/heads/dev'))
147+
dependsOn: ['Build_WINDOWS_X64', 'Build_WINDOWS_X86', 'Build_LINUX_X64', 'Build_OSX_X64', 'Build_OSX_ARM64']
148+
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['GeneratePackage'], True))
129149
pool:
130150
name: '1ES-Hosted-AzFunc'
131151
demands:

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

+3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222
<file src="..\3.9_WINDOWS_X86\**" target="tools\3.9\WINDOWS\X86" />
2323
<file src="..\3.9_LINUX_X64\**" target="tools\3.9\LINUX\X64" />
2424
<file src="..\3.9_OSX_X64\**" target="tools\3.9\OSX\X64" />
25+
<file src="..\3.9_OSX_X64\**" target="tools\3.9\OSX\Arm64" />
2526
<file src="..\3.10_WINDOWS_X64\**" target="tools\3.10\WINDOWS\X64" />
2627
<file src="..\3.10_WINDOWS_X86\**" target="tools\3.10\WINDOWS\X86" />
2728
<file src="..\3.10_LINUX_X64\**" target="tools\3.10\LINUX\X64" />
2829
<file src="..\3.10_OSX_X64\**" target="tools\3.10\OSX\X64" />
30+
<file src="..\3.10_OSX_X64\**" target="tools\3.10\OSX\Arm64" />
2931
<file src="..\3.11_WINDOWS_X64\**" target="tools\3.11\WINDOWS\X64" />
3032
<file src="..\3.11_WINDOWS_X86\**" target="tools\3.11\WINDOWS\X86" />
3133
<file src="..\3.11_LINUX_X64\**" target="tools\3.11\LINUX\X64" />
3234
<file src="..\3.11_OSX_X64\**" target="tools\3.11\OSX\X64" />
35+
<file src="..\3.11_OSX_X64\**" target="tools\3.11\OSX\Arm64" />
3336
<file src="..\python\prodV4\worker.config.json" target="tools" />
3437
<file src="Microsoft.Azure.Functions.PythonWorker.targets" target="build" />
3538
<file src="..\_manifest\manifest.json" target="SBOM\manifest.json" />

pack/scripts/mac_arm64_deps.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
python -m venv .env
4+
source .env/bin/activate
5+
python -m pip install --upgrade pip==23.0
6+
7+
python -m pip install .
8+
9+
python -m pip install . --no-compile --target "$BUILD_SOURCESDIRECTORY/deps"

pack/templates/macos_64_env_gen.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
parameters:
2+
pythonVersion: ''
3+
artifactName: ''
4+
workerPath: ''
5+
6+
steps:
7+
- task: UsePythonVersion@0
8+
inputs:
9+
versionSpec: ${{ parameters.pythonVersion }}
10+
addToPath: true
11+
- task: ShellScript@2
12+
inputs:
13+
disableAutoCwd: true
14+
scriptPath: 'pack/scripts/mac_arm64_deps.sh'
15+
- task: CopyFiles@2
16+
inputs:
17+
contents: |
18+
${{ parameters.workerPath }}
19+
targetFolder: '$(Build.ArtifactStagingDirectory)'
20+
flattenFolders: true
21+
- task: CopyFiles@2
22+
inputs:
23+
sourceFolder: '$(Build.SourcesDirectory)/deps'
24+
contents: |
25+
**
26+
!grpc_tools/**/*
27+
!grpcio_tools*/*
28+
targetFolder: '$(Build.ArtifactStagingDirectory)'
29+
- task: PublishBuildArtifacts@1
30+
inputs:
31+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
32+
artifactName: ${{ parameters.artifactName }}

python/prodV4/worker.config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"description":{
33
"language":"python",
4-
"defaultRuntimeVersion":"3.9",
4+
"defaultRuntimeVersion":"3.10",
55
"supportedOperatingSystems":["LINUX", "OSX", "WINDOWS"],
66
"supportedRuntimeVersions":["3.7", "3.8", "3.9", "3.10", "3.11"],
7-
"supportedArchitectures":["X64", "X86"],
7+
"supportedArchitectures":["X64", "X86", "Arm64"],
88
"extensions":[".py"],
99
"defaultExecutablePath":"python",
1010
"defaultWorkerPath":"%FUNCTIONS_WORKER_RUNTIME_VERSION%/{os}/{architecture}/worker.py",

setup.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@
110110
"python-dateutil~=2.8.2"
111111
]
112112

113-
if sys.version_info[:3] < (3, 11, 0):
114-
INSTALL_REQUIRES.append("protobuf~=3.19.3")
115-
INSTALL_REQUIRES.append("grpcio-tools~=1.43.0")
116-
INSTALL_REQUIRES.append("grpcio~=1.43.0")
113+
if sys.version_info[:3] < (3, 9, 0):
114+
INSTALL_REQUIRES.extend(
115+
("protobuf~=3.19.3", "grpcio-tools~=1.43.0", "grpcio~=1.43.0")
116+
)
117117
else:
118-
INSTALL_REQUIRES.append("protobuf~=4.22.0")
119-
INSTALL_REQUIRES.append("grpcio-tools~=1.51.3")
120-
INSTALL_REQUIRES.append("grpcio~=1.51.3")
118+
INSTALL_REQUIRES.extend(
119+
("protobuf~=4.22.0", "grpcio-tools~=1.54.2", "grpcio~=1.54.2")
120+
)
121121

122122
EXTRA_REQUIRES = {
123123
"dev": [

0 commit comments

Comments
 (0)