Skip to content

Commit eca28fa

Browse files
authored
feat: add uv to python build images (#181)
* feat: add uv to python>=3.10 build images * fix: use pip to install rather than script * nit: install uv in 3.8/3.9 * test: add tests for 3.8/3.9 for uv
1 parent 569b814 commit eca28fa

File tree

8 files changed

+51
-16
lines changed

8 files changed

+51
-16
lines changed

build-image-src/Dockerfile-python310

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ ENV LANG=en_US.UTF-8
5050
# Python for it to be picked up during `sam build`
5151
RUN pip3 install wheel==0.45.1
5252

53+
# Install uv
54+
RUN pip3 install uv==0.9.22
55+
5356
COPY ATTRIBUTION.txt /
5457

5558
# Compatible with initial base image

build-image-src/Dockerfile-python311

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ ENV LANG=en_US.UTF-8
5050
# Python for it to be picked up during `sam build`
5151
RUN pip3 install wheel==0.45.1
5252

53+
# Install uv
54+
RUN pip3 install uv==0.9.22
55+
5356
COPY ATTRIBUTION.txt /
5457

5558
# Compatible with initial base image

build-image-src/Dockerfile-python312

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ ENV LANG=en_US.UTF-8
5151
# Python for it to be picked up during `sam build`
5252
RUN pip3 install wheel==0.45.1 setuptools
5353

54+
# Install uv
55+
RUN pip3 install uv==0.9.22
56+
5457
COPY ATTRIBUTION.txt /
5558

5659
# Compatible with initial base image

build-image-src/Dockerfile-python313

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ ENV LANG=en_US.UTF-8
5151
# Python for it to be picked up during `sam build`
5252
RUN pip3 install wheel==0.45.1 setuptools
5353

54+
# Install uv
55+
RUN pip3 install uv==0.9.22
56+
5457
COPY ATTRIBUTION.txt /
5558

5659
# Compatible with initial base image

build-image-src/Dockerfile-python314

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ ENV LANG=en_US.UTF-8
5151
# Python for it to be picked up during `sam build`
5252
RUN pip3 install wheel==0.45.1 setuptools
5353

54+
# Install uv
55+
RUN pip3 install uv==0.9.22
56+
5457
COPY ATTRIBUTION.txt /
5558

5659
# Compatible with initial base image

build-image-src/Dockerfile-python38

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ ENV LANG=en_US.UTF-8
5050
# Python for it to be picked up during `sam build`
5151
RUN pip3 install wheel==0.45.1
5252

53+
# Install uv
54+
RUN pip3 install uv==0.9.22
55+
5356
COPY ATTRIBUTION.txt /
5457

5558
# Compatible with initial base image

build-image-src/Dockerfile-python39

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ ENV LANG=en_US.UTF-8
5050
# Python for it to be picked up during `sam build`
5151
RUN pip3 install wheel==0.45.1
5252

53+
# Install uv
54+
RUN pip3 install uv==0.9.22
55+
5356
COPY ATTRIBUTION.txt /
5457

5558
# Compatible with initial base image

tests/test_build_images.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ def test_packages(self):
507507
self.assertTrue(self.check_package_output("python --version", "Python 3.8."))
508508
self.assertTrue(self.is_package_present("pip"))
509509
self.assertTrue(self.is_architecture("x86_64"))
510+
self.assertTrue(self.check_package_output("uv --version", "uv"))
510511

511512

512513
@pytest.mark.python38arm64
@@ -524,6 +525,7 @@ def test_packages(self):
524525
self.assertTrue(self.check_package_output("python --version", "Python 3.8."))
525526
self.assertTrue(self.is_package_present("pip"))
526527
self.assertTrue(self.is_architecture("aarch64"))
528+
self.assertTrue(self.check_package_output("uv --version", "uv"))
527529

528530

529531
@pytest.mark.python39x86_64
@@ -540,6 +542,24 @@ def test_packages(self):
540542
"""
541543
self.assertTrue(self.check_package_output("python --version", "Python 3.9."))
542544
self.assertTrue(self.is_package_present("pip"))
545+
self.assertTrue(self.check_package_output("uv --version", "uv"))
546+
547+
548+
@pytest.mark.python39arm64
549+
class TestBIPython39ForArm(BuildImageBase):
550+
__test__ = True
551+
552+
@classmethod
553+
def setUpClass(cls):
554+
super().setUpClass("python3.9", "Dockerfile-python39", "pip", tag="arm64")
555+
556+
def test_packages(self):
557+
"""
558+
Test packages specific to this build image
559+
"""
560+
self.assertTrue(self.check_package_output("python --version", "Python 3.9."))
561+
self.assertTrue(self.is_package_present("pip"))
562+
self.assertTrue(self.check_package_output("uv --version", "uv"))
543563

544564

545565
@pytest.mark.python310arm64
@@ -556,6 +576,7 @@ def test_packages(self):
556576
"""
557577
self.assertTrue(self.check_package_output("python --version", "Python 3.10."))
558578
self.assertTrue(self.is_package_present("pip"))
579+
self.assertTrue(self.check_package_output("uv --version", "uv"))
559580

560581

561582
@pytest.mark.python310x86_64
@@ -572,6 +593,7 @@ def test_packages(self):
572593
"""
573594
self.assertTrue(self.check_package_output("python --version", "Python 3.10."))
574595
self.assertTrue(self.is_package_present("pip"))
596+
self.assertTrue(self.check_package_output("uv --version", "uv"))
575597

576598

577599
@pytest.mark.python311arm64
@@ -588,6 +610,7 @@ def test_packages(self):
588610
"""
589611
self.assertTrue(self.check_package_output("python --version", "Python 3.11."))
590612
self.assertTrue(self.is_package_present("pip"))
613+
self.assertTrue(self.check_package_output("uv --version", "uv"))
591614

592615

593616
@pytest.mark.python311x86_64
@@ -604,6 +627,7 @@ def test_packages(self):
604627
"""
605628
self.assertTrue(self.check_package_output("python --version", "Python 3.11."))
606629
self.assertTrue(self.is_package_present("pip"))
630+
self.assertTrue(self.check_package_output("uv --version", "uv"))
607631

608632

609633
@pytest.mark.python312arm64
@@ -620,6 +644,7 @@ def test_packages(self):
620644
"""
621645
self.assertTrue(self.check_package_output("python --version", "Python 3.12."))
622646
self.assertTrue(self.is_package_present("pip"))
647+
self.assertTrue(self.check_package_output("uv --version", "uv"))
623648

624649

625650
@pytest.mark.python312x86_64
@@ -636,6 +661,7 @@ def test_packages(self):
636661
"""
637662
self.assertTrue(self.check_package_output("python --version", "Python 3.12."))
638663
self.assertTrue(self.is_package_present("pip"))
664+
self.assertTrue(self.check_package_output("uv --version", "uv"))
639665

640666

641667
@pytest.mark.python313arm64
@@ -652,6 +678,7 @@ def test_packages(self):
652678
"""
653679
self.assertTrue(self.check_package_output("python --version", "Python 3.13."))
654680
self.assertTrue(self.is_package_present("pip"))
681+
self.assertTrue(self.check_package_output("uv --version", "uv"))
655682

656683

657684
@pytest.mark.python313x86_64
@@ -668,6 +695,7 @@ def test_packages(self):
668695
"""
669696
self.assertTrue(self.check_package_output("python --version", "Python 3.13."))
670697
self.assertTrue(self.is_package_present("pip"))
698+
self.assertTrue(self.check_package_output("uv --version", "uv"))
671699

672700

673701
@pytest.mark.python314arm64
@@ -684,6 +712,7 @@ def test_packages(self):
684712
"""
685713
self.assertTrue(self.check_package_output("python --version", "Python 3.14."))
686714
self.assertTrue(self.is_package_present("pip"))
715+
self.assertTrue(self.check_package_output("uv --version", "uv"))
687716

688717

689718
@pytest.mark.python314x86_64
@@ -700,22 +729,7 @@ def test_packages(self):
700729
"""
701730
self.assertTrue(self.check_package_output("python --version", "Python 3.14."))
702731
self.assertTrue(self.is_package_present("pip"))
703-
704-
705-
@pytest.mark.python39arm64
706-
class TestBIPython39ForArm(BuildImageBase):
707-
__test__ = True
708-
709-
@classmethod
710-
def setUpClass(cls):
711-
super().setUpClass("python3.9", "Dockerfile-python39", "pip", tag="arm64")
712-
713-
def test_packages(self):
714-
"""
715-
Test packages specific to this build image
716-
"""
717-
self.assertTrue(self.check_package_output("python --version", "Python 3.9."))
718-
self.assertTrue(self.is_package_present("pip"))
732+
self.assertTrue(self.check_package_output("uv --version", "uv"))
719733

720734

721735
@pytest.mark.dotnet6x86_64

0 commit comments

Comments
 (0)