From 5927fc854441c00a70311d177062549e9201f573 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Thu, 23 Jul 2026 14:19:43 +0100 Subject: [PATCH] Add `WheelDistInfo` configuration option An increasing number of Python modules implicitly depend on the presence of distribution metadata (e.g. to ensure their dependencies are correctly installed). `.dist-info` directories can be added manually to `python_wheel`'s `outs` when required, although it is cumbersome to do so - besides, there really isn't any advantage to omitting `.dist-info` directories. When the `WheelDistInfo` plugin configuration option is enabled, `python_wheel` outputs the module's `.dist-info` directory. The option is disabled by default for now while we test it more thoroughly. --- .plzconfig | 8 ++++++++ build_defs/python.build_defs | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.plzconfig b/.plzconfig index 07b6b70c..179a7932 100644 --- a/.plzconfig +++ b/.plzconfig @@ -154,6 +154,14 @@ Optional = true Inherit = true Help = The tool used to resolve wheels with using the pypi API. +[PluginConfig "wheel_dist_info"] +ConfigKey = WheelDistInfo +Type = bool +DefaultValue = false +Optional = true +Inherit = true +Help = Controls whether python_wheel outputs the module's .dist-info directory by default. + [PluginConfig "prereleases"] DefaultValue = false Type = bool diff --git a/build_defs/python.build_defs b/build_defs/python.build_defs index 6076dc67..2657f0db 100644 --- a/build_defs/python.build_defs +++ b/build_defs/python.build_defs @@ -602,6 +602,10 @@ def python_wheel(name:str, version:str, labels:list=[], hashes:list=None, packag """ binary = binary or entry_points package_name = package_name or name.replace('-', '_') + if not outs: + outs = [name] + if CONFIG.PYTHON.WHEEL_DIST_INFO: + outs += [f"{package_name}-{version}.dist-info"] initial = package_name[0] url_base = repo or CONFIG.PYTHON.WHEEL_REPO if not tool and not url_base: @@ -667,7 +671,7 @@ 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]), + '$TOOLS_ARCAT z -d --prefix $PKG -i ' + ' -i '.join(outs), ] label = f'whl:{package_name}=={version}' @@ -704,7 +708,7 @@ def python_wheel(name:str, version:str, labels:list=[], hashes:list=None, packag name = name, tag = "lib_rule" if binary else None, srcs = [wheel_rule], - outs = outs or [name], + outs = outs, tools = [CONFIG.ARCAT_TOOL], cmd = cmd, deps = deps,