Skip to content

Commit 8aa6918

Browse files
committed
unify mappings
1 parent 269602f commit 8aa6918

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

python/private/pypi/pep508_env.bzl

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,23 @@ platform_machine_select_map = {
6464

6565
# Platform system returns results from the `uname` call.
6666
_platform_system_values = {
67+
# See https://peps.python.org/pep-0738/#platform
68+
"android": "Android",
69+
"freebsd": "FreeBSD",
70+
# See https://peps.python.org/pep-0730/#platform
71+
# NOTE: Per Pep 730, "iPadOS" is also an acceptable value
72+
"ios": "iOS",
6773
"linux": "Linux",
74+
"netbsd": "NetBSD",
75+
"openbsd": "OpenBSD",
6876
"osx": "Darwin",
6977
"windows": "Windows",
7078
}
7179

7280
platform_system_select_map = {
73-
# See https://peps.python.org/pep-0738/#platform
74-
"@platforms//os:android": "Android",
75-
"@platforms//os:freebsd": "FreeBSD",
76-
# See https://peps.python.org/pep-0730/#platform
77-
# NOTE: Per Pep 730, "iPadOS" is also an acceptable value
78-
"@platforms//os:ios": "iOS",
79-
"@platforms//os:linux": "Linux",
80-
"@platforms//os:netbsd": "NetBSD",
81-
"@platforms//os:openbsd": "OpenBSD",
82-
"@platforms//os:osx": "Darwin",
83-
"@platforms//os:windows": "Windows",
81+
"@platforms//os:{}".format(bazel_os): py_system
82+
for bazel_os, py_system in _platform_system_values.items()
83+
} | {
8484
# The value is empty string if it cannot be determined:
8585
# https://docs.python.org/3/library/platform.html#platform.machine
8686
"//conditions:default": "",
@@ -112,46 +112,46 @@ platform_system_select_map = {
112112
#
113113
# We are using only the subset that we actually support.
114114
_sys_platform_values = {
115+
# These values are decided by the sys.platform docs.
116+
"android": "android",
117+
"emscripten": "emscripten",
118+
# NOTE: The below values are approximations. The sys.platform() docs
119+
# don't have documented values for these OSes. Per docs, the
120+
# sys.platform() value reflects the OS at the time Python was *built*
121+
# instead of the runtime (target) OS value.
122+
"freebsd": "freebsd",
123+
"ios": "ios",
115124
"linux": "linux",
125+
"openbsd": "openbsd",
116126
"osx": "darwin",
127+
"wasi": "wasi",
117128
"windows": "win32",
118129
}
119130

120-
# Taken from
121-
# https://docs.python.org/3/library/sys.html#sys.platform
122131
sys_platform_select_map = {
123-
# These values are decided by the sys.platform docs.
124-
"@platforms//os:android": "android",
125-
"@platforms//os:emscripten": "emscripten",
126-
# NOTE: The below values are approximations. The sys.platform() docs
127-
# don't have documented values for these OSes. Per docs, the
128-
# sys.platform() value reflects the OS at the time Python was *built*
129-
# instead of the runtime (target) OS value.
130-
"@platforms//os:freebsd": "freebsd",
131-
"@platforms//os:ios": "ios",
132-
"@platforms//os:linux": "linux",
133-
"@platforms//os:openbsd": "openbsd",
134-
"@platforms//os:osx": "darwin",
135-
"@platforms//os:wasi": "wasi",
136-
"@platforms//os:windows": "win32",
132+
"@platforms//os:{}".format(bazel_os): py_platform
133+
for bazel_os, py_platform in _sys_platform_values.items()
134+
} | {
137135
# For lack of a better option, use empty string. No standard doc/spec
138136
# about sys_platform value.
139137
"//conditions:default": "",
140138
}
141139

140+
# The "java" value is documented, but with Jython defunct,
141+
# shouldn't occur in practice.
142+
# The os.name value is technically a property of the runtime, not the
143+
# targetted runtime OS, but the distinction shouldn't matter if
144+
# things are properly configured.
142145
_os_name_values = {
143146
"linux": "posix",
144147
"osx": "posix",
145148
"windows": "nt",
146149
}
147150

148151
os_name_select_map = {
149-
# The "java" value is documented, but with Jython defunct,
150-
# shouldn't occur in practice.
151-
# The os.name value is technically a property of the runtime, not the
152-
# targetted runtime OS, but the distinction shouldn't matter if
153-
# things are properly configured.
154-
"@platforms//os:windows": "nt",
152+
"@platforms//os:{}".format(bazel_os): py_os
153+
for bazel_os, py_os in _os_name_values.items()
154+
} | {
155155
"//conditions:default": "posix",
156156
}
157157

0 commit comments

Comments
 (0)