pythonazureazure-pipelinesazure-devops-servertwine

Publishing python package into azure artifacts


Due to poor documentation I'm suffering alot to upload my Python Package to my internal Azure Artifacts: I have followed exactly like this

Twine authenticate was successful however unable to upload to feed as it keeps asking username!

Is my setup correct? I need to self authenticate the publish without providing username and password

Tools:

Azure steps:

    - 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 file:

[distutils]
Index-servers =
  feedName

[feedName]
Repository = https://<host>/tfs/***-Collection/_packaging/feedName/pypi/upload

Starting: 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

Starting: Publish 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'.

enter image description here


Solution

  • Try inserting $(PYPIRC_PATH) on your twine upload step, this file will be auto-generated by the Twine_Authenticate task

    Example: