Artifacts安装Python程序包

Artifacts安装Python程序包

本文介绍了Azure Devops从Docker内部的Azure Artifacts安装Python程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Azure Artifacts安装一个pip软件包作为Docker映像的一部分(使用 Docker @ 2 任务),但是我尝试执行的任何操作均不起作用.

I am trying to install a pip package from Azure Artifacts as part of a Docker image(with Docker@2 task) but whatever I try does not work.

无论我尝试执行什么操作,似乎我在Docker中的 pip 都无法针对Azure Artifacts进行身份验证.我最亲近的是

It looks like my pip inside Docker cannot authenticate against Azure Artifacts whatever I try. Closest I got is with

RUN pip install keyring artifacts-keyring
ENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE true
RUN pip install <> --index-url https://pkgs.dev.azure.com/<>/_packaging/<>/pypi/simple/

但是在我的Azure开发中,我不断获得

but in my Azure devops, i keep getting

ERROR: Could not find a version that satisfies the requirement <> (from versions: none)
ERROR: No matching distribution found for <>

此外-关于此的Azure文档似乎非常差,如果我将 ENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE设置为false ,它会提示我的Azure DevOps管道以交互方式进行身份验证,这不是我想要的.

Also - Azure documentation on this seems to very poor, if I switch ENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE false it prompts my Azure DevOps pipeline to authenticate intercatively which is not what I want.

如何自动安装发布在Azure Artifacts中的Python软件包作为我的Azure Pipeline Docker任务的一部分?

How can I install a Python package published in Azure Artifacts as part of my Azure Pipeline Docker task automatically?

推荐答案

我们可以使用 PipAuthenticate 任务填充 PIP_EXTRA_INDEX_URL 环境变量:

We could use the PipAuthenticate task to populates the PIP_EXTRA_INDEX_URL environment variable:

然后将其传递给构建arg:

Then pass it in the build arg:

arguments: --build-arg INDEX_URL=$(PIP_EXTRA_INDEX_URL)

您可以查看此文档在Docker中使用Azure Pipelines Python工件提要,以了解更多详细信息.

You could check this document Consuming Azure Pipelines Python artifact feeds in Docker for some more details.

希望这会有所帮助.

这篇关于Azure Devops从Docker内部的Azure Artifacts安装Python程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:01