diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a56edcbda..c0d87b28a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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 @@ -98,7 +98,7 @@ jobs: artifactName: '$(pythonVersion)_LINUX_X64' - job: Build_OSX_X64 pool: - vmImage: 'macOS-12' + vmImage: 'macOS-latest' strategy: matrix: Python37V4: @@ -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: diff --git a/pack/Microsoft.Azure.Functions.V4.PythonWorker.nuspec b/pack/Microsoft.Azure.Functions.V4.PythonWorker.nuspec index 4ffc38b50..3426e72b8 100644 --- a/pack/Microsoft.Azure.Functions.V4.PythonWorker.nuspec +++ b/pack/Microsoft.Azure.Functions.V4.PythonWorker.nuspec @@ -22,14 +22,17 @@ + + + diff --git a/pack/scripts/mac_arm64_deps.sh b/pack/scripts/mac_arm64_deps.sh new file mode 100644 index 000000000..13a2315da --- /dev/null +++ b/pack/scripts/mac_arm64_deps.sh @@ -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" \ No newline at end of file diff --git a/pack/templates/macos_64_env_gen.yml b/pack/templates/macos_64_env_gen.yml new file mode 100644 index 000000000..94c2260a1 --- /dev/null +++ b/pack/templates/macos_64_env_gen.yml @@ -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 }} diff --git a/python/prodV4/worker.config.json b/python/prodV4/worker.config.json index 552cecc29..f22d26f45 100644 --- a/python/prodV4/worker.config.json +++ b/python/prodV4/worker.config.json @@ -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", diff --git a/setup.py b/setup.py index bda8b4d96..4a49556b5 100644 --- a/setup.py +++ b/setup.py @@ -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": [