Azure DevOps Services
Use this task to select the Python 版本,and optionally add it to PATH.
無
如果在 Agent.ToolsDirectory 中找不到 Python 版本,This task will fail. 可在 Microsoft Managed proxies found available on Python 版本.
備注
x86 和 x64 版本的 Python 在 Microsoft 托管的 Windows available on proxy,但在 Linux 或 macOS Not available on proxy.
YAML復制
# Use Python version
# Use the specified version of Python from the tool cache, optionally adding it to the PATH
- task: [email protected]
inputs:
#versionSpec: '3.x'
#addToPath: true
#architecture: 'x64' # Options: x86, x64 (this argument applies only on Windows agents)
versionSpec
3.x
addToPath
true
architecture
x64
從任務的 0.150 版起,Version specifications will also be accepted pypy2
或 pypy3
接受.
如果任務成功完成,The task will contain the output of the variables Python 安裝的目錄:
使用“添加到 PATH”After running this task, python
Commands in subsequent scripts will be used for the highest available version of the interpreter that matches the version specification and architecture.
在 Microsoft 托管的 Ubuntu 和 macOS Installed on the image Python version follows PEP 394 中定義的類似 Unix The system symbolic link structure of. 例如,對於 Python 3.7, python3.7
is the actual interpreter. python3
symlink to this interpreter,並且 python
is a symlink to that symlink.
在 Microsoft 托管的 Windows 映像上,The interpreter is just.python
對於 Microsoft 托管的代理,x86 僅在 Windows 上受支持. 這是因為 Windows 可以使用 WoW64 子系統為 x86 The architecture runs the compiled executable. 托管 Ubuntu 和托管 macOS 運行 64 位操作系統,僅運行 64 位 Python.
This task is GitHub 上的開源任務. Feedback and suggestions are welcome.
Instructions for tool installers and examples,請參閱 工具安裝程序.
至少需要一個代理to run a build or publish.
請查看Troubleshoot build and publish issues.
請查看代理池.
This issue can be resolved by adding a trusted root certificate. environment variable NODE_EXTRA_CA_CERTS=file
add to build agent,You can also add task variables in the pipeline NODE.EXTRA.CA.CERTS=file
. More detailed information about this variable,請參閱 Node.js 文檔. Instructions for setting variables in the pipeline,請參閱Set variables in the pipeline.
所需的 Python The version must be added to the tools cache on the self-hosted proxy,so that the task uses it. 通常,The tool cache is located in the proxy's directory _work/_tool
,can also be set by an environment variable AGENT_TOOLSDIRECTORY
重寫路徑. 在該目錄下,根據 Python Version creates the following directory structure:
復制
$AGENT_TOOLSDIRECTORY/
Python/
{version number}/
{platform}/
{tool files}
{platform}.complete
應 version number
遵循以下格式 1.2.3
. 應 platform
為 x86
或 x64
. 應 tool files
for decompressed Python 版本文件. 應 {platform}.complete
為 0 字節文件, x86.complete
如下所示, x64.complete
and just means that the tool is properly installed in the cache.
as a complete concrete example,下面是 Python 3.6.4 for x64 how the full download of the looks in the tool cache:
復制
$AGENT_TOOLSDIRECTORY/
Python/
3.6.4/
x64/
{tool files}
x64.complete
More details on tool caching,請參閱 此處.
In order to make the script in Microsoft Works fine on managed proxies,We recommend following something like Unix 的系統上 PEP 394 symlink structure.
另請注意,Python 的可嵌入 ZIP 版本需要 for installed modules(包括 pip
)進行額外配置. 如果可能,我們建議使用 complete installer 來獲取 pip
兼容的 Python 安裝.
In the generated or release pipe run Python 腳本
使用 pip 設置身份驗證,so that it can be executed in the pipeline pip 命令.
設置 twine 到 Python source authentication,so that it can be published in the pipeline Python 包.
如何使用 Azure Pipelines 發布 Python 包
Publish and use via the command line interface Python 包
使用 Azure PipelinesAutomatically build and test Python 應用
在 macOS、Linux 或 Windows 上運行 Bash 腳本
For the source andAzure Artifacts Maven Repository provides credentials.
顯示較少選項