[英]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.