From 92fa368f5d8318718ec883eefd65e990ab436696 Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Fri, 30 May 2025 16:43:08 +1000 Subject: [PATCH] Switch to uv pipenv is not a popular choice these days, uv seems to have won hearts and minds. --- .buildkite/pipeline.yml | 3 +- .python-version | 1 + Dockerfile | 9 ++-- Pipfile | 12 ----- Pipfile.lock | 68 -------------------------- Readme.md | 8 ++-- pyproject.toml | 15 ++++++ src/python_docker_example/__init__.py | 2 + uv.lock | 69 +++++++++++++++++++++++++++ 9 files changed, 95 insertions(+), 92 deletions(-) create mode 100644 .python-version delete mode 100644 Pipfile delete mode 100644 Pipfile.lock create mode 100644 pyproject.toml create mode 100644 src/python_docker_example/__init__.py create mode 100644 uv.lock diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1caf72d..588c025 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,7 +1,6 @@ - steps: - name: ":python:" - command: "py.test" + command: uv run py.test plugins: - docker-compose#v5.2.0: run: app diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/Dockerfile b/Dockerfile index 4f9b812..d52a312 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,5 @@ -FROM python -RUN pip install pipenv +FROM ghcr.io/astral-sh/uv:python3.13-alpine COPY . /app WORKDIR /app -RUN pipenv install --deploy --dev -ENV SHELL=/bin/bash -ENTRYPOINT ["pipenv", "run"] -CMD ["python"] \ No newline at end of file +RUN uv sync +CMD ["uv", "run", "python"] diff --git a/Pipfile b/Pipfile deleted file mode 100644 index a8df74c..0000000 --- a/Pipfile +++ /dev/null @@ -1,12 +0,0 @@ -[[source]] - -url = "https://pypi.python.org/simple" -verify_ssl = true -name = "pypi" - - -[dev-packages] - -pytest = "*" - -[packages] \ No newline at end of file diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index e9355d0..0000000 --- a/Pipfile.lock +++ /dev/null @@ -1,68 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "a28e60d6ec10434b5d5c40b6c3d799a45286fc0c6af7e2f5000aa77058933889" - }, - "pipfile-spec": 6, - "requires": {}, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.python.org/simple", - "verify_ssl": true - } - ] - }, - "default": {}, - "develop": { - "attrs": { - "hashes": [ - "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836", - "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99" - ], - "markers": "python_version >= '3.6'", - "version": "==22.2.0" - }, - "iniconfig": { - "hashes": [ - "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", - "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374" - ], - "markers": "python_version >= '3.7'", - "version": "==2.0.0" - }, - "packaging": { - "hashes": [ - "sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2", - "sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97" - ], - "markers": "python_version >= '3.7'", - "version": "==23.0" - }, - "pluggy": { - "hashes": [ - "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", - "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3" - ], - "markers": "python_version >= '3.6'", - "version": "==1.0.0" - }, - "pytest": { - "hashes": [ - "sha256:27fa6617efc2869d3e969a3e75ec060375bfb28831ade8b5cdd68da3a741dc3c", - "sha256:81a25f36a97da3313e1125fce9e7bbbba565bc7fec3c5beb14c262ddab238ac1" - ], - "index": "pypi", - "version": "==7.2.0" - }, - "setuptools": { - "hashes": [ - "sha256:c3a9c4211ff4c309edb8b8c4f1cbfa7ae324c4ba9f91ff254e3d305b9fd54561", - "sha256:fcc17fd9cd898242f6b4adfaca46137a9edef687f43e6f78469692a5e70d851d" - ], - "index": "pypi", - "markers": "python_version >= '3.9'", - "version": "==78.1.1" - } - } -} diff --git a/Readme.md b/Readme.md index b13f9e0..8485596 100644 --- a/Readme.md +++ b/Readme.md @@ -1,15 +1,15 @@ -# Buildkite Python Docker Example (using pipenv) +# Buildkite Python Docker Example (using uv) [![Add to Buildkite](https://buildkite.com/button.svg)](https://buildkite.com/new) -This repository is an example on how to test a [Python](https://python.org) project using [Buildkite](https://buildkite.com/), [Docker](https://www.docker.com/) and [pipenv](https://github.com/kennethreitz/pipenv). +This repository is an example on how to test a [Python](https://python.org) project using [Buildkite](https://buildkite.com/), [Docker](https://www.docker.com/) and [uv](https://docs.astral.sh/uv/). ## How does it work? -* The [Dockerfile](Dockerfile) sets up the pipenv environment, and installs the dependencies +* The [Dockerfile](Dockerfile) sets up the uv environment, and installs the dependencies * The [docker-compose.yml](docker-compose.yml) defines the 'app' Docker service and how it should be built * The [pipeline.yml](.buildkite/pipeline.yml) runs the command using Docker Compose ## License -See [Licence.md](Licence.md) (MIT) \ No newline at end of file +See [Licence.md](Licence.md) (MIT) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..37e8a0d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[project] +name = "python-docker-example" +version = "0.1.0" +description = "" +readme = "README.md" +authors = [ + { name = "Builkdite Developers", email = "dev@buildkite.com" } +] +requires-python = ">=3.13" +dependencies = [] + +[dependency-groups] +dev = [ + "pytest>=8.3.5", +] diff --git a/src/python_docker_example/__init__.py b/src/python_docker_example/__init__.py new file mode 100644 index 0000000..44630b6 --- /dev/null +++ b/src/python_docker_example/__init__.py @@ -0,0 +1,2 @@ +def main() -> None: + print("Hello from python-docker-example!") diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..d66d47c --- /dev/null +++ b/uv.lock @@ -0,0 +1,69 @@ +version = 1 +revision = 1 +requires-python = ">=3.13" + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 }, +] + +[[package]] +name = "iniconfig" +version = "2.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f2/97/ebf4da567aa6827c909642694d71c9fcf53e5b504f2d96afea02718862f3/iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7", size = 4793 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050 }, +] + +[[package]] +name = "packaging" +version = "25.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469 }, +] + +[[package]] +name = "pluggy" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538 }, +] + +[[package]] +name = "pytest" +version = "8.3.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ae/3c/c9d525a414d506893f0cd8a8d0de7706446213181570cdbd766691164e40/pytest-8.3.5.tar.gz", hash = "sha256:f4efe70cc14e511565ac476b57c279e12a855b11f48f212af1080ef2263d3845", size = 1450891 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/30/3d/64ad57c803f1fa1e963a7946b6e0fea4a70df53c1a7fed304586539c2bac/pytest-8.3.5-py3-none-any.whl", hash = "sha256:c69214aa47deac29fad6c2a4f590b9c4a9fdb16a403176fe154b79c0b4d4d820", size = 343634 }, +] + +[[package]] +name = "python-docker-example" +version = "0.1.0" +source = { virtual = "." } + +[package.dev-dependencies] +dev = [ + { name = "pytest" }, +] + +[package.metadata] + +[package.metadata.requires-dev] +dev = [{ name = "pytest", specifier = ">=8.3.5" }]