-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Python and Pip #45
Comments
Correct me if I am wrong, but this is going to store the value of the The tokens that are obtained are short lived, which is why for the package managers we are supporting so far we have to replace the command like Can Python/Pip be configured to get the token from an environment variable? Where we tell it the name of the variable and it reads the value? The |
ah, I see about the short living token. You are correct that it won't work in the long run. There is an option to do it via run script: #!/bin/bash
if [ -f "${HOME}/ado-auth-helper" ]; then
export ARTIFACTS_ACCESSTOKEN=$(${HOME}/ado-auth-helper get-access-token)
fi
# Read index-url from pip config get
INDEX_URL=$(pip config get global.index-url)
EXPANDED_INDEX_URL=$(eval echo ${INDEX_URL})
if [ -f "${HOME}/ado-auth-helper" ]; then
unset ARTIFACTS_ACCESSTOKEN
fi
# Find the pip executable so we do not run the bash alias again
PIP_EXE=$(which pip)
${PIP_EXE} "$@" -i "${EXPANDED_INDEX_URL}"
EXIT_CODE=$?
unset PIP_EXE
if [ -f "${HOME}/ado-auth-helper" ]; then
unset EXPANDED_INDEX_URL
fi
exit $EXIT_CODE this would require that Pip is configured like this: |
Just so I understand ... now you are storing the name of the environment variable in the configuration but since Pip does not support this you dynamically retrieve and expand the value then set it on the command line when running pip? I still see a couple of problems:
I do not think the first problem can be solved. I also do not think it has to block a solution. It may just be something users need to be aware of |
You are correct in your understanding.
There is potential solution similar to the above run script. There, we would put auth token in a keyring. Run pip command (it can be any command; if it doesn't need auth, then it will not read it from the keyring). Finally, we remove the token from keyring. The problem with this solution is that there is no easy-usable keyring backend implementation. |
I do not have the Python skills for this but looking at the documentation for building a custom keyring backend it looks doable. Wondering if the code for that backend could live in this repository and during install time we configure pip to use it? If configured of course. Presumably it would not even need to store anything and just has to respond to the getPassword or getCredential method with the results of calling the script? |
I quite like the keyring backend idea. I imagine it would be similar to the implementation in https://github.com/microsoft/artifacts-keyring/blob/master/src/artifacts_keyring/plugin.py, but differing in the underlying executable that we call. Is anyone working on this atm? |
Update: Got proof of concept working locally. Keen to get this one reviewed and released. I'll reach out, let's discuss on Teams next week! |
Feel free to add a PR with your PoC. If you explain what it is doing and what needs to be done at install time, I can probably take care of the glue code for the feature to install and set it up etc. It is pretty straightforward so if you want to tackle that too feel free. It is hard to test the full final version but usually you can just create a Codespace and manually do some of the steps the install will do to verify it works. That is how I did it for the other providers. |
@delilahw I published a new version that installs the helper you created. Can you give it a test? I am only testing that the install completes, not the actual usage. To try it you need this:
The installation only happens if it also detects |
@markphip Thanks!! I've just tested it with a config like this: {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11"
},
"ghcr.io/microsoft/codespace-features/artifacts-helper:1": {
"python": true
}
}
} It downloads the wheel successfully but fails to find
|
It would be great to have support for Python/Pip as well.
I did some experiments around it and looks like it is possible to have a script similar to
write-npm.sh
. It could bewrite-pip.sh
:Pip doesn't support providing auth token independent of feed url. It supports keyring, but my understanding that it is impossible to use keyring in dev container in a non-interactive manner. See https://github.com/jaraco/keyring#using-keyring-on-headless-linux-systems-in-a-docker-container
Running pip via
run-pip.sh
could be possible as well. In this case we will need a way to read/obtain feed url. Then we may set the environment variablePIP_INDEX_URL
,The text was updated successfully, but these errors were encountered: