AAfors
AAfors

Reputation: 13

Azure: Installing Python feed packages to Pipeline

I have an Azure Artifacts feed with a Python package called py-data (This is an alias). This can be installed on my local machine from the feed, however, I am trying to install it as a dependency for a build pipeline.

My YAML code looks like the following:

pool:
  vmImage: windows-latest
strategy:
  matrix:
    Python39:
      python.version: '3.9'

steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: '$(python.version)'
  displayName: 'Use Python $(python.version)'

- task: PipAuthenticate@1
  displayName: 'Pip Authenticate'
  inputs:
    artifactFeeds: 'foo-packages'
    onlyAddExtraIndex: true

- script: |
    python -m pip install --upgrade pip
    pip install py-data
    pip install -r requirements.txt
  displayName: 'Install dependencies'

- script: |
    pip install pytest pytest-azurepipelines
    pytest
  displayName: 'pytest'

This does not work and I get the following error:

ERROR: Could not find a version that satisfies the requirement py-data (from versions: none)

The URL that is provided by PipAuthenticate is of the style https://build:***@bdouk.pkgs.visualstudio.com/ which is different to the one provided by the connect to feed in the artefacts tab.

Upvotes: 1

Views: 979

Answers (1)

Meeke
Meeke

Reputation: 26

I was banging my head over this same issue. What solved it for me was to add the name of the project before the name of artifact feed, like so:

- task: PipAuthenticate@1
  displayName: 'Pip Authenticate'
  inputs:
     artifactFeeds: 'YOUR-PROJECT/foo-packages'
     onlyAddExtraIndex: true

This worked, even though the documentation suggests it's not required when the feed is in the same project as the pipeline.

After doing this, the generated URL was the same as the one I got from "connect to feed" in the Artifacts tab, only with the credentials added in front.

Upvotes: 1

Related Questions