Skip to content

Commit b2c73c0

Browse files
committed
more cleanup
1 parent 104c27b commit b2c73c0

File tree

6 files changed

+15
-38
lines changed

6 files changed

+15
-38
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
55
# To update these lines, execute
66
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
7-
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
8-
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
7+
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,examples/scratch,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
8+
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,examples/scratch,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered,tests/modules/other,tests/modules/other/nspkg_delta,tests/modules/other/nspkg_gamma
99

1010
test --test_output=errors
1111

python/config_settings/BUILD.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,12 @@ define_pypi_internal_flags(
221221
name = "define_pypi_internal_flags",
222222
)
223223

224-
# todo: have single --pypi_env_config flag instead? Under the hood, it
225-
# could be driven more more discrete flags, which could be considered an
226-
# implementation detail of our particular impl.
227-
# A label is used to allow users to use select() to affect the value.
228-
# A target providing BuildSettingInfo is used to allow users to define
229-
# a flag as the target, which lets them CLI-override or transition it easily.
230224
label_flag(
231225
name = "pip_platform_release_config",
232226
build_setting_default = ":_pip_platform_release_default_config",
233227
visibility = ["//visibility:public"],
234228
)
235229

236-
# docs: points to a label that provides BuildSettingInfo for the value.
237-
# A label and BuildSettingInfo are used for the same reason as platform_release
238230
label_flag(
239231
name = "pip_platform_version_config",
240232
build_setting_default = ":_pip_platform_version_default_config",

python/private/pypi/env_marker_setting.bzl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ load(
66
":pep508_env.bzl",
77
"env_aliases",
88
"os_name_select_map",
9-
"platform_machine_aliases",
109
"platform_machine_select_map",
1110
"platform_system_select_map",
1211
"sys_platform_select_map",
@@ -47,10 +46,7 @@ def env_marker_setting(*, name, expression, **kwargs):
4746
**kwargs
4847
)
4948

50-
# todo: maybe put all the env into a single target and have a
51-
# PyPiEnvMarkersInfo provider? Have --pypi_env=//some:target?
5249
def _env_marker_setting_impl(ctx):
53-
# todo: should unify with pep508_env.bzl
5450
env = {}
5551

5652
runtime = ctx.toolchains[TARGET_TOOLCHAIN_TYPE].py3_runtime
@@ -65,7 +61,7 @@ def _env_marker_setting_impl(ctx):
6561
env["implementation_version"] = full_version
6662
else:
6763
env["python_version"] = _get_flag(ctx.attr._python_version_major_minor_flag)
68-
full_version = _get_flag(ctx.attr._python_full_version)
64+
full_version = _get_flag(ctx.attr._python_full_version_flag)
6965
env["python_full_version"] = full_version
7066
env["implementation_version"] = full_version
7167

python/private/pypi/flags.bzl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ def define_pypi_internal_flags(name):
9191
)
9292
_platform_version_config(
9393
name = "_pip_platform_version_default_config",
94-
value = select({
95-
"@platforms//os:osx": "USE_OSX_VERSION_FLAG",
96-
"//conditions:default": "",
97-
}),
9894
visibility = ["//visibility:public"],
9995
)
10096

@@ -134,14 +130,10 @@ _platform_release_config = rule(
134130
)
135131

136132
def _platform_version_config_impl(ctx):
137-
value = ctx.attr.value
138-
return [BuildSettingInfo(value = ctx.attr.value)]
133+
return [BuildSettingInfo(value = "")]
139134

140135
# Despite its name, this "version" value is not a simple version value.
141136
# It's a more detailed, arbitrary, description the OS gives about itself.
142137
_platform_version_config = rule(
143138
implementation = _platform_version_config_impl,
144-
attrs = {
145-
"value": attr.string(),
146-
},
147139
)

python/private/pypi/pep508_env.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ sys_platform_select_map = {
124124
# These values are decided by the sys.platform docs.
125125
"@platforms//os:android": "android",
126126
"@platforms//os:emscripten": "emscripten",
127-
"@platforms//os:ios": "ios",
128-
"@platforms//os:linux": "linux",
129-
"@platforms//os:osx": "darwin",
130-
"@platforms//os:windows": "win32",
131-
"@platforms//os:wasi": "wasi",
132127
# NOTE: The below values are approximations. The sys.platform() docs
133128
# don't have documented values for these OSes. Per docs, the
134129
# sys.platform() value reflects the OS at the time Python was *built*
135130
# instead of the runtime (target) OS value.
136131
"@platforms//os:freebsd": "freebsd",
132+
"@platforms//os:ios": "ios",
133+
"@platforms//os:linux": "linux",
137134
"@platforms//os:openbsd": "openbsd",
135+
"@platforms//os:osx": "darwin",
136+
"@platforms//os:wasi": "wasi",
137+
"@platforms//os:windows": "win32",
138138
# For lack of a better option, use empty string. No standard doc/spec
139139
# about sys_platform value.
140140
"//conditions:default": "",

tests/pypi/env_marker_setting/env_marker_setting_tests.bzl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
22
load("@rules_testing//lib:test_suite.bzl", "test_suite")
33
load("@rules_testing//lib:util.bzl", "TestingAspectInfo")
44
load("//python/private/pypi:env_marker_setting.bzl", "env_marker_setting")
5-
load("//python/private/pypi:pep508_env.bzl", pep508_env = "env") # buildifier: disable=bzl-visibility
6-
load("//python/private/pypi:pep508_evaluate.bzl", "evaluate", "tokenize") # buildifier: disable=bzl-visibility
75
load("//tests/support:support.bzl", "PYTHON_VERSION")
86

97
_tests = []
108

119
def _test_expr(name):
1210
def impl(env, target):
13-
# todo: create FeatureFlagInfo subject
1411
env.expect.where(
1512
expression = target[TestingAspectInfo].attrs.expression,
1613
).that_str(
@@ -20,19 +17,19 @@ def _test_expr(name):
2017
)
2118

2219
cases = {
23-
"python_version_gte": {
24-
"expression": "python_version >= '3.12.0'",
25-
"expected": "TRUE",
20+
"python_full_version_lt_negative": {
2621
"config_settings": {
2722
PYTHON_VERSION: "3.12.0",
2823
},
29-
},
30-
"python_full_version_lt_negative": {
31-
"expression": "python_full_version < '3.8'",
3224
"expected": "FALSE",
25+
"expression": "python_full_version < '3.8'",
26+
},
27+
"python_version_gte": {
3328
"config_settings": {
3429
PYTHON_VERSION: "3.12.0",
3530
},
31+
"expected": "TRUE",
32+
"expression": "python_version >= '3.12.0'",
3633
},
3734
}
3835

0 commit comments

Comments
 (0)