onnxruntime/tools/ci_build/github/azure-pipelines/templates/set-python-manylinux-variables-step.yml
Changming Sun 285606108a
Set pythonInterpreter in set-python-manylinux-variables-step.yml (#19105)
### Description
Set pythonInterpreter in set-python-manylinux-variables-step.yml. To fix
a build error:

```
Starting: Set Python manylinux variables
==============================================================================
Task         : Python script
Description  : Run a Python file or inline script
Version      : 0.231.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/python-script
==============================================================================
##[error]Parameter 'toolPath' cannot be null or empty.
Finishing: Set Python manylinux variables
```
The error was because today I deleted a bunch of software from the VM
image. The task might fail if no Python versions are found in
$(Agent.ToolsDirectory).
2024-01-12 07:22:02 -08:00

43 lines
1.3 KiB
YAML

# sets Python manylinux variables
# the Python version is specified with the PythonVersion variable
steps:
- task: PythonScript@0
displayName: 'Set Python manylinux variables'
inputs:
pythonInterpreter: /usr/bin/python3
scriptSource: inline
script: |
version = "$(PythonVersion)"
if version == "3.7":
variables = {
"PythonManylinuxDir": "/opt/python/cp37-cp37m"
}
elif version == "3.8":
variables = {
"PythonManylinuxDir": "/opt/python/cp38-cp38"
}
elif version == "3.9":
variables = {
"PythonManylinuxDir": "/opt/python/cp39-cp39"
}
elif version == "3.10":
variables = {
"PythonManylinuxDir": "/opt/python/cp310-cp310"
}
elif version == "3.11":
variables = {
"PythonManylinuxDir": "/opt/python/cp311-cp311"
}
elif version == "3.12":
variables = {
"PythonManylinuxDir": "/opt/python/cp312-cp312"
}
else:
raise ValueError("Unsupported Python version: '{}'".format(version))
for name, value in variables.items():
print("Setting variable: {} = '{}'".format(name, value))
print("##vso[task.setvariable variable={}]{}".format(name, value))