Error while uploading python package with Azure Pipelines

Viewed 588

I am trying to use Azure Pipelines to build and submit the package to Azure Artifacts feed. The azure-pipeline file:

- script: |
    pip install wheel
    pip install twine
  displayName: 'Install wheel and twine'

- script: |
    python setup.py bdist_wheel
  displayName: 'Build package'
    
- task: TwineAuthenticate@1
  displayName: 'Twine Authenticate'
  inputs:
    artifactFeed: 'PythonPackages'

- script: |
    cat $(PYPIRC_PATH)
    python -m twine upload -r PythonPackages --verbose --config-file $(PYPIRC_PATH) dist/*.whl
  displayName: 'Publish package'

But I am getting the following error:

Uploading nxgeometry-0.1-py3-none-any.whl

  0%|          | 0.00/3.90k [00:00<?, ?B/s]
100%|██████████| 3.90k/3.90k [00:00<00:00, 4.12kB/s]
Content received from server:
{"$id":"1","innerException":null,"message":"The URL '#' is invalid.","typeName":"Microsoft.VisualStudio.Services.Packaging.Shared.WebApi.Exceptions.InvalidPackageException, Microsoft.VisualStudio.Services.Packaging.Shared.WebApi","typeKey":"InvalidPackageException","errorCode":0,"eventId":3000}
HTTPError: 400 Bad Request from https://pkgs.dev.azure.com/MyOrganization/_packaging/PythonPackages/pypi/upload
Bad Request - The URL '#' is invalid. (DevOps Activity ID: 6E1BE784-A98A-4052-BC7F-B4E4DB7231F0)
##[error]Bash exited with code '1'.
Finishing: Publish package

Any ideas?

1 Answers

In your setup.py , set the url to the Azure DevOps link of the repository you are trying to publish from. The error must be due to the url in your setup.py being different from the url of the repository.

E.g

setup(
    name='omega',
    packages=['omega'],
    description='Omega package for shared functions',
    version='0.1',
    url='https://dev.azure.com/<organization-name>/<project-name>/_git/<repository-name>',
    author='Bond, James Bond',
    author_email='bond@mi6.secret',
    keywords=['pip','omega']
)
Related