Skip to content

Commit 8c752d5

Browse files
committed
Support appending plugin labels to wheel names
1 parent baff058 commit 8c752d5

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

demo-plugins/blas_plugin.py

Whitespace-only changes.

demo-plugins/demo_plugins.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from variantlib.base import PluginBase
2+
from variantlib.config import ProviderConfig
3+
from variantlib.meta import VariantDescription
4+
5+
6+
class BlasPlugin(PluginBase):
7+
namespace = "blas"
8+
9+
def get_supported_configs(self) -> ProviderConfig:
10+
return None
11+
12+
def get_variant_labels(self, variant_desc: VariantDescription) -> list[str]:
13+
for meta in variant_desc:
14+
if meta.namespace == "blas" and meta.key == "variant":
15+
return [meta.value]
16+
return []
17+
18+
19+
class X8664Plugin(PluginBase):
20+
namespace = "x86_64"
21+
22+
def get_supported_configs(self) -> ProviderConfig:
23+
return None
24+
25+
def get_variant_labels(self, variant_desc: VariantDescription) -> list[str]:
26+
for meta in variant_desc:
27+
if meta.namespace == "x86_64" and meta.key == "baseline":
28+
return [f"x86_64_{meta.value}"]
29+
return []

demo-plugins/pyproject.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[build-system]
2+
requires = ["flit_core>=3.2,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "demo-plugins"
7+
version = "0"
8+
description = "Demo plugins for meson-python/numpy variants"
9+
dependencies = ["variantlib"]
10+
11+
[project.entry-points."variantlib.plugins"]
12+
blas = "demo_plugins:BlasPlugin"
13+
x86_64 = "demo_plugins:X8664Plugin"

mesonpy/__init__.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,20 @@ def tag(self) -> mesonpy._tags.Tag:
353353
return mesonpy._tags.Tag('py3', 'none', None)
354354
return mesonpy._tags.Tag(None, self._stable_abi, None)
355355

356-
@property
357-
def _variant_suffix(self) -> str:
358-
if self._variant is not None:
359-
return f"-{self._variant.hexdigest}"
360-
return ""
361-
362356
@property
363357
def name(self) -> str:
364358
"""Wheel name, this includes the basename and tag."""
365-
return f'{self._metadata.distribution_name}-{self._metadata.version}-{self.tag}{self._variant_suffix}'
359+
name = f'{self._metadata.distribution_name}-{self._metadata.version}-{self.tag}'
360+
if self._variant is not None:
361+
name += f'-{self._variant.hexdigest}'
362+
labels = PluginLoader().get_variant_labels(self._variant)
363+
for numlabels in range(len(labels), 0, -1):
364+
long_name = "+".join((name, *labels[:numlabels]))
365+
# if labels would give us filename that's longer than 128
366+
# characters (124 + .whl), strip them
367+
if len(long_name) < 124:
368+
return long_name
369+
return name
366370

367371
@property
368372
def _distinfo_dir(self) -> str:

0 commit comments

Comments
 (0)