Skip to content

Commit a18ff0d

Browse files
Add WheelDistInfo configuration option (#312)
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.
1 parent 7bde1e3 commit a18ff0d

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

.plzconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ Optional = true
154154
Inherit = true
155155
Help = The tool used to resolve wheels with using the pypi API.
156156

157+
[PluginConfig "wheel_dist_info"]
158+
ConfigKey = WheelDistInfo
159+
Type = bool
160+
DefaultValue = false
161+
Optional = true
162+
Inherit = true
163+
Help = Controls whether python_wheel outputs the module's .dist-info directory by default.
164+
157165
[PluginConfig "prereleases"]
158166
DefaultValue = false
159167
Type = bool

build_defs/python.build_defs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,10 @@ def python_wheel(name:str, version:str, labels:list=[], hashes:list=None, packag
602602
"""
603603
binary = binary or entry_points
604604
package_name = package_name or name.replace('-', '_')
605+
if not outs:
606+
outs = [name]
607+
if CONFIG.PYTHON.WHEEL_DIST_INFO:
608+
outs += [f"{package_name}-{version}.dist-info"]
605609
initial = package_name[0]
606610
url_base = repo or CONFIG.PYTHON.WHEEL_REPO
607611
if not tool and not url_base:
@@ -667,7 +671,7 @@ def python_wheel(name:str, version:str, labels:list=[], hashes:list=None, packag
667671
cmd += [
668672
# N.B. we need -b for legacy locations because that's all zipimport knows to look for :(
669673
'$TOOLS_PYTHON -m compileall -b -f .',
670-
'$TOOLS_ARCAT z -d --prefix $PKG -i ' + ' -i '.join(outs or [name]),
674+
'$TOOLS_ARCAT z -d --prefix $PKG -i ' + ' -i '.join(outs),
671675
]
672676
label = f'whl:{package_name}=={version}'
673677

@@ -704,7 +708,7 @@ def python_wheel(name:str, version:str, labels:list=[], hashes:list=None, packag
704708
name = name,
705709
tag = "lib_rule" if binary else None,
706710
srcs = [wheel_rule],
707-
outs = outs or [name],
711+
outs = outs,
708712
tools = [CONFIG.ARCAT_TOOL],
709713
cmd = cmd,
710714
deps = deps,

0 commit comments

Comments
 (0)