Bootstrap Python runtime with uv for faster build time
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- build-system, cloud
Hướng nghiên cứu
Issue không nêu tên tệp nào trong repository, bài kiểm thử hay điểm vào của phần triển khai. Trước tiên, hãy xác nhận việc thiết lập runtime PYTHON_VERSION thuộc về cloudflare-python hay Cloudflare Pages, sau đó xác định phần nào chịu trách nhiệm cho build runtime. Công việc được xem là hoàn tất khi đã quyết định được hướng triển khai để cài đặt phiên bản Python được yêu cầu bằng uv và đã xác minh được mức cải thiện thời gian build được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Confirm this is a Python library issue and not an underlying Cloudflare API issue.
- This is an issue with the Python library
edit: I'm not sure this is an issue with the "Python library" but with the Python support in CloudFlare itself, but I don't see where that is reportable/feature requestable? I came here via the link in the CloudFlare developer platform changelog and would appreciate being pointed in the right direction if I'm in the wrong place!
Describe the bug
I'm not sure how easy it would be for you to use uv behind the scenes to set Python up itself, but this is something uv supports.
Currently PYTHON_VERSION triggers setup of a Python runtime via pyenv, to my understanding.
I imagine uv would do this faster, as uv is optimised for speed, besides which once I get a Python [with pip] the first thing I have to do is use that to get uv to set up the tool I actually want.
I use uv rather than plain pip because it works with my lockfile, and for many Python developers it is the go-to tool, so this makes cloudflare-python feel a little awkward to work with. I would think this can be easily fixed by having a mechanism to set up uv?
A Python runtime is set up if you set PYTHON_VERSION (here "3.13") but then you have to pip install uv to get uv.
This setup took ~100 seconds, 94% of which is building Python from source. uv can install Python for you, it'd be nice to be able to instead set UV_PYTHON_VERSION and have uv install a Python runtime via python-build-standalone (used by mise for example). This exact scenario is highlighted in the uv docs in contrast to the uv approach:
CPython distributions
As Python does not publish official distributable CPython binaries, uv instead uses pre-built distributions from the Astral python-build-standalone project. python-build-standalone is also is used in many other Python projects, like Mise and bazelbuild/rules_python.
The uv Python distributions are self-contained, highly-portable, and performant. While Python can be built from source, as in tools like pyenv, doing so requires preinstalled system dependencies, and creating optimized, performant builds (e.g., with PGO and LTO enabled) is very slow.
These distributions have some behavior quirks, generally as a consequence of portability; see the python-build-standalone quirks documentation for details.
2026-05-11T09:58:20.18442Z Detected the following tools from environment: python@3.13.12, pip@25.1.1
2026-05-11T09:58:20.184785Z Installing python 3.13.12
2026-05-11T09:58:20.92625Z From https://github.com/pyenv/pyenv
2026-05-11T09:58:20.926531Z d26308df..c639152a master -> origin/master
2026-05-11T09:58:20.926629Z * [new tag] v2.6.31 -> v2.6.31
2026-05-11T09:58:20.941038Z * [new tag] v2.6.27 -> v2.6.27
2026-05-11T09:58:20.941232Z * [new tag] v2.6.28 -> v2.6.28
2026-05-11T09:58:20.941299Z * [new tag] v2.6.29 -> v2.6.29
2026-05-11T09:58:20.941401Z * [new tag] v2.6.30 -> v2.6.30
2026-05-11T09:58:21.131194Z python-build 3.13.12 /opt/buildhome/.asdf/installs/python/3.13.12
2026-05-11T09:58:21.206109Z Downloading Python-3.13.12.tar.xz...
2026-05-11T09:58:21.206372Z -> https://www.python.org/ftp/python/3.13.12/Python-3.13.12.tar.xz
2026-05-11T09:58:23.253131Z Installing Python-3.13.12...
2026-05-11T09:59:57.220831Z Installed Python-3.13.12 to /opt/buildhome/.asdf/installs/python/3.13.12
2026-05-11T09:59:58.07709Z Executing user command: pip install uv && uvx zensical build
2026-05-11T09:59:58.977421Z Collecting uv
2026-05-11T09:59:59.031347Z Downloading uv-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
2026-05-11T09:59:59.050936Z Downloading uv-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.7 MB)
2026-05-11T09:59:59.530469Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 24.7/24.7 MB 54.2 MB/s 0:00:00
2026-05-11T09:59:59.57034Z Installing collected packages: uv
2026-05-11T09:59:59.921853Z Successfully installed uv-0.11.13
2026-05-11T10:00:00.031242Z
2026-05-11T10:00:00.031568Z [notice] A new release of pip is available: 25.3 -> 26.1.1
2026-05-11T10:00:00.031744Z [notice] To update, run: pip3 install --upgrade pip
2026-05-11T10:00:00.100405Z Reshimming asdf python...
uv setup benchmark
I measured in an Ubuntu (latest) Docker container:
- Installing uv takes 3 seconds
curl -LsSf https://astral.sh/uv/install.sh | sh
root@564346048fa8:/# export PATH="$HOME/.local/bin:$PATH"
root@564346048fa8:/# uv --version
uv 0.11.13 (x86_64-unknown-linux-gnu)
- Installing Python 3.13 takes another 3 seconds
root@564346048fa8:/# UV_PYTHON_VERSION=3.13
root@564346048fa8:/# uv python install $UV_PYTHON_VERSION
Installed Python 3.13.13 in 3.31s
+ cpython-3.13.13-linux-x86_64-gnu (python3.13)
So we're easily looking at over 10x faster than the pyenv approach (~6s not 100s)
To Reproduce
- Set
PYTHON_VERSIONwhen setting up CloudFlare Pages - Build spends 94s compiling Python from source
- This compilation step could pull prebuilt binaries much faster
Code snippets
OS
Linux
Python version
3.13
Library version
v5.1.0 (latest)
- Ngôn ngữ chính
- Python
- Star
- 509
- Fork
- 150
- Merge trung bình
- 3 giờ 15 phút
- Pull request đã merge (30 ngày)
- 1
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cloudflare/cloudflare-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
cloudflare/cloudflare-python#2747 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
cloudflare/cloudflare-python#2718 · 1 bình luận ·
-
`client.pages.projects.list` returns a paginated list of `Deployment`s instead of `Project`s Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
cloudflare/cloudflare-python#2692 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
cloudflare/cloudflare-python#2679 · 4 bình luận · 5 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
cloudflare/cloudflare-python#2745 · 1 bình luận ·
Tất cả issue của cloudflare/cloudflare-python
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100