简体   繁体   中英

Publishing packages to Azure DeveOps Artifacts using Python-Poetry

The background

I've seen this answer, How to Publish to PyPI with Azure-Pipelines and Poetry however, where the credentials are supposedly generated, I don't see that same option when I go to Connect to Feed > Python . All I see is pip and twine , both of which show how to do unauthenticated pushes.

I have an Azure DevOps Artifacts Python Feed setup where I am the administrator to it. I wanted to use poetry to publish or push the package I am working on into that Feed. However, when prompted for my credentials, I use my email, and password I use to login, but I don't think these are correct. I get a 401 Unauthorized. So here is the steps that I am doing

I created the project

poetry new phil_hello_world --src

I then added some boiler plate code in src/phil_hello_world/__init__.py

__version__ = '0.1.0'


def hello_world():
"""Hello World Function
"""
print('Hello, World!')

Then I was able to build and install the package and use it in IDLE and some other scripts.

poetry build

The problem

So, where this comes to the problem is getting my Azure DevOps Python Artifact Feed setup properly. They recommend using pip or twine, but I'm trying to use this, so bear with me.

First, I setup the repostiory so Poetry knows about it. We're going to do a local configuration.

poetry config repostiories.azure-python-feed https://pkgs.dev.azure.com/myOrg/Project/_packaging/azure-python-feed/pypi/upload

Then I tried just pushing the package up using:

poetry publish -r azure-python-feed --build

I then got a 401 Unauthorized error.

So, I tried to use my login information by doing:

poetry config http-basic.azure-python-feed ${USER_EMAIL} ${USER_LOGIN_PASS}

buuuuut, I still get 401 Unauthorized. Am I doing something wrong? I did make sure to add the recommended packages listed in the Connect Me pop-out.

poetry add twine keyring artifacts-keyring
poetry install

To narrow down the issue, you may try the following items:

  1. Try to create a new PAT with Full access , and then try it again.
  2. Try to run command poetry publish -u $(username) -p $(password) ...

The $(username) can be anything, except blank. Remember to also use the -r option to define your repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM