Skip to content
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

Azure CLI: Compatibility with Debian bookworm #578

Merged
merged 7 commits into from
Jun 27, 2023

Conversation

joshspicer
Copy link
Member

@joshspicer joshspicer commented Jun 16, 2023

closes #589
related #577

Changes needed to the Azure CLI Feature post Debian bookworm / PEP 668

When azure-cli binaries aren't available from apt, checks if pipx if available in apt and if so, attempts to use that to install the Azure CLI. From the base images I tested, pipx is only available in the bookworm apt repos (and that's the goal for this PR!).

@crazy4pi314
Copy link

Linking #577
I think this is not going to be a great solution long term, as it creates a confusing situation for the user (where are packages getting installed) and is not following the best pratice guidance from the Python Language commitee. Installing Python in a venv is the reccomended path to ensure installs and packages are managed in the right scopes.

Problem tl;dr as show in the linked issue: OS provide Python distros can mix package management with os package managers with pip leading to confustion in where packages are. PEP 668 was published as guidance for how to properly isolate the OS python install, and best pratice for a variety of situations where you might be trying to install Python.

@joshspicer
Copy link
Member Author

@crazy4pi314 In this instance (installing the Azure CLI which need be installed system-wide), what changes would you recommend I make in this PR? There are lots of instances in this repo where we're using pip to install tools globally, so having one good example of how to proceed would be useful.

@crazy4pi314
Copy link

Testing some things now, will make suggestions shortly!

@crazy4pi314
Copy link

crazy4pi314 commented Jun 22, 2023

Ok so for the azure-cli one, is there a need to have the full install of python as well as installing the CLI? If not, I could suggest just using pipx as provided from apt by putting this in install_using_pip where appropriate:

apt-get install pipx
pipx ensurepath
pipx install azure-cli

You can probably get rid of most of the python/pip management code there if it is the case Python is not needed otherwise for the CLI somewhere.

I tested this on "mcr.microsoft.com/devcontainers/base:bookworm" but would be good to try in the pipeline.

Looking now more at the messier Python one!

@crazy4pi314
Copy link

For the python one, I think there is a much more nuanced question there, there are a lot of ways to "install python" and that do different things such that not everyone will be happy. I think that's ok as this is an opnionated feature, and I would think that if I as the user wanted to "install python version x (or latest)" this would install python via wget-ing the appropriate build of python from Python.org, setting up symlinks, and setting up appropriate venvs and path defaults." This is not really at all what the exsisting feature does, it pretty heavily relies on using the system packaged python (the default even) in the ways the PEP is trying to prevent.

The error message itself:

#18 36.77     If you wish to install a non-Debian-packaged Python package,
#18 36.77     create a virtual environment using python3 -m venv path/to/venv.
#18 36.77     Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
#18 36.77     sure you have python3-full installed.

Would suggest that changing install_python to not allow "os-provided" or "system" and install python3-full, then use that to create a venv that then is set as default on path. This is similar to the last option suggested in this blog:

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

I looked at how the Python docker image does it, which always wgets source tars from python.org and then builds.

Idk of a short "fix" here that would have the behaviour I would expect, I would probably pick build from scratch/wget the prebuilt from python.org as default, installing create a venv and disable the "os-provided" option in version selecting (as that is what we are trying to prevent here.)

@joshspicer joshspicer force-pushed the joshspicer/bookworm-fixes branch from 060b057 to 4355158 Compare June 22, 2023 22:44
@joshspicer
Copy link
Member Author

Ok so for the azure-cli one, is there a need to have the full install of python as well as installing the CLI?

One of the dependencies is a version of python: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=script

@joshspicer joshspicer changed the title Compatibility fixes for debian bookworm Azure CLI: Compatibility with Debian bookworm Jun 24, 2023
@joshspicer joshspicer marked this pull request as ready for review June 24, 2023 00:35
@joshspicer joshspicer requested a review from a team as a code owner June 24, 2023 00:35
Copy link
Member

@samruddhikhandale samruddhikhandale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

src/azure-cli/install.sh Outdated Show resolved Hide resolved
Copy link
Member

@samruddhikhandale samruddhikhandale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@joshspicer joshspicer merged commit ccce957 into main Jun 27, 2023
@joshspicer joshspicer deleted the joshspicer/bookworm-fixes branch June 27, 2023 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azure-cli feature fails to install
3 participants