How to publish to an Azure Devops PyPI feed with Poetry?

2024/9/8 8:54:17

I am trying to set up Azure Devops to publish to a PyPI feed with Poetry.

I know about Twine authentication and storing credentials to an Azure Key Vault. But is there any more straightforward method? Something like this:

- script: |source .venv/bin/activatepoetry builddisplayName: Build wheel
- script: |source .venv/bin/activatepoetry publish -u USER -p PASSdisplayName: Publish wheel
Answer

Yes. In the Azure DevOps web interface:

  1. Create a new PyPI feed (Artifacts > New feed > Create).
  2. Create PyPI credentials (Connect to feed > Python > Generate Python credentials).
  3. Create secret pipeline variables named username and password and valued with the PyPI credentials (Pipelines > Edit > Variables > New variable > Keep this value secret > OK).
  4. Update the contents of the azure-pipelines.yml CI file with this:
trigger:
- masterpool:vmImage: ubuntu-lateststeps:
- task: UsePythonVersion@0inputs:versionSpec: 3.7displayName: Install Python
- script: |python -m pip install -U pippip install poetrypoetry installdisplayName: Install software
- script: |poetry run python -m unittest discover tests/ -vdisplayName: Test software
- script: |poetry builddisplayName: Package software
- script: |poetry config repositories.azure https://pkgs.dev.azure.com/{your organization}/_packaging/{your feed}/pypi/uploadpoetry config http-basic.azure $(username) $(password)poetry publish -r azureexit 0displayName: Publish software
https://en.xdnf.cn/q/73058.html

Related Q&A

Python Regex Match Before Character AND Ignore White Space

Im trying to write a regex to match part of a string that comes before / but also ignores any leading or trailing white space within the match.So far Ive got ^[^\/]* which matches everything before the…

Python Twisted integration with Cmd module

I like Pythons Twisted and Cmd. I want to use them together.I got some things working, but so far I havent figured out how to make tab-completion work, because I dont see how to receive tab keypres ev…

Read .pptx file from s3

I try to open a .pptx from Amazon S3 and read it using the python-pptx library. This is the code: from pptx import Presentation import boto3 s3 = boto3.resource(s3)obj=s3.Object(bucket,key) body = obj.…

PIL image display error It looks like the image was moved or renamed

Here is a bit of my code:from PIL import Imageimage = Image.open(fall-foliage-1740841_640.jpg) image.show()The error is when the default photo viewer is started and shows the error "It looks like …

How to delete numpy nan from a list of strings in Python?

I have a list of strings x = [A, B, nan, D]and want to remove the nan.I tried:x = x[~numpy.isnan(x)]But that only works if it contains numbers. How do we solve this for strings in Python 3+?

Pasting data into a pandas dataframe

This is the same question as this question, which is marked as a duplicate of this one. The problem, and the reason Im still asking, is that the solution provided (using pandas.read_clipboard()) curren…

Add graph description under graph in pylab [duplicate]

This question already has answers here:Closed 11 years ago.Possible Duplicate:Is there a way of drawing a caption box in matplotlib Is it possible to add graph description under graph in pylab?Lets s…

Using Python textwrap.shorten for string but with bytes width

Id like to shorten a string using textwrap.shorten or a function like it. The string can potentially have non-ASCII characters. Whats special here is that the maximal width is for the bytes encoding of…

How to create a transparent mask in opencv-python

I have sign (signs with arbitrary shape) images with white background and I want to get an image of the sign with transparent background. I have managed to create a mask and apply it to the image and t…

Variables with dynamic shape TensorFlow

I need to create a matrix in TensorFlow to store some values. The trick is the matrix has to support dynamic shape.I am trying to do the same I would do in numpy: myVar = tf.Variable(tf.zeros((x,y), va…