Skip to content

Updating the dependencies and build pipelines to support Arm64 macOS #1267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 5, 2023
Merged
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
28 changes: 24 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trigger:

variables:
patchBuildNumberForDev: $(Build.BuildNumber)
PROD_V4_WORKER_PY : 'python/prodV4/worker.py'
PROD_V4_WORKER_PY: 'python/prodV4/worker.py'

jobs:
- job: Build_WINDOWS_X64
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
artifactName: '$(pythonVersion)_LINUX_X64'
- job: Build_OSX_X64
pool:
vmImage: 'macOS-12'
vmImage: 'macOS-latest'
strategy:
matrix:
Python37V4:
Expand All @@ -122,10 +122,30 @@ jobs:
pythonVersion: '$(pythonVersion)'
workerPath: '$(workerPath)'
artifactName: '$(pythonVersion)_OSX_X64'
- job: Build_OSX_ARM64
pool:
vmImage: 'macOS-latest'
strategy:
matrix:
Python39V4:
pythonVersion: '3.9'
workerPath: $(PROD_V4_WORKER_PY)
Python310V4:
pythonVersion: '3.10'
workerPath: $(PROD_V4_WORKER_PY)
Python311V4:
pythonVersion: '3.11'
workerPath: $(PROD_V4_WORKER_PY)
steps:
- template: pack/templates/macos_64_env_gen.yml
parameters:
pythonVersion: '$(pythonVersion)'
workerPath: '$(workerPath)'
artifactName: '$(pythonVersion)_OSX_ARM64'

- job: PackageWorkers
dependsOn: ['Build_WINDOWS_X64', 'Build_WINDOWS_X86', 'Build_LINUX_X64', 'Build_OSX_X64']
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq(variables['Build.SourceBranch'], 'refs/heads/dev'))
dependsOn: ['Build_WINDOWS_X64', 'Build_WINDOWS_X86', 'Build_LINUX_X64', 'Build_OSX_X64', 'Build_OSX_ARM64']
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['GeneratePackage'], True))
pool:
name: '1ES-Hosted-AzFunc'
demands:
Expand Down
3 changes: 3 additions & 0 deletions pack/Microsoft.Azure.Functions.V4.PythonWorker.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@
<file src="..\3.9_WINDOWS_X86\**" target="tools\3.9\WINDOWS\X86" />
<file src="..\3.9_LINUX_X64\**" target="tools\3.9\LINUX\X64" />
<file src="..\3.9_OSX_X64\**" target="tools\3.9\OSX\X64" />
<file src="..\3.9_OSX_X64\**" target="tools\3.9\OSX\Arm64" />
<file src="..\3.10_WINDOWS_X64\**" target="tools\3.10\WINDOWS\X64" />
<file src="..\3.10_WINDOWS_X86\**" target="tools\3.10\WINDOWS\X86" />
<file src="..\3.10_LINUX_X64\**" target="tools\3.10\LINUX\X64" />
<file src="..\3.10_OSX_X64\**" target="tools\3.10\OSX\X64" />
<file src="..\3.10_OSX_X64\**" target="tools\3.10\OSX\Arm64" />
<file src="..\3.11_WINDOWS_X64\**" target="tools\3.11\WINDOWS\X64" />
<file src="..\3.11_WINDOWS_X86\**" target="tools\3.11\WINDOWS\X86" />
<file src="..\3.11_LINUX_X64\**" target="tools\3.11\LINUX\X64" />
<file src="..\3.11_OSX_X64\**" target="tools\3.11\OSX\X64" />
<file src="..\3.11_OSX_X64\**" target="tools\3.11\OSX\Arm64" />
<file src="..\python\prodV4\worker.config.json" target="tools" />
<file src="Microsoft.Azure.Functions.PythonWorker.targets" target="build" />
<file src="..\_manifest\manifest.json" target="SBOM\manifest.json" />
Expand Down
9 changes: 9 additions & 0 deletions pack/scripts/mac_arm64_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

python -m venv .env
source .env/bin/activate
python -m pip install --upgrade pip==23.0

python -m pip install .

python -m pip install . --no-compile --target "$BUILD_SOURCESDIRECTORY/deps"
32 changes: 32 additions & 0 deletions pack/templates/macos_64_env_gen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
parameters:
pythonVersion: ''
artifactName: ''
workerPath: ''

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: ${{ parameters.pythonVersion }}
addToPath: true
- task: ShellScript@2
inputs:
disableAutoCwd: true
scriptPath: 'pack/scripts/mac_arm64_deps.sh'
- task: CopyFiles@2
inputs:
contents: |
${{ parameters.workerPath }}
targetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)/deps'
contents: |
**
!grpc_tools/**/*
!grpcio_tools*/*
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: ${{ parameters.artifactName }}
4 changes: 2 additions & 2 deletions python/prodV4/worker.config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"description":{
"language":"python",
"defaultRuntimeVersion":"3.9",
"defaultRuntimeVersion":"3.10",
"supportedOperatingSystems":["LINUX", "OSX", "WINDOWS"],
"supportedRuntimeVersions":["3.7", "3.8", "3.9", "3.10", "3.11"],
"supportedArchitectures":["X64", "X86"],
"supportedArchitectures":["X64", "X86", "Arm64"],
"extensions":[".py"],
"defaultExecutablePath":"python",
"defaultWorkerPath":"%FUNCTIONS_WORKER_RUNTIME_VERSION%/{os}/{architecture}/worker.py",
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@
"python-dateutil~=2.8.2"
]

if sys.version_info[:3] < (3, 11, 0):
INSTALL_REQUIRES.append("protobuf~=3.19.3")
INSTALL_REQUIRES.append("grpcio-tools~=1.43.0")
INSTALL_REQUIRES.append("grpcio~=1.43.0")
if sys.version_info[:3] < (3, 9, 0):
INSTALL_REQUIRES.extend(
("protobuf~=3.19.3", "grpcio-tools~=1.43.0", "grpcio~=1.43.0")
)
else:
INSTALL_REQUIRES.append("protobuf~=4.22.0")
INSTALL_REQUIRES.append("grpcio-tools~=1.51.3")
INSTALL_REQUIRES.append("grpcio~=1.51.3")
INSTALL_REQUIRES.extend(
("protobuf~=4.22.0", "grpcio-tools~=1.54.2", "grpcio~=1.54.2")
)

EXTRA_REQUIRES = {
"dev": [
Expand Down