[英]Publishing packages to Azure DeveOps Artifacts using Python-Poetry
[英]Publishing python package into azure artifacts
由於糟糕的文檔,我很難將我的 Python Package 上傳到我的內部Azure
Twine 身份驗證成功,但無法上傳到 feed,因為它一直在詢問用戶名!
我的設置正確嗎? 我需要在不提供用戶名和密碼的情況下對發布進行自我驗證
工具:
Azure步驟:
- task: TwineAuthenticate@1
inputs:
artifactFeed: feedName
displayName: Twine Authenticate
- script: |
twine upload -r feedName --config-file $(System.DefaultWorkingDirectory)\.pypirc dist/*.whl
displayName: Publish Package1
PyPirc 文件:
[distutils]
Index-servers =
feedName
[feedName]
Repository = https://<host>/tfs/***-Collection/_packaging/feedName/pypi/upload
開始:Twine Authenticate
=======================================================================
Task : Python twine upload authenticate....
=======================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
Adding authentication to configuration for registry Neon
Successfully added auth for 1 internal feed and 0 external endpoint.
Finishing: Twine Authenticate
開始:發布 Package
Uploading distributions to
https://******/tfs/****-Collection/_packaging/****/pypi/upload
INFO dist\***_test_framework-0.1.0-py3-none-any.whl (1.2 KB)
INFO Querying keyring for username
WARNING Error getting username from keyring
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\twine\auth.py", line 59, in
get_username_from_keyring
creds = keyring.get_credential(system, None)
File "C:\Python310\lib\site-packages\keyring\core.py", line 72, in
get_credential
return get_keyring().get_credential(service_name, username)
File "C:\Python310\lib\site-packages\keyring\backends\chainer.py",
line 71, in get_credential
credential = keyring.get_credential(service, username)
File "C:\Python310\lib\site-packages\artifacts_keyring\__init__.py",
line 58, in get_credential
username, password = provider.get_credentials(service)
Traceback (most recent call last):
File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python310\lib\runpy.py", line 86, in _run_code
File "C:\Python310\lib\site-packages\artifacts_keyring\plugin.py",
line 67, in get_credentials
username, password =
self._get_credentials_from_credential_provider(url, is_retry=False)
File "C:\Python310\lib\site-packages\artifacts_keyring\plugin.py",
line 124, in _get_credentials_from_credential_provider
raise RuntimeError("Failed to get credentials: process with PID
{pid} exited with code {code}; additional error message: {error}"
RuntimeError: Failed to get credentials: process with PID 164 exited
with code 2; additional error message:
exec(code, run_globals)
File "C:\Python310\lib\site-packages\twine\__main__.py", line 51, in <module>
sys.exit(main())
File "C:\Python310\lib\site-packages\twine\__main__.py", line 33, in main
error = cli.dispatch(sys.argv[1:])
File "C:\Python310\lib\site-packages\twine\cli.py", line 123, in dispatch
return main(args.args)
File "C:\Python310\lib\site-packages\twine\commands\upload.py", line 198, in main
return upload(upload_settings, parsed_args.dists)
File "C:\Python310\lib\site-packages\twine\commands\upload.py", line 127, in upload
repository = upload_settings.create_repository()
File "C:\Python310\lib\site-packages\twine\settings.py", line 329, in create_repository
self.username,
File "C:\Python310\lib\site-packages\twine\settings.py", line 131, in username
return cast(Optional[str], self.auth.username)
File "C:\Python310\lib\site-packages\twine\auth.py", line 34, in username
return utils.get_userpass_value(
File "C:\Python310\lib\site-packages\twine\utils.py", line 248, in get_userpass_value
value = prompt_strategy()
File "C:\Python310\lib\site-packages\twine\auth.py", line 85, in username_from_keyring_or_prompt
return self.prompt("username", input)
File "C:\Python310\lib\site-packages\twine\auth.py", line 96, in prompt
return how(f"Enter your {what}: ")
EOFError: EOF when reading a line
##[error]PowerShell exited with code '1'.
我已經做了一個測試,它工作正常:
項目 Scope 供稿:
.yml 文件
trigger:
- none
variables:
- name: PYPIRC_PATH
value: .pypirc
steps:
- task: CmdLine@2
inputs:
script: |
pip install wheel
pip install twine
- task: CmdLine@2
inputs:
script: 'python setup.py bdist_wheel'
- task: TwineAuthenticate@1
inputs:
artifactFeed: '<Project Name>/<Feed Name>'
- task: CmdLine@2
inputs:
script: 'python -m twine upload -r <Feed Name> --config-file $(PYPIRC_PATH) dist/*.whl'
.pypirc
[distutils]
Index-servers =
<Organization Name>
[<Organization Name>]
Repository = https://pkgs.dev.azure.com/<Organization Name>/_packaging/<Feed Name>/pypi/upload
組織 Scope 供稿:
.yml 文件
trigger:
- none
variables:
- name: PYPIRC_PATH
value: .pypirc
steps:
- task: CmdLine@2
inputs:
script: |
pip install wheel
pip install twine
- task: CmdLine@2
inputs:
script: 'python setup.py bdist_wheel'
- task: TwineAuthenticate@1
inputs:
artifactFeed: '<Organization Scope Feed Name>'
- task: CmdLine@2
inputs:
script: 'python -m twine upload -r <Organization Scope Feed Name> --config-file $(PYPIRC_PATH) dist/*.whl'
.pypirc
[distutils]
Index-servers =
<Organization Name>
[<Organization Name>]
Repository = https://pkgs.dev.azure.com/<Organization Name>/_packaging/<Organization Scope Feed Name>/pypi/upload
請參考這份官方文檔:
嘗試在您的 twine 上傳步驟中插入 $(PYPIRC_PATH),此文件將由 Twine_Authenticate 任務自動生成
例子:
任務:PowerShell@2
輸入:
目標類型:'內聯'
腳本:C:\Python310\python -m twine upload -r <feed_name> --config-file $(PYPIRC_PATH) dist/*.whl --non-interactive --skip-existing --verbose
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.