From f2507e7939a614aacd0f0d0f072043ecc50fbd8c Mon Sep 17 00:00:00 2001 From: Marcus Caisey Date: Wed, 6 May 2026 13:48:33 +0100 Subject: [PATCH 1/2] Add "py" dependency requirement to pip_library target --- build_defs/python.build_defs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build_defs/python.build_defs b/build_defs/python.build_defs index 6076dc6..b75286e 100644 --- a/build_defs/python.build_defs +++ b/build_defs/python.build_defs @@ -513,8 +513,8 @@ def pip_library(name:str, version:str, labels:list=[], hashes:list=None, package labels = ["dlink:plz-out/python/venv"] ) - # Don't include the dependency whl's into our whl. They are later picked up by py_binary anyway. - cmd = f'$TOOLS_ARCAT z --suffix="" --exclude_suffix=whl --include_other -i . -r $PKG/{name}:$PKG' + # Don't include the dependency pex.zips or whls into our whl. They are later picked up by python_binary anyway. + cmd = f'$TOOLS_ARCAT z --suffix="" --exclude_suffix=whl --exclude_suffix=pex.zip --include_other -i . -r $PKG/{name}:$PKG' if not licences: cmd += ' && find . -name METADATA -or -name PKG-INFO | grep -v "^./build/" | xargs grep -E "License ?:" | grep -v UNKNOWN | cat || true' @@ -531,6 +531,7 @@ def pip_library(name:str, version:str, labels:list=[], hashes:list=None, package tools = { 'arcat': [CONFIG.ARCAT_TOOL], }, + requires = ["py"], post_build = None if licences else _add_licences, labels = labels + ['py', 'pip:' + package_name] + (['py:zip-unsafe'] if not zip_safe else []), visibility = visibility, From 9457e345c50c6c213406765cc470dd718e88b0ad Mon Sep 17 00:00:00 2001 From: Marcus Caisey Date: Wed, 6 May 2026 13:55:13 +0100 Subject: [PATCH 2/2] Ensure python_wheel sources are linked after dependent targets are built --- build_defs/python.build_defs | 43 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/build_defs/python.build_defs b/build_defs/python.build_defs index b75286e..dd1c348 100644 --- a/build_defs/python.build_defs +++ b/build_defs/python.build_defs @@ -668,22 +668,19 @@ def python_wheel(name:str, version:str, labels:list=[], hashes:list=None, packag cmd += [ # N.B. we need -b for legacy locations because that's all zipimport knows to look for :( '$TOOLS_PYTHON -m compileall -b -f .', - '$TOOLS_ARCAT z -d --prefix $PKG -i ' + ' -i '.join(outs or [name]), ] label = f'whl:{package_name}=={version}' - wheel_rule = build_rule( + srcs_rule = build_rule( name = name, - tag = 'wheel', + tag = 'srcs', cmd = ' && '.join(cmd), - outs = [name + '.pex.zip'], + outs = outs or [name], srcs = { 'src': [file_rule], 'res': patches if patch else [], }, - building_description = 'Repackaging...', - requires = ['py'], - deps = deps, + building_description = 'Extracting...', test_only = test_only, licences = licences, tools = { @@ -691,28 +688,32 @@ def python_wheel(name:str, version:str, labels:list=[], hashes:list=None, packag "python": [interpreter], }, post_build = None if licences else _add_licences, - sandbox = False, + labels = [label] + ["link:plz-out/python/venv"], + ) + + wheel_rule = build_rule( + name = name, + tag = 'wheel', + cmd = '$TOOL z -d -i $PKG/' + ' -i $PKG/'.join(outs or [name]), + outs = [name + '.pex.zip'], + srcs = [srcs_rule], + building_description = 'Repackaging...', + requires = ['py'], + deps = deps, + test_only = test_only, + tools = [CONFIG.ARCAT_TOOL], labels = ['py:zip-unsafe', label] if not zip_safe else [label], ) - cmd = '$TOOL x $SRCS -s $PKG_DIR' - if outs: - # Hacky solution to handle things being in subdirectories in awkward ways. - before, _, after = outs[0].partition('/') - if after: - cmd = f'rm -rf {before} && {cmd}' - - lib_rule = build_rule( + + lib_rule = filegroup( name = name, tag = "lib_rule" if binary else None, - srcs = [wheel_rule], - outs = outs or [name], - tools = [CONFIG.ARCAT_TOOL], - cmd = cmd, + srcs = [srcs_rule], deps = deps, visibility = visibility, licences = licences, test_only = test_only, - labels = labels + [label] + ["link:plz-out/python/venv"], + labels = labels + [label], provides = { "py": wheel_rule, "py_whl": file_rule,