Skip to content

Commit

Permalink
fixup the generation of the config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
aignas committed Oct 22, 2024
1 parent 9b296d2 commit 77754c2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
18 changes: 7 additions & 11 deletions python/private/pypi/config_settings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,6 @@ def config_settings(
constraint_values.append("@platforms//cpu:" + cpu)
suffix += "_" + cpu

if suffix:
# Add python version + platform config settings
_dist_config_setting(
name = suffix.strip("_"),
flag_values = {},
python_version = python_version,
is_python = is_python,
visibility = visibility,
native = native,
)

_dist_config_settings(
suffix = suffix,
plat_flag_values = _plat_flag_values(
Expand All @@ -159,6 +148,13 @@ def config_settings(
)

def _dist_config_settings(*, suffix, plat_flag_values, **kwargs):
if kwargs.get("constraint_values"):
# Add python version + platform config settings
_dist_config_setting(
name = suffix.strip("_"),
**kwargs
)

flag_values = {_flags.dist: ""}

# First create an sdist, we will be building upon the flag values, which
Expand Down
23 changes: 17 additions & 6 deletions tests/pypi/render_pkg_aliases/render_pkg_aliases_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,19 @@ def _test_multiplatform_whl_aliases_filename_versioned(env):

_tests.append(_test_multiplatform_whl_aliases_filename_versioned)

def _mock_alias(container):
return lambda name, **kwargs: container.append(name)

def _mock_config_setting(container):
def _inner(name, flag_values = None, constraint_values = None, **_):
if flag_values or constraint_values:
container.append(name)
return

fail("At least one of 'flag_values' or 'constraint_values' needs to be set")

return _inner

def _test_config_settings_exist_legacy(env):
aliases = [
whl_alias(
Expand All @@ -787,12 +800,11 @@ def _test_config_settings_exist_legacy(env):
),
]
available_config_settings = []
mock_rule = lambda name, **kwargs: available_config_settings.append(name)
config_settings(
python_versions = ["3.11"],
native = struct(
alias = mock_rule,
config_setting = mock_rule,
alias = _mock_alias(available_config_settings),
config_setting = _mock_config_setting(available_config_settings),
),
target_platforms = [
"linux_aarch64",
Expand Down Expand Up @@ -846,12 +858,11 @@ def _test_config_settings_exist(env):
),
]
available_config_settings = []
mock_rule = lambda name, **kwargs: available_config_settings.append(name)
config_settings(
python_versions = ["3.11"],
native = struct(
alias = mock_rule,
config_setting = mock_rule,
alias = _mock_alias(available_config_settings),
config_setting = _mock_config_setting(available_config_settings),
),
**kwargs
)
Expand Down

0 comments on commit 77754c2

Please sign in to comment.