python - Azure Pipelines - 使用 Poetry 的正确方法

标签 python azure azure-devops continuous-integration azure-pipelines

使用 Azure Pipelines 的 poetry 安装 Python 包依赖项的推荐方法是什么?我看到人们只通过 pip 下载poetry,这是一个很大的禁忌。

- script: |
    python -m pip install -U pip
    pip install poetry
    poetry install
  displayName: Install dependencies

我可以使用curl来下载诗歌

  - script: |
      curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
      export PATH=$PATH:$HOME/.poetry/bin
      poetry install --no-root
    displayName: 'Install dependencies'

但是在后续的每个步骤中,我都必须再次将诗歌添加到 PATH 中......

  - script: |
      curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
      export PATH=$PATH:$HOME/.poetry/bin
      poetry install --no-root
    displayName: 'Install dependencies'

  - script: |
      # export PATH=$PATH:$HOME/.poetry/bin
      poetry run flake8 src
    displayName: 'Linter'

  - script: |
      # export PATH=$PATH:$HOME/.poetry/bin
      poetry add pytest-azurepipelines
      poetry run pytest src
    displayName: 'Tests'

是否有任何正确方式在 Azure Pipelines 中使用诗歌?

最佳答案

与同事咨询了这个问题。他建议执行单独的步骤将 Poetry 添加到 PATH。

  - task: UsePythonVersion@0
    inputs:
      versionSpec: '3.8'
    displayName: 'Use Python 3.8'

  - script: |
      curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
      export PATH=$PATH:$HOME/.poetry/bin
      poetry install --no-root
    displayName: 'Install dependencies'

  - script: echo "##vso[task.prependpath]$HOME/.poetry/bin"
    displayName: Add poetry to PATH

  - script: |
      poetry run flake8 src
    displayName: 'Linter'

  - script: |
      poetry add pytest-azurepipelines
      poetry run pytest src
    displayName: 'Tests'

关于python - Azure Pipelines - 使用 Poetry 的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71423949/

相关文章:

python - tight_layout 失败时如何减少水平子图间距?

azure - 在 Bash 中访问传入的 WebHook JSON 负载 - Azure Pipelines

Azure 虚拟网络 - 证书 CN 名称与传递的值不匹配

azure - 从订阅/资源组继承多个标签

Azure ARM DataFactory InvalidTemplate runAfter 属性无效;范围必须属于同一级别

Powershell 脚本完成但退出并显示错误代码 1

c# - 如何从控制台应用程序使用客户端 api 连接到 TeamFoundationServer (tfs)?

python - 谷歌云应用引擎 : Python2 or Python3? 的最佳实践

python - 删除多索引数据框中具有重复索引的行

python - 为什么这个 Python 脚本不能在 Ubuntu 12.04 中作为启动应用程序运行?