I have created a PoC Azure pipeline to create a package in a feed, as below:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
displayName: 'Deploy Python 3.7'
- script: |
python -m pip install --upgrade pip
pip install twine
displayName: 'Install dependencies'
- script: |
python setup.py sdist
displayName: 'Package creation'
- task: TwineAuthenticate@1
inputs:
artifactFeed: 'Project/Feed'
displayName: 'Set Artifact Authentiation'
- script: 'twine upload -r Feed --config-file $(PYPIRC_PATH) dist/*'
displayName: 'Publish Artifact'
I am trying to do a pip install in a docker instance on my laptop (not Azure) using the following:
FROM python:3.7.9-buster
ADD . /package-consumer/
RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb
RUN apt-get update && apt-get install -y apt-transport-https && apt-get install -y dotnet-sdk-5.0
RUN pip install keyring artifacts-keyring
RUN pip install --index-url=https://pkgs.dev.azure.com/Org/Project/_packaging/Feed/pypi/simple/ Package
CMD cd /package-consumer && python Consume/UsePackages.py
And as expected I get
[Minimal] [CredentialProvider]DeviceFlow: https://pkgs.dev.azure.com/causewayltd/Mobile/_packaging/Mobile/pypi/simple/
[Minimal] [CredentialProvider]ATTENTION: User interaction required.
**********************************************************************
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code **** to authenticate.
**********************************************************************
[Error] [CredentialProvider]Device flow authentication failed. User was presented with device flow, but didn't react within 90 seconds.
I tried various settings such as ENV ARTIFACTS_KEYRING_NONINTERACTIVE_MODE true
etc. All to no avail.
Is it even possible to pip install an Azure package in a non Azure docker container. If so, how? Any help appreciated.
PS - I have scoured the web but can't seem to get a definitive answer how to achieve the above. Thanks
Found a solution (prob a bit hacky).. generate a token in Azure https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page and copy the token.
And in the Dockerfile ensure
pip install keyring artifacts-keyring
is not there.Then simply
Where <azure_pat> is the copied token.