-
Notifications
You must be signed in to change notification settings - Fork 309
Try uv second attempt #2161
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
base: main
Are you sure you want to change the base?
Try uv second attempt #2161
Changes from 18 commits
4313217
f3267b9
fd8a974
f3180ec
bed71a7
2cdc2a2
6dbb16a
d245242
7459c11
9548c6f
2725da0
b6b0427
90c2101
a95337b
469acdd
d82c055
9af0449
a596266
e75d042
06e3129
8136b00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,109 +1,74 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| if [ $# -eq 0 ]; then | ||
| install=false | ||
| install=false | ||
| else | ||
| if [ "$1" = "install" ]; then | ||
| install=true | ||
| else | ||
| echo "Invalid command, supported commands are: 'install'" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [[ "$PYTHON" =~ "python2" ]]; then | ||
| echo "python2 is not supported." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Use the newest version we find | ||
| if [ -z "$PYTHON" ]; then | ||
| for i in 12 11 10; do | ||
| command -v "python3.$i" && PYTHON="python3.$i" &>/dev/null && break | ||
| done | ||
| fi | ||
| if [ -z "$PYTHON" ]; then | ||
| # This would be bizarre, but I suppose possible | ||
| PYTHON=${PYTHON:-"python3"} | ||
| if [ "$1" = "install" ]; then | ||
| install=true | ||
| else | ||
| echo "Invalid command, supported commands are: 'install'" | ||
| exit 1 | ||
| fi | ||
| fi | ||
| echo "Using python: $PYTHON" | ||
|
|
||
| case "$(uname -s)" in | ||
| Linux) | ||
| if command -v lsb_release; then | ||
| OS=$(lsb_release --id --short) | ||
| else | ||
| . /etc/os-release | ||
| OS=$(echo $NAME | tr -d ' ') | ||
| fi | ||
| # rpm/dnf is the default, to reduce repetition in the case statement | ||
| has_pkg="rpm -q --whatprovides" | ||
| install_pkg="sudo dnf install -y" | ||
| . /etc/os-release | ||
| OS="${NAME// /}" | ||
| case "$OS" in | ||
| Ubuntu|Debian|LinuxMint) | ||
| deps=(qemu-utils python3-dev libssl-dev python3-pip python3-wheel python3-venv libev-dev libvirt-dev libffi-dev libyaml-dev build-essential jq curl) | ||
| has_pkg="dpkg -s" | ||
| deps=(qemu-utils python3-dev libssl-dev libev-dev libvirt-dev libffi-dev libyaml-dev pipx build-essential jq curl) | ||
| has_pkg="dpkg -C" | ||
| install_pkg="sudo apt install -y" | ||
| ;; | ||
| RedHatEnterpriseWorkstation|RedHatEnterpriseServer|RedHatEnterprise|CentOS) | ||
| deps=(python39-pip python39-devel mariadb-devel libev-devel libvirt-devel libffi-devel) | ||
| ;; | ||
| CentOSStream) | ||
| PYTHON=python3.12 | ||
| deps=($PYTHON-pip $PYTHON-devel) | ||
| ;; | ||
| AlmaLinux|RockyLinux) | ||
| PYTHON=python3.12 | ||
| deps=($PYTHON-pip $PYTHON-devel libev-devel libvirt-devel libffi-devel) | ||
| ;; | ||
| Fedora|FedoraLinux) | ||
| deps=($PYTHON-pip $PYTHON-devel libev-devel libvirt-devel libffi-devel) | ||
| RedHatEnterpriseWorkstation|RedHatEnterpriseServer|RedHatEnterprise|CentOS|CentOSStream|AlmaLinux|RockyLinux|Fedora|FedoraLinux) | ||
| # Use the newest version we find | ||
| if [ -z "$PYTHON" ]; then | ||
| for i in 13 12 11 10; do | ||
| command -v "python3.$i" > /dev/null && PYTHON="python3.$i" && break | ||
| done | ||
| fi | ||
| if [ -z "$PYTHON" ]; then | ||
| # This would be bizarre, but I suppose possible | ||
| PYTHON=${PYTHON:-"python3"} | ||
| fi | ||
| # rpm/dnf is the default, to reduce repetition in the case statement | ||
| has_pkg="rpm -q --whatprovides" | ||
| install_pkg="sudo dnf install -y" | ||
| deps=(libev-devel libffi-devel libvirt-devel "$PYTHON-devel" pipx) | ||
| ;; | ||
| "openSUSE project"|"SUSE LINUX"|"openSUSE"|"openSUSELeap"|"openSUSETumbleweed") | ||
| PYTHON=python3.12 | ||
| deps=(python312-pip python312-devel python312 libev-devel libvirt-devel libffi-devel) | ||
| PYTHON=${PYTHON:-"python3"} | ||
| deps=("$PYTHON" "$PYTHON-devel" "$PYTHON-pipx" libev-devel libffi-devel libvirt-devel) | ||
| has_pkg="rpm -q --whatprovides" | ||
| install_pkg="sudo zypper install" | ||
|
||
| ;; | ||
| esac | ||
| ;; | ||
|
|
||
| Darwin) | ||
| deps="python libvirt libev libffi" | ||
| deps=(python libvirt libev libffi pipx uv) | ||
| has_pkg="brew list" | ||
| install_pkg="brew install" | ||
| ;; | ||
| esac | ||
| for package in ${deps[@]}; do | ||
| if ! $has_pkg $package &>/dev/null; then | ||
| for package in "${deps[@]}"; do | ||
| if ! $has_pkg "$package" &>/dev/null; then | ||
| # add a space after old values | ||
| missing="${missing:+$missing }$package" | ||
| echo missing=${missing} | ||
| fi | ||
| done | ||
| if [ -n "$missing" ]; then | ||
| echo "$0: missing required packages:" 1>&2 | ||
| echo "$missing" | ||
| if [ "$install" = true ]; then | ||
| echo "Installing missing packages..." | ||
| $install_pkg $missing | ||
| $install_pkg "$missing" | ||
| else | ||
| echo "Please install missing packages or run './bootstrap install'" | ||
| echo "$install_pkg $missing" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| PYTHON_BIN=$(command -v $PYTHON) | ||
| if [ -z $PYTHON_BIN -o ! -e $PYTHON_BIN -o ! -x $PYTHON_BIN ]; then | ||
| echo "Cannot find $PYTHON!" | ||
| exit 1 | ||
| fi | ||
| PYTHON_VER_OUT=$($PYTHON_BIN --version) | ||
|
|
||
| VENV=${VENV:-"./virtualenv"} | ||
| # If the venv was set to use system site-packages, fix that | ||
| if [ -f "$VENV/pyvenv.cfg" ]; then | ||
| sed -i'' -e 's/\(include-system-site-packages\s*=\s*\)true/\1false/g' $VENV/pyvenv.cfg | ||
| fi | ||
|
|
||
| # Attempt to force a UTF-8 locale without forcing English | ||
|
|
@@ -112,50 +77,14 @@ LC_ALL=${LC_ALL:=C} | |
| export LANG="${LANG/.*/}.utf-8" | ||
| export LC_ALL="${LC_ALL/.*/}.utf-8" | ||
|
|
||
| if [ -z "$NO_CLOBBER" ] && \ | ||
| [ ! -e "$VENV/bin/pip" -o ! -e "$VENV/bin/$PYTHON" ] || \ | ||
| [ "${PYTHON_VER_OUT}" != "$($VENV/bin/$PYTHON --version)" ] \ | ||
| ; then | ||
| echo "Deleting existing virtual environment" | ||
| rm -rf virtualenv | ||
| fi | ||
|
|
||
| if [ -z "$NO_CLOBBER" ] || [ ! -e $VENV ]; then | ||
| echo "Creating new venv at $VENV" | ||
| $PYTHON_BIN -m venv $VENV | ||
| fi | ||
|
|
||
| PY_MAJOR=$($VENV/bin/python -c "import sys; print(sys.version_info[0])") | ||
| PY_MINOR=$($VENV/bin/python -c "import sys; print(sys.version_info[1])") | ||
|
|
||
| # Python version check | ||
| if [[ "$PY_MAJOR" -ne 3 || "$PY_MINOR" -lt 10 ]]; then | ||
| echo "Python version should be 3.10 or higher, found $PY_MAJOR.$PY_MINOR" | ||
| exit 1 | ||
| fi | ||
|
|
||
| $VENV/bin/pip install packaging | ||
|
|
||
| if [ -f "$VENV/bin/ansible" ]; then | ||
| uninstall_ansible=$($VENV/bin/python3 -c "import ansible; from packaging.version import parse; print(parse(ansible.__version__) < parse('2.10.0'))") | ||
| if [ "$uninstall_ansible" = "True" ]; then | ||
| $VENV/bin/pip uninstall -y ansible | ||
| fi | ||
| fi | ||
|
|
||
| # First, upgrade pip | ||
| $VENV/bin/pip install --upgrade pip | ||
|
|
||
| # See https://github.com/pypa/pip/issues/8559 | ||
| $VENV/bin/pip install -r requirements.txt --use-pep517 | ||
|
|
||
| # By default, install teuthology in editable mode | ||
| $VENV/bin/pip install ${PIP_INSTALL_FLAGS:---editable '.[test]'} | ||
|
|
||
| # Check to make sure requirements are met | ||
| $VENV/bin/pip check | ||
| [ -z "$NO_CLOBBER" ] && rm -rf virtualenv | ||
| command -v uv > /dev/null || pipx install uv | ||
| command -v uv > /dev/null || pipx ensurepath | ||
| PATH=$PATH:$HOME/.local/bin | ||
| # Create the venv if it does not exist, and install teuthology and dependencies | ||
| uv sync --frozen --all-extras | ||
| # To avoid crashing older dispatchers | ||
| ln -sf .venv virtualenv | ||
|
|
||
| # Install ansible collections | ||
| $VENV/bin/ansible-galaxy install -r requirements.yml | ||
|
|
||
| echo "Bootstrap completed successfully!!!" | ||
| uv run ansible-galaxy install -r requirements.yml | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dpkg -C is ->
-C|--audit [...] Check for broken package(s)
in practice dpkg -C still exits 0 even when the package is missing (it prints “not installed” to stderr). I verified this in the environment: both an installed and a bogus package name lead the bootstrap loop to treat the dependency as present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zmc what did you have in mind when changing to
-sto-C?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I just wanted a quieter
-s, but I will amend this to use-sand drop stdout/err. Good catch!!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or, @kshtsk, if you'd rather just push a small fix to this branch that works as well.