Skip to content

Commit ef78f42

Browse files
Re-Ordering of commands + Adding get-variant-hash as a rapid tool to compute a variant hash`
1 parent 86fae03 commit ef78f42

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ test = [
6060
variantlib = "variantlib.commands.main:main"
6161

6262
[project.entry-points."variantlib.actions"]
63-
analyze-wheel = "variantlib.commands.analyze_wheel:analyze_wheel"
6463
analyze-platform = "variantlib.commands.analyze_platform:analyze_platform"
64+
analyze-wheel = "variantlib.commands.analyze_wheel:analyze_wheel"
6565
config = "variantlib.commands.config.main:main"
6666
generate-index-json = "variantlib.commands.generate_index_json:generate_index_json"
67+
get-variant-hash = "variantlib.commands.get_variant_hash:get_variant_hash"
6768
make-variant = "variantlib.commands.make_variant:make_variant"
68-
unmake-variant = "variantlib.commands.unmake_variant:unmake_variant"
6969
plugins = "variantlib.commands.plugins.main:main"
70+
unmake-variant = "variantlib.commands.unmake_variant:unmake_variant"
7071
update-pyproject-toml = "variantlib.commands.update_pyproject_toml:update_pyproject_toml"
7172

7273
[project.entry-points."variantlib.actions.config"]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from __future__ import annotations
2+
3+
import argparse
4+
import sys
5+
6+
from variantlib import __package_name__
7+
from variantlib.api import VariantDescription
8+
from variantlib.api import VariantProperty
9+
from variantlib.constants import METADATA_VARIANT_HASH_HEADER
10+
11+
12+
def get_variant_hash(args: list[str]) -> None:
13+
parser = argparse.ArgumentParser(
14+
prog=f"{__package_name__} get-variant-hash",
15+
description="Compute the variant hash of a set of variant properties.",
16+
)
17+
18+
parser.add_argument(
19+
"-p",
20+
"--property",
21+
dest="properties",
22+
type=VariantProperty.from_str,
23+
action="extend",
24+
nargs="+",
25+
help=(
26+
"Variant Properties to add to the Wheel Variant, can be repeated as many "
27+
"times as needed"
28+
),
29+
default=[],
30+
)
31+
32+
parsed_args = parser.parse_args(args)
33+
34+
_print_variant_hash(properties=parsed_args.properties)
35+
36+
37+
def _print_variant_hash(properties: list[VariantProperty]) -> None:
38+
# Transform properties into a VariantDescription
39+
vdesc = VariantDescription(properties=properties)
40+
41+
sys.stdout.write(f"{METADATA_VARIANT_HASH_HEADER}: {vdesc.hexdigest}\n")

variantlib/commands/make_variant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def make_variant(args: list[str]) -> None:
5555
group = parser.add_mutually_exclusive_group(required=True)
5656

5757
group.add_argument(
58-
"-P",
58+
"-p",
5959
"--property",
6060
dest="properties",
6161
type=VariantProperty.from_str,

0 commit comments

Comments
 (0)