Skip to content

Commit 1717c76

Browse files
committed
unix: derive set of packages to copy from config file
The code was mostly redundant with the config file annotations. But it was incomplete and there were some minor name mismatches. So we close the gaps as part of this change.
1 parent dd181ce commit 1717c76

File tree

4 files changed

+68
-54
lines changed

4 files changed

+68
-54
lines changed

cpython-unix/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ TIX_DEPENDS = \
206206
$(HERE)/build-tix.sh \
207207
$(OUTDIR)/tcl-$(TCL_VERSION)-$(PACKAGE_SUFFIX).tar \
208208
$(OUTDIR)/tk-$(TK_VERSION)-$(PACKAGE_SUFFIX).tar \
209-
$(if $(NEED_X11),$(OUTDIR)/libX11-$(LIBX11_VERSION)-$(PACKAGE_SUFFIX).tar) \
209+
$(if $(NEED_LIBX11),$(OUTDIR)/libX11-$(LIBX11_VERSION)-$(PACKAGE_SUFFIX).tar) \
210210
$(NULL)
211211

212212
$(OUTDIR)/tix-$(TIX_VERSION)-$(PACKAGE_SUFFIX).tar: $(TIX_DEPENDS)
@@ -215,7 +215,7 @@ $(OUTDIR)/tix-$(TIX_VERSION)-$(PACKAGE_SUFFIX).tar: $(TIX_DEPENDS)
215215
TK_DEPENDS = \
216216
$(HERE)/build-tk.sh \
217217
$(OUTDIR)/tcl-$(TCL_VERSION)-$(PACKAGE_SUFFIX).tar \
218-
$(if $(NEED_X11),$(OUTDIR)/libX11-$(LIBX11_VERSION)-$(PACKAGE_SUFFIX).tar) \
218+
$(if $(NEED_LIBX11),$(OUTDIR)/libX11-$(LIBX11_VERSION)-$(PACKAGE_SUFFIX).tar) \
219219
$(NULL)
220220

221221
$(OUTDIR)/tk-$(TK_VERSION)-$(PACKAGE_SUFFIX).tar: $(TK_DEPENDS)
@@ -250,7 +250,7 @@ $(OUTDIR)/zlib-$(ZLIB_VERSION)-$(PACKAGE_SUFFIX).tar: $(PYTHON_DEP_DEPENDS) $(HE
250250

251251
PYTHON_DEPENDS := \
252252
$(if $(NEED_BDB),$(OUTDIR)/bdb-$(BDB_VERSION)-$(PACKAGE_SUFFIX).tar) \
253-
$(OUTDIR)/bzip2-$(BZIP2_VERSION)-$(PACKAGE_SUFFIX).tar \
253+
$(if $(NEED_BZIP2),$(OUTDIR)/bzip2-$(BZIP2_VERSION)-$(PACKAGE_SUFFIX).tar) \
254254
$(if $(NEED_GDBM),$(OUTDIR)/gdbm-$(GDBM_VERSION)-$(PACKAGE_SUFFIX).tar) \
255255
$(if $(NEED_GETTEXT),$(OUTDIR)/gettext-$(GETTEXT_VERSION)-$(PACKAGE_SUFFIX).tar) \
256256
$(if $(NEED_LIBEDIT),$(OUTDIR)/libedit-$(LIBEDIT_VERSION)-$(PACKAGE_SUFFIX).tar) \
@@ -262,8 +262,8 @@ PYTHON_DEPENDS := \
262262
$(if $(NEED_SQLITE),$(OUTDIR)/sqlite-$(SQLITE_VERSION)-$(PACKAGE_SUFFIX).tar) \
263263
$(if $(NEED_TIX),$(OUTDIR)/tix-$(TIX_VERSION)-$(PACKAGE_SUFFIX).tar) \
264264
$(if $(NEED_UUID),$(OUTDIR)/uuid-$(UUID_VERSION)-$(PACKAGE_SUFFIX).tar) \
265-
$(OUTDIR)/xz-$(XZ_VERSION)-$(PACKAGE_SUFFIX).tar \
266-
$(OUTDIR)/zlib-$(ZLIB_VERSION)-$(PACKAGE_SUFFIX).tar \
265+
$(if $(NEED_XZ),$(OUTDIR)/xz-$(XZ_VERSION)-$(PACKAGE_SUFFIX).tar) \
266+
$(if $(NEED_ZLIB),$(OUTDIR)/zlib-$(ZLIB_VERSION)-$(PACKAGE_SUFFIX).tar) \
267267
$(HERE)/disabled-static-modules.$(PYBUILD_PYTHON_MAJOR_VERSION).$(HOST_PLATFORM) \
268268
$(HERE)/required-extensions.$(PYBUILD_PYTHON_MAJOR_VERSION).$(HOST_PLATFORM) \
269269
$(HERE)/static-modules.$(PYBUILD_PYTHON_MAJOR_VERSION).$(HOST_PLATFORM) \

cpython-unix/build.py

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
add_licenses_to_extension_entry,
3030
download_entry,
3131
get_targets,
32+
target_needs,
3233
validate_python_json,
3334
write_package_versions,
3435
write_triples_makefiles,
@@ -820,53 +821,11 @@ def build_cpython(
820821
musl="musl" in target_triple,
821822
)
822823

823-
# TODO support bdb/gdbm toggle
824-
packages = {
825-
"bzip2",
826-
"xz",
827-
"zlib",
828-
}
829-
830-
bdb = host_platform != "macos"
831-
if bdb:
832-
packages.add("bdb")
833-
834-
libedit = target_triple not in ("aarch64-apple-ios", "x86_64-apple-ios")
835-
if libedit:
836-
packages.add("libedit")
837-
838-
libffi = target_triple not in ("aarch64-apple-ios", "x86_64-apple-ios")
839-
if libffi:
840-
packages.add("libffi")
841-
842-
if libressl:
843-
packages.add("libressl")
844-
else:
845-
packages.add("openssl")
846-
847-
# We use the system ncurses on macOS for now.
848-
ncurses = host_platform != "macos"
849-
if ncurses:
850-
packages.add("ncurses")
851-
852-
readline = host_platform != "macos"
853-
if readline:
854-
packages.add("readline")
855-
856-
sqlite = target_triple not in ("aarch64-apple-ios", "x86_64-apple-ios")
857-
if sqlite:
858-
packages.add("sqlite")
859-
860-
tk = target_triple not in ("aarch64-apple-ios", "x86_64-apple-ios")
861-
if tk:
862-
packages |= {"tcl", "tix", "tk"}
863-
864-
uuid = target_triple not in ("aarch64-apple-ios", "x86_64-apple-ios")
865-
if uuid:
866-
packages.add("uuid")
867-
868-
if host_platform == "linux64":
869-
packages |= {"libX11", "libXau", "libxcb", "xorgproto"}
824+
packages = target_needs(TARGETS_CONFIG, target_triple)
825+
# Toolchain packages are handled specially.
826+
packages.discard("binutils")
827+
packages.discard("clang")
828+
packages.discard("gcc")
870829

871830
for p in sorted(packages):
872831
build_env.install_artifact_archive(BUILD, p, target_triple, optimizations)

cpython-unix/targets.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,91 +12,132 @@ aarch64-apple-darwin:
1212
host_platforms:
1313
- darwin
1414
needs:
15+
- bzip2
1516
- libedit
1617
- libffi
1718
- ncurses
1819
- sqlite
1920
- tix
2021
- uuid
22+
- xz
23+
- zlib
2124

2225
aarch64-apple-ios:
2326
host_platforms:
2427
- darwin
2528
needs:
29+
- bzip2
30+
- libffi
2631
- sqlite
32+
- xz
33+
- zlib
2734

2835
arm64-apple-tvos:
2936
host_platforms:
3037
- darwin
3138
needs:
39+
- bzip2
3240
- sqlite
41+
- xz
42+
- zlib
3343

3444
thumb7k-apple-watchos:
3545
host_platforms:
3646
- darwin
3747
needs:
48+
- bzip2
3849
- sqlite
50+
- xz
51+
- zlib
3952

4053
x86_64-apple-darwin:
4154
host_platforms:
4255
- darwin
4356
needs:
57+
- bzip2
4458
- libedit
4559
- libffi
4660
- ncurses
4761
- sqlite
4862
- tix
4963
- uuid
64+
- xz
65+
- zlib
5066

5167
x86_64-apple-ios:
5268
host_platforms:
5369
- darwin
5470
needs:
71+
- bzip2
72+
- libffi
5573
- sqlite
74+
- xz
75+
- zlib
5676

5777
x86_64-apple-tvos:
5878
host_platforms:
5979
- darwin
6080
needs:
81+
- bzip2
6182
- sqlite
83+
- xz
6284

6385
x86_64-apple-watchos:
6486
host_platforms:
6587
- darwin
6688
needs:
89+
- bzip2
6790
- sqlite
91+
- xz
92+
- zlib
6893

6994
x86_64-unknown-linux-gnu:
7095
host_platforms:
7196
- linux
7297
needs:
7398
- bdb
7499
- binutils
100+
- bzip2
75101
- gcc
76102
- gdbm
77103
- libedit
78104
- libffi
105+
- libX11
106+
- libXau
107+
- libxcb
79108
- ncurses
80-
- x11
81109
- readline
82110
- sqlite
111+
- tcl
112+
- tk
83113
- tix
84114
- uuid
115+
- xorgproto
116+
- xz
117+
- zlib
85118

86119
x86_64-unknown-linux-musl:
87120
host_platforms:
88121
- linux
89122
needs:
90123
- bdb
91124
- binutils
125+
- bzip2
92126
- gcc
93127
- gdbm
94128
- libedit
95129
- libffi
130+
- libX11
131+
- libXau
132+
- libxcb
96133
- musl
97134
- ncurses
98-
- x11
99135
- readline
100136
- sqlite
137+
- tcl
138+
- tk
101139
- tix
102140
- uuid
141+
- xorgproto
142+
- xz
143+
- zlib

pythonbuild/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ def supported_targets(yaml_path: pathlib.Path):
3838
return targets
3939

4040

41+
def target_needs(yaml_path: pathlib.Path, target: str):
42+
"""Obtain the dependencies needed to build the specified target."""
43+
settings = get_targets(yaml_path)[target]
44+
45+
needs = set(settings["needs"])
46+
47+
if "PYBUILD_LIBRESSL" in os.environ:
48+
needs.add("libressl")
49+
else:
50+
needs.add("openssl")
51+
52+
return needs
53+
54+
4155
def release_tag_from_git():
4256
return (
4357
subprocess.check_output(

0 commit comments

Comments
 (0)