Use "uv" for building virtual environments

Change-Id: I5e24e82e6347d351cac71255904b44aa558d449b
(cherry picked from commit 4e2d8ac7928cb95aadbd0587230837281827976a)
diff --git a/images/barbican/Dockerfile b/images/barbican/Dockerfile
index 09543bd..7bb2b02 100644
--- a/images/barbican/Dockerfile
+++ b/images/barbican/Dockerfile
@@ -6,8 +6,8 @@
 ARG BARBICAN_GIT_REF=b5841df387e5ab38caf173950a1d98ab37a51453
 ADD --keep-git-dir=true https://opendev.org/openstack/barbican.git#${BARBICAN_GIT_REF} /src/barbican
 RUN git -C /src/barbican fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/barbican \
         pykmip
diff --git a/images/cinder/Dockerfile b/images/cinder/Dockerfile
index 540b674..4cc880e 100644
--- a/images/cinder/Dockerfile
+++ b/images/cinder/Dockerfile
@@ -8,8 +8,8 @@
 RUN git -C /src/cinder fetch --unshallow
 COPY patches/cinder /patches/cinder
 RUN git -C /src/cinder apply --verbose /patches/cinder/*
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/cinder \
         purestorage \
diff --git a/images/designate/Dockerfile b/images/designate/Dockerfile
index 0cb3d72..5747ecc 100644
--- a/images/designate/Dockerfile
+++ b/images/designate/Dockerfile
@@ -8,8 +8,8 @@
 RUN git -C /src/designate fetch --unshallow
 COPY patches/designate /patches/designate
 RUN git -C /src/designate apply --verbose /patches/designate/*
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/designate
 EOF
diff --git a/images/glance/Dockerfile b/images/glance/Dockerfile
index 9dc50cc..cd3cc08 100644
--- a/images/glance/Dockerfile
+++ b/images/glance/Dockerfile
@@ -8,8 +8,8 @@
 RUN git -C /src/glance fetch --unshallow
 ADD --keep-git-dir=true https://opendev.org/openstack/glance_store.git#stable/2024.2 /src/glance_store
 RUN git -C /src/glance_store fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/glance \
         /src/glance_store[cinder] \
diff --git a/images/heat/Dockerfile b/images/heat/Dockerfile
index 9730a4c..818b3a1 100644
--- a/images/heat/Dockerfile
+++ b/images/heat/Dockerfile
@@ -6,8 +6,8 @@
 ARG HEAT_GIT_REF=64bdbb9bc66c38760989dd7bb2574ccc14069872
 ADD --keep-git-dir=true https://opendev.org/openstack/heat.git#${HEAT_GIT_REF} /src/heat
 RUN git -C /src/heat fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/heat
 EOF
diff --git a/images/horizon/Dockerfile b/images/horizon/Dockerfile
index a52b11c..b25a967 100644
--- a/images/horizon/Dockerfile
+++ b/images/horizon/Dockerfile
@@ -25,8 +25,8 @@
 RUN git -C /src/horizon apply --verbose /patches/horizon/*
 COPY patches/magnum-ui /patches/magnum-ui
 RUN git -C /src/magnum-ui apply --verbose /patches/magnum-ui/*
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/designate-dashboard \
         /src/heat-dashboard \
diff --git a/images/ironic/Dockerfile b/images/ironic/Dockerfile
index a278715..a106bc4 100644
--- a/images/ironic/Dockerfile
+++ b/images/ironic/Dockerfile
@@ -6,8 +6,8 @@
 ARG IRONIC_GIT_REF=5aa51d6985d25acd6abfb161c62c66facc20a6ca
 ADD --keep-git-dir=true https://opendev.org/openstack/ironic.git#${IRONIC_GIT_REF} /src/ironic
 RUN git -C /src/ironic fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/ironic \
         python-dracclient \
diff --git a/images/keystone/Dockerfile b/images/keystone/Dockerfile
index 02562f2..f6e9774 100644
--- a/images/keystone/Dockerfile
+++ b/images/keystone/Dockerfile
@@ -6,8 +6,8 @@
 ARG KEYSTONE_GIT_REF=47891f4ae8fd7876e5a7657f58c32c371feeddc3
 ADD --keep-git-dir=true https://opendev.org/openstack/keystone.git#${KEYSTONE_GIT_REF} /src/keystone
 RUN git -C /src/keystone fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/keystone[ldap] \
         keystone-keycloak-backend==0.2.0
diff --git a/images/magnum/Dockerfile b/images/magnum/Dockerfile
index 78cc0a4..0d152ab 100644
--- a/images/magnum/Dockerfile
+++ b/images/magnum/Dockerfile
@@ -14,8 +14,8 @@
 ARG MAGNUM_GIT_REF=db197e08a09da93062fc4222180051dadfc0f0d8
 ADD --keep-git-dir=true https://opendev.org/openstack/magnum.git#${MAGNUM_GIT_REF} /src/magnum
 RUN git -C /src/magnum fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/magnum \
         magnum-cluster-api==0.26.2
diff --git a/images/manila/Dockerfile b/images/manila/Dockerfile
index 78f2ce8..69fbd7e 100644
--- a/images/manila/Dockerfile
+++ b/images/manila/Dockerfile
@@ -6,8 +6,8 @@
 ARG MANILA_GIT_REF=09f3ab0a229362c00bb55f704cfeae43bccd3c8d
 ADD --keep-git-dir=true https://opendev.org/openstack/manila.git#${MANILA_GIT_REF} /src/manila
 RUN git -C /src/manila fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/manila
 EOF
diff --git a/images/neutron/Dockerfile b/images/neutron/Dockerfile
index 68c7198..2860393 100644
--- a/images/neutron/Dockerfile
+++ b/images/neutron/Dockerfile
@@ -20,8 +20,8 @@
 ARG LOG_PASER_GIT_REF=9bc923c1294864ec709c538ba5c309065ef710d5
 ADD --keep-git-dir=true https://github.com/vexxhost/neutron-ovn-network-logging-parser.git#${LOG_PASER_GIT_REF} /src/neutron-ovn-network-logging-parser
 RUN git -C /src/neutron-ovn-network-logging-parser fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/neutron \
         /src/neutron-vpnaas \
diff --git a/images/nova/Dockerfile b/images/nova/Dockerfile
index 50b9c82..1b0096f 100644
--- a/images/nova/Dockerfile
+++ b/images/nova/Dockerfile
@@ -9,8 +9,8 @@
 ARG SCHEDULER_FILTERS_GIT_REF=77ed1c2ca70f4166a6d0995c7d3d90822f0ca6c0
 ADD --keep-git-dir=true https://github.com/vexxhost/nova-scheduler-filters.git#${SCHEDULER_FILTERS_GIT_REF} /src/nova-scheduler-filters
 RUN git -C /src/nova-scheduler-filters fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/nova \
         /src/nova-scheduler-filters \
diff --git a/images/octavia/Dockerfile b/images/octavia/Dockerfile
index 089637d..6d34896 100644
--- a/images/octavia/Dockerfile
+++ b/images/octavia/Dockerfile
@@ -8,8 +8,8 @@
 RUN git -C /src/octavia fetch --unshallow
 ADD --keep-git-dir=true https://opendev.org/openstack/ovn-octavia-provider.git#stable/2024.2 /src/ovn-octavia-provider
 RUN git -C /src/ovn-octavia-provider fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/octavia \
         /src/ovn-octavia-provider
diff --git a/images/openstack-venv-builder/Dockerfile b/images/openstack-venv-builder/Dockerfile
index e3d9672..3984f8a 100644
--- a/images/openstack-venv-builder/Dockerfile
+++ b/images/openstack-venv-builder/Dockerfile
@@ -24,18 +24,19 @@
     lsb-release \
     openssh-client \
     python3 \
-    python3-dev \
-    python3-pip \
-    python3-venv
+    python3-dev
 apt-get clean
 rm -rf /var/lib/apt/lists/*
 EOF
-RUN python3 -m venv --upgrade-deps --system-site-packages /var/lib/openstack
+COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
 COPY --from=requirements --link /upper-constraints.txt /upper-constraints.txt
-RUN pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv venv --system-site-packages /var/lib/openstack
+uv pip install \
     --constraint /upper-constraints.txt \
         cryptography \
         pymysql \
         python-binary-memcached \
         python-memcached \
         uwsgi
+EOF
diff --git a/images/placement/Dockerfile b/images/placement/Dockerfile
index 7dd8101..2c62dc7 100644
--- a/images/placement/Dockerfile
+++ b/images/placement/Dockerfile
@@ -6,8 +6,8 @@
 ARG PLACEMENT_GIT_REF=828b2559a1b3c0b59c543e851c6ea3efb1baae20
 ADD --keep-git-dir=true https://opendev.org/openstack/placement.git#${PLACEMENT_GIT_REF} /src/placement
 RUN git -C /src/placement fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/placement
 EOF
diff --git a/images/python-openstackclient/Dockerfile b/images/python-openstackclient/Dockerfile
index 0e6de70..d318636 100644
--- a/images/python-openstackclient/Dockerfile
+++ b/images/python-openstackclient/Dockerfile
@@ -3,8 +3,8 @@
 # Atmosphere-Rebuild-Time: 2025-02-20T21:42:46Z
 
 FROM openstack-venv-builder AS build
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         osc-placement \
         python-barbicanclient \
diff --git a/images/staffeln/Dockerfile b/images/staffeln/Dockerfile
index 6d22f91..82b34b1 100644
--- a/images/staffeln/Dockerfile
+++ b/images/staffeln/Dockerfile
@@ -6,8 +6,8 @@
 ARG STAFFELN_GIT_REF=v2.2.3
 ADD --keep-git-dir=true https://github.com/vexxhost/staffeln.git#${STAFFELN_GIT_REF} /src/staffeln
 RUN git -C /src/staffeln fetch --unshallow
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/staffeln
 EOF
diff --git a/images/tempest/Dockerfile b/images/tempest/Dockerfile
index 85a29f0..4b8f5bf 100644
--- a/images/tempest/Dockerfile
+++ b/images/tempest/Dockerfile
@@ -26,8 +26,8 @@
 ADD --keep-git-dir=true https://opendev.org/openstack/octavia-tempest-plugin.git#master /src/octavia-tempest-plugin
 RUN git -C /src/octavia-tempest-plugin fetch --unshallow
 ADD https://releases.openstack.org/constraints/upper/master /upper-constraints.txt
-RUN --mount=type=cache,mode=0755,target=/root/.cache/pip,sharing=private <<EOF bash -xe
-pip3 install \
+RUN --mount=type=cache,target=/root/.cache/uv <<EOF bash -xe
+uv pip install \
     --constraint /upper-constraints.txt \
         /src/tempest \
         /src/barbican-tempest-plugin \
diff --git a/releasenotes/notes/use-uv-for-venv-ec400e1d456a8c5f.yaml b/releasenotes/notes/use-uv-for-venv-ec400e1d456a8c5f.yaml
new file mode 100644
index 0000000..b8ff8a8
--- /dev/null
+++ b/releasenotes/notes/use-uv-for-venv-ec400e1d456a8c5f.yaml
@@ -0,0 +1,4 @@
+---
+other:
+  - The images now use the `uv` tool to create the virtual environment which
+    is faster and more reliable than the previous method.