如何使用 Poetry 发布到 Azure Devops PyPI 源?

2024-01-24

我正在尝试设置 Azure Devops 以使用 Poetry 发布到 PyPI 提要。

我了解 Twine 身份验证以及将凭据存储到 Azure Key Vault。但有没有更直接的方法呢?像这样的事情:

- script: |
    source .venv/bin/activate
    poetry build
  displayName: Build wheel
- script: |
    source .venv/bin/activate
    poetry publish -u USER -p PASS
  displayName: Publish wheel

是的。在 Azure DevOps Web 界面中:

  1. 创建新的 PyPI feed(工件 > 新 feed > 创建)。
  2. 创建 PyPI 凭据(连接到源 > Python > 生成 Python 凭据)。
  3. Create secret管道变量命名为username and password并使用 PyPI 凭据进行赋值(管道 > 编辑 > 变量 > 新变量 > 将此值保密 > 确定)。
  4. 更新内容azure-pipelines.ymlCI 文件如下:
trigger:
- master

pool:
  vmImage: ubuntu-latest

steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: 3.7
  displayName: Install Python
- script: |
    python -m pip install -U pip
    pip install poetry
    poetry install
  displayName: Install software
- script: |
    poetry run python -m unittest discover tests/ -v
  displayName: Test software
- script: |
    poetry build
  displayName: Package software
- script: |
    poetry config repositories.azure https://pkgs.dev.azure.com/{your organization}/_packaging/{your feed}/pypi/upload
    poetry config http-basic.azure $(username) $(password)
    poetry publish -r azure
    exit 0
  displayName: Publish software
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 Poetry 发布到 Azure Devops PyPI 源? 的相关文章

随机推荐