What is the extent to which I can utilise the uv b...
# general
h
What is the extent to which I can utilise the uv build backend
uv_build
? I don’t think Pex can utilise it in anyway yet but can it be integrated with an existing project using Pants-compatible pyproject.toml and such?
b
Copy code
:; uv init example --build-backend uv --package --app
Initialized project `example` at `/tmp/example`

:; pex example/ -c example -o example.pex 
:; ./example.pex 
Hello from example!
 
:; cat example/pyproject.toml 
[project]
name = "example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
    { name = "John Sirois", email = "<mailto:john.sirois@gmail.com|john.sirois@gmail.com>" }
]
requires-python = ">=3.12"
dependencies = []

[project.scripts]
example = "example:main"

[build-system]
requires = ["uv_build>=0.8.10,<0.9.0"]
build-backend = "uv_build"
h
Is Pex using the uv build backend in this example?
b
1. Technically no - Pip is though. Pex does all wheel builds via Pip.
Copy code
:; tail -20 build.log 
2025-08-14T10:54:32,497   Successfully installed uv_build-0.8.3
2025-08-14T10:54:32,501   Remote version of pip: 25.2
2025-08-14T10:54:32,501   Local version of pip:  24.1
2025-08-14T10:54:32,503   Was pip installed by pip? False
2025-08-14T10:54:32,503   Removed build tracker: '/home/jsirois/.cache/pex/pip/1/24.1/pip_cache/.tmp/pip-build-tracker-660vfdg1'
2025-08-14T10:54:32,537   Installing build dependencies: finished with status 'done'
2025-08-14T10:54:32,537   Getting requirements to build wheel: started
2025-08-14T10:54:32,537   Running command Getting requirements to build wheel
2025-08-14T10:54:32,561   Getting requirements to build wheel: finished with status 'done'
2025-08-14T10:54:32,561   Created temporary directory: /home/jsirois/.cache/pex/pip/1/24.1/pip_cache/.tmp/pip-modern-metadata-gl_fib_o
2025-08-14T10:54:32,561   Preparing metadata (pyproject.toml): started
2025-08-14T10:54:32,561   Running command Preparing metadata (pyproject.toml)
2025-08-14T10:54:32,588   Preparing metadata (pyproject.toml): finished with status 'done'
2025-08-14T10:54:32,588   Source in ./example has version 0.1.0, which satisfies requirement example==0.1.0 from file:///tmp/example
2025-08-14T10:54:32,588   Removed example==0.1.0 from file:///tmp/example from build tracker '/home/jsirois/.cache/pex/pip/1/24.1/pip_cache/.tmp/pip-build-tracker-660vfdg1'
2025-08-14T10:54:32,589 Created temporary directory: /home/jsirois/.cache/pex/pip/1/24.1/pip_cache/.tmp/pip-unpack-entxhlz7
2025-08-14T10:54:32,589 Not copying link to destination directory since it is a directory: file:///tmp/example
2025-08-14T10:54:32,589 Created temporary directory: /home/jsirois/.cache/pex/pip/1/24.1/pip_cache/.tmp/pip-unpack-1yth3y81
2025-08-14T10:54:32,589 Successfully downloaded example
2025-08-14T10:54:32,590 Removed build tracker: '/home/jsirois/.cache/pex/pip/1/24.1/pip_cache/.tmp/pip-build-tracker-660vfdg1'
2. Proof:
Copy code
:; rm -rf example ~/.cache/pex 
:; uv init example --build-backend uv --package --app
Initialized project `example` at `/tmp/example`
 
:; cp example/pyproject.toml example/pyproject.toml.orig 
:; vi example/pyproject.toml 
:; diff -u example/pyproject.toml.orig example/pyproject.toml
--- example/pyproject.toml.orig	2025-08-14 10:53:45.703227559 -0700
+++ example/pyproject.toml	2025-08-14 10:53:58.488471055 -0700
@@ -13,5 +13,5 @@
 example = "example:main"
 
 [build-system]
-requires = ["uv_build>=0.8.10,<0.9.0"]
+requires = ["uv_build==0.8.3"]
 build-backend = "uv_build"

:; pex --pip-log build.log example/ -c example -o example.pex 
[Errno 13] Permission denied: '/home/jsirois/.cache/pex/installed_wheels/0/99a01ad8f853a7bbfaa99b05b66f1b866b620c9fa928fb07bf6f6964a29a7df5/example-0.1.0-py3-none-any.whl.9bf72fcb252848f0a56c8a6932f76ddf.work/example/__init__.py'

:; ls -l /home/jsirois/.cache/pex/installed_wheels/0/99a01ad8f853a7bbfaa99b05b66f1b866b620c9fa928fb07bf6f6964a29a7df5/example-0.1.0-py3-none-any.whl.9bf72fcb252848f0a56c8a6932f76ddf.work/example/__init__.py
--w--wx--- 1 jsirois jsirois 53 Aug 14 10:54 /home/jsirois/.cache/pex/installed_wheels/0/99a01ad8f853a7bbfaa99b05b66f1b866b620c9fa928fb07bf6f6964a29a7df5/example-0.1.0-py3-none-any.whl.9bf72fcb252848f0a56c8a6932f76ddf.work/example/__init__.py
C.F.: + https://github.com/astral-sh/uv/issues/14920 + https://github.com/astral-sh/uv/releases/tag/0.8.4
And @hundreds-carpet-28072 FWIW, once you can use 1 build backend, you can use any: https://peps.python.org/pep-0517/ That standard is 10 years old at this point.
h
Interesting - I was under the false impression that Pex was tied to a specific backend for some reason. So for the pex “binaries” that Pants builds, I can leverage the same perf. benefits that the uv build backend would for normal wheel builds, presumably. I remember there being a config layer between Pants and Pex that I may have to wrangle, but I can work that out. Thanks for your work with Pex btw, it’s been a great tool for us.