Skip to content

Commit 35eec28

Browse files
authored
Use host CPython as Python dependency; remove xcb image; upgrade xcb (#627)
The `xcb` Dockerfile / image existed to provide a host build of CPython, which was required to build libxcb, xcb-proto, and tk. The existence of this image predated our building a host CPython in order to build CPython itself. With PBS now unconditionally building a host CPython, we can use our host CPython during the builds of these packages, eliminating the need for the xcb image. This commit makes that transition. We also upgrade libxcb and xcb-proto to the latest version as part of this migration. Older versions of libxcb aren't compatible with Python 3.12+ due to removal of the `imp` module.
1 parent c550375 commit 35eec28

File tree

9 files changed

+38
-29
lines changed

9 files changed

+38
-29
lines changed

.github/workflows/linux.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ jobs:
6060
- build.cross
6161
- build.cross-riscv64
6262
- gcc
63-
- xcb
64-
- xcb.cross
65-
- xcb.cross-riscv64
6663
name: ${{ matrix.image }}
6764
runs-on: depot-ubuntu-22.04
6865
permissions:

cpython-unix/Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ PYTHON_DEP_DEPENDS := \
7070
$(TOOLCHAIN_DEPENDS) \
7171
$(NULL)
7272

73+
HOST_PYTHON_DEPENDS := $(OUTDIR)/cpython-$(PYTHON_MAJOR_VERSION)-$(CPYTHON_$(PYTHON_MAJOR_VERSION)_VERSION)-$(HOST_PLATFORM).tar
74+
7375
default: $(OUTDIR)/cpython-$(CPYTHON_$(PYTHON_MAJOR_VERSION)_VERSION)-$(PACKAGE_SUFFIX).tar
7476

7577
ifndef PYBUILD_NO_DOCKER
@@ -149,16 +151,16 @@ $(OUTDIR)/libXau-$(LIBXAU_VERSION)-$(PACKAGE_SUFFIX).tar: $(LIBXAU_DEPENDS)
149151

150152
LIBXCB_DEPENDS = \
151153
$(PYTHON_DEP_DEPENDS) \
154+
$(HOST_PYTHON_DEPENDS) \
152155
$(HERE)/build-libxcb.sh \
153-
$(OUTDIR)/image-$(DOCKER_IMAGE_XCB).tar \
154156
$(OUTDIR)/xcb-proto-$(XCB_PROTO_VERSION)-$(PACKAGE_SUFFIX).tar \
155157
$(OUTDIR)/libXau-$(LIBXAU_VERSION)-$(PACKAGE_SUFFIX).tar \
156158
$(OUTDIR)/xorgproto-$(XORGPROTO_VERSION)-$(PACKAGE_SUFFIX).tar \
157159
$(OUTDIR)/libpthread-stubs-$(LIBPTHREAD_STUBS_VERSION)-$(PACKAGE_SUFFIX).tar \
158160
$(NULL)
159161

160162
$(OUTDIR)/libxcb-$(LIBXCB_VERSION)-$(PACKAGE_SUFFIX).tar: $(LIBXCB_DEPENDS)
161-
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_XCB) libxcb
163+
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) --python-host-version $(PYBUILD_PYTHON_VERSION) libxcb
162164

163165
$(OUTDIR)/m4-$(M4_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-m4.sh
164166
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) m4
@@ -204,22 +206,23 @@ $(OUTDIR)/tix-$(TIX_VERSION)-$(PACKAGE_SUFFIX).tar: $(TIX_DEPENDS)
204206
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) tix
205207

206208
TK_DEPENDS = \
209+
$(HOST_PYTHON_DEPENDS) \
207210
$(HERE)/build-tk.sh \
208211
$(OUTDIR)/tcl-$(TCL_VERSION)-$(PACKAGE_SUFFIX).tar \
209212
$(if $(NEED_LIBX11),$(OUTDIR)/libX11-$(LIBX11_VERSION)-$(PACKAGE_SUFFIX).tar) \
210213
$(NULL)
211214

212215
$(OUTDIR)/tk-$(TK_VERSION)-$(PACKAGE_SUFFIX).tar: $(TK_DEPENDS)
213-
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_XCB) tk
216+
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) --python-host-version $(PYBUILD_PYTHON_VERSION) tk
214217

215218
$(OUTDIR)/uuid-$(UUID_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-uuid.sh
216219
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) uuid
217220

218221
$(OUTDIR)/x11-util-macros-$(X11_UTIL_MACROS_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-x11-util-macros.sh
219222
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) x11-util-macros
220223

221-
$(OUTDIR)/xcb-proto-$(XCB_PROTO_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-xcb-proto.sh
222-
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_XCB) xcb-proto
224+
$(OUTDIR)/xcb-proto-$(XCB_PROTO_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HOST_PYTHON_DEPENDS) $(HERE)/build-xcb-proto.sh
225+
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) --python-host-version $(PYBUILD_PYTHON_VERSION) xcb-proto
223226

224227
$(OUTDIR)/xorgproto-$(XORGPROTO_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HERE)/build-xorgproto.sh
225228
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) xorgproto

cpython-unix/build-xcb-proto.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pkg-config --version
1212
export PATH=/tools/${TOOLCHAIN}/bin:/tools/host/bin:$PATH
1313
export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig
1414

15-
tar -xf xcb-proto-${XCB_PROTO_VERSION}.tar.gz
15+
tar -xf xcb-proto-${XCB_PROTO_VERSION}.tar.xz
1616
pushd xcb-proto-${XCB_PROTO_VERSION}
1717

1818
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" LDFLAGS="${EXTRA_TARGET_LDFLAGS}" ./configure \

cpython-unix/build.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ def simple_build(
246246
dest_archive,
247247
extra_archives=None,
248248
tools_path="deps",
249+
python_host_version=None,
249250
):
250251
archive = download_entry(entry, DOWNLOADS_PATH)
251252

@@ -264,6 +265,15 @@ def simple_build(
264265
for a in extra_archives or []:
265266
build_env.install_artifact_archive(BUILD, a, target_triple, build_options)
266267

268+
if python_host_version:
269+
majmin = ".".join(python_host_version.split(".")[0:2])
270+
build_env.install_toolchain_archive(
271+
BUILD,
272+
f"cpython-{majmin}",
273+
host_platform,
274+
version=python_host_version,
275+
)
276+
267277
build_env.copy_file(archive)
268278
build_env.copy_file(SUPPORT / ("build-%s.sh" % entry))
269279

@@ -796,6 +806,7 @@ def build_cpython(
796806
for p in sorted(packages):
797807
build_env.install_artifact_archive(BUILD, p, target_triple, build_options)
798808

809+
# Install the host CPython.
799810
build_env.install_toolchain_archive(
800811
BUILD, entry_name, host_platform, version=python_version
801812
)
@@ -1032,6 +1043,11 @@ def main():
10321043
default=None,
10331044
help="A custom path to CPython source files to use",
10341045
)
1046+
parser.add_argument(
1047+
"--python-host-version",
1048+
default=None,
1049+
help="Python X.Y version for host Python installation",
1050+
)
10351051
parser.add_argument("action")
10361052

10371053
args = parser.parse_args()
@@ -1047,6 +1063,8 @@ def main():
10471063
dest_archive = pathlib.Path(args.dest_archive)
10481064
docker_image = args.docker_image
10491065

1066+
python_host_version = args.python_host_version
1067+
10501068
settings = get_target_settings(TARGETS_CONFIG, target_triple)
10511069

10521070
if args.action == "dockerfiles":
@@ -1213,6 +1231,7 @@ def main():
12131231
target_triple=target_triple,
12141232
build_options=build_options,
12151233
dest_archive=dest_archive,
1234+
python_host_version=python_host_version,
12161235
)
12171236

12181237
elif action == "libxcb":
@@ -1226,6 +1245,7 @@ def main():
12261245
build_options=build_options,
12271246
dest_archive=dest_archive,
12281247
extra_archives={"libpthread-stubs", "libXau", "xcb-proto", "xorgproto"},
1248+
python_host_version=python_host_version,
12291249
)
12301250

12311251
elif action == "tix":
@@ -1260,6 +1280,7 @@ def main():
12601280
build_options=build_options,
12611281
dest_archive=dest_archive,
12621282
extra_archives=extra_archives,
1283+
python_host_version=python_host_version,
12631284
)
12641285

12651286
elif action.startswith("cpython-") and action.endswith("-host"):

cpython-unix/xcb.Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

cpython-unix/xcb.cross-riscv64.Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

cpython-unix/xcb.cross.Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

pythonbuild/downloads.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,11 @@
156156
"licenses": ["MIT"],
157157
"license_file": "LICENSE.libXau.txt",
158158
},
159-
# Newer versions of libxcb require a modern Python to build. We can take this
160-
# dependency once we feel like doing the work.
161159
"libxcb": {
162-
"url": "https://xcb.freedesktop.org/dist/libxcb-1.14.tar.gz",
163-
"size": 640322,
164-
"sha256": "2c7fcddd1da34d9b238c9caeda20d3bd7486456fc50b3cc6567185dbd5b0ad02",
165-
"version": "1.14",
160+
"url": "https://xcb.freedesktop.org/dist/libxcb-1.17.0.tar.gz",
161+
"size": 661593,
162+
"sha256": "2c69287424c9e2128cb47ffe92171e10417041ec2963bceafb65cb3fcf8f0b85",
163+
"version": "1.17.0",
166164
"library_names": ["xcb"],
167165
"licenses": ["MIT"],
168166
"license_file": "LICENSE.libxcb.txt",
@@ -380,10 +378,10 @@
380378
"version": "1.20.1",
381379
},
382380
"xcb-proto": {
383-
"url": "https://www.x.org/archive/individual/proto/xcb-proto-1.14.1.tar.gz",
384-
"size": 194674,
385-
"sha256": "85cd21e9d9fbc341d0dbf11eace98d55d7db89fda724b0e598855fcddf0944fd",
386-
"version": "1.14.1",
381+
"url": "https://xcb.freedesktop.org/dist/xcb-proto-1.17.0.tar.xz",
382+
"size": 151748,
383+
"sha256": "2c1bacd2110f4799f74de6ebb714b94cf6f80fb112316b1219480fd22562148c",
384+
"version": "1.17.0",
387385
},
388386
# Newer versions from at least 2023 have build failures for reasons we haven't
389387
# fully investigated.

pythonbuild/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def write_triples_makefiles(
195195
image_suffix = settings.get("docker_image_suffix", "")
196196

197197
lines.append("DOCKER_IMAGE_BUILD := build%s\n" % image_suffix)
198-
lines.append("DOCKER_IMAGE_XCB := xcb%s\n" % image_suffix)
199198

200199
entry = clang_toolchain(host_platform, triple)
201200
lines.append(

0 commit comments

Comments
 (0)