程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Use the Python version task

編輯:Python

Azure DevOps Services

Use this task to select the Python 版本,and optionally add it to PATH.

需求

先決條件

  • side-by-side version installed Microsoft 托管代理 ,或者配置了 Agent.ToolsDirectory self-hosted proxy (請參閱 常見問題解答) .

如果在 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 代碼片段

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
版本規范(所需的) Version range or to be used Python the exact version of the version.
默認值:303.xaddToPath
添加到 PATH(必需) whether the retrieved Python version appended to PATH 環境變量,Make it available in subsequent tasks or scripts,without using output variables.
默認值:30truearchitecture
體系結構(需要) Python the target architecture of the interpreter (x86、x64) . x86 僅在 Windows 上受支持.
默認值:30x64

從任務的 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.

常見問題解答

Where can I learn more about the tool installer?

Instructions for tool installers and examples,請參閱 工具安裝程序.

Do I need to use a proxy??

至少需要一個代理to run a build or publish.

我遇到了問題. How to troubleshoot it?

請查看Troubleshoot build and publish issues.

I can't choose the default proxy pool,Unable to queue build or publish. 如何修復此問題?

請查看代理池.

我的 NuGet Push task failed,出現“錯誤: 無法獲取本地頒發者證書”錯誤. 如何解決此問題?

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.

How to configure a self-hosted proxy to use this task?

所需的 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 安裝.


  • Python 腳本任務 - Azure Pipelines

    In the generated or release pipe run Python 腳本

  • Python Pip 身份驗證 - Azure Pipelines

    使用 pip 設置身份驗證,so that it can be executed in the pipeline pip 命令.

  • Python Twine upload authentication - Azure Pipelines

    設置 twine 到 Python source authentication,so that it can be published in the pipeline Python 包.

  • 發布 Python 包 - Azure Pipelines

    如何使用 Azure Pipelines 發布 Python 包

  • 從 CLI Publish and use packages - Azure Artifacts

    Publish and use via the command line interface Python 包

  • 生成和測試 Python 應用 - Azure Pipelines

    使用 Azure PipelinesAutomatically build and test Python 應用

  • Bash 任務 - Azure Pipelines

    在 macOS、Linux 或 Windows 上運行 Bash 腳本

  • Maven 對任務 (Run the program to authenticate) - Azure Pipelines

    For the source andAzure Artifacts Maven Repository provides credentials.

顯示較少選項

 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved