如何使用Azure管道和诗歌发布到PyPI

时间:2019-03-30 20:26:50

标签: python azure-devops python-poetry

我正在尝试将我的Python应用设置为使用天蓝色管道发布到PyPI。我希望能够使用Poetry Publish来实现这一目标。

我了解麻线身份验证以及将证书存储到Azure密钥保管库的知识。有没有更简单的方法?像这样:

    - script: |
        source .venv/bin/activate
        poetry build
      displayName: Build Wheel

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

3 个答案:

答案 0 :(得分:1)

是的。在Azure DevOps Web界面中:

  1. 创建新的PyPI提要(工件>新建提要>创建)。
  2. 创建PyPI凭据(连接到供稿> Python>生成Python凭据)。
  3. 创建名为usernamepassword secret 管道变量,并使用PyPI凭据对其进行赋值(管道>编辑>变量>新变量>将此值保密>确定)。
  4. 使用以下命令更新azure-pipelines.yml CI文件的内容:
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

答案 1 :(得分:0)

您可能想要使用 $(System.AccessToken) 变量:

...
else if (event.type == sf::Event::Resized) {
    float w = static_cast<float>(event.size.width);
    float h = static_cast<float>(event.size.height);
    view.setSize({w , h});
    view.setCenter({w/2.f , h/2.f}); // <----- !
    window.setView(view);
    board.createBoard({ event.size.width, event.size.height });
}
...

答案 2 :(得分:0)

如何使用 poetry 构建并使用 twine 发布,以便我们可以利用 Azure 自己的 TwineAuthenticate

steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: '$(python.version)'
    displayName: 'Use Python $(python.version)'

  - script: |
      python -m pip install --upgrade pip
      pip install poetry
      pip install twine
      poetry install --no-dev
    displayName: 'Install dependencies'

  - script: |
      poetry build
    displayName: 'Build package'

  - task: TwineAuthenticate@1
    inputs:
      artifactFeed: 'repo-name/feed-name'

  - script: |
      twine upload -r repo-name --config-file $(PYPIRC_PATH) dist/*.whl
    displayName: Upload package to Azure Artifact