Skip to content

Commit 1595154

Browse files
committed
fix the config setting getting and add docs
1 parent 484f8ef commit 1595154

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

python/private/pypi/pep508_deps.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _platform_str(self):
111111

112112
minor_version = self.abi[3:]
113113
if self.arch == None and self.os == None:
114-
return "@//python/config_settings:is_python_3.{}".format(minor_version)
114+
return str(Label("//python/config_settings:is_python_3.{}".format(minor_version)))
115115

116116
return "cp3{}_{}_{}".format(
117117
minor_version,

python/private/pypi/pep508_env.bzl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""This module is for implementing PEP508 environment definition.
1616
"""
1717

18-
# See https://stackoverflow.com/questions/45125516/possible-values-for-uname-m
18+
# See https://stackoverflow.com/a/45125525
1919
_platform_machine_aliases = {
2020
# These pairs mean the same hardware, but different values may be used
2121
# on different host platforms.
@@ -24,13 +24,41 @@ _platform_machine_aliases = {
2424
"i386": "x86_32",
2525
"i686": "x86_32",
2626
}
27+
28+
# Platform system returns results from the `uname` call.
2729
_platform_system_values = {
2830
"linux": "Linux",
2931
"osx": "Darwin",
3032
"windows": "Windows",
3133
}
34+
35+
# The copy of SO [answer](https://stackoverflow.com/a/13874620) containing
36+
# all of the platforms:
37+
# ┍━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━┑
38+
# │ System │ Value │
39+
# ┝━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━┥
40+
# │ Linux │ linux or linux2 (*) │
41+
# │ Windows │ win32 │
42+
# │ Windows/Cygwin │ cygwin │
43+
# │ Windows/MSYS2 │ msys │
44+
# │ Mac OS X │ darwin │
45+
# │ OS/2 │ os2 │
46+
# │ OS/2 EMX │ os2emx │
47+
# │ RiscOS │ riscos │
48+
# │ AtheOS │ atheos │
49+
# │ FreeBSD 7 │ freebsd7 │
50+
# │ FreeBSD 8 │ freebsd8 │
51+
# │ FreeBSD N │ freebsdN │
52+
# │ OpenBSD 6 │ openbsd6 │
53+
# │ AIX │ aix (**) │
54+
# ┕━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━┙
55+
#
56+
# (*) Prior to Python 3.3, the value for any Linux version is always linux2; after, it is linux.
57+
# (**) Prior Python 3.8 could also be aix5 or aix7; use sys.platform.startswith()
58+
#
59+
# We are using only the subset that we actually support.
3260
_sys_platform_values = {
33-
"linux": "posix",
61+
"linux": "linux",
3462
"osx": "darwin",
3563
"windows": "win32",
3664
}

tests/pypi/pep508/deps_tests.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ def _test_can_get_version_select(env):
264264

265265
env.expect.that_collection(got.deps).contains_exactly(["bar"])
266266
env.expect.that_dict(got.deps_select).contains_exactly({
267-
"@//python/config_settings:is_python_3.7": ["baz"],
268-
"@//python/config_settings:is_python_3.8": ["baz_new"],
269-
"@//python/config_settings:is_python_3.9": ["baz_new"],
267+
str(Label("//python/config_settings:is_python_3.7")): ["baz"],
268+
str(Label("//python/config_settings:is_python_3.8")): ["baz_new"],
269+
str(Label("//python/config_settings:is_python_3.9")): ["baz_new"],
270270
"@platforms//os:linux": ["baz", "posix_dep"],
271271
"cp37_linux_anyarch": ["baz", "posix_dep"],
272272
"cp37_linux_x86_64": ["arch_dep", "baz", "posix_dep"],
@@ -370,7 +370,7 @@ def _test_deps_are_not_duplicated_when_encountering_platform_dep_first(env):
370370
# I am not sure why. The starlark version behaviour looks more correct.
371371
env.expect.that_collection(got.deps).contains_exactly([])
372372
env.expect.that_dict(got.deps_select).contains_exactly({
373-
"@//python/config_settings:is_python_3.10": ["bar"],
373+
str(Label("//python/config_settings:is_python_3.10")): ["bar"],
374374
"cp310_linux_aarch64": ["bar"],
375375
"cp37_linux_aarch64": ["bar"],
376376
"linux_aarch64": ["bar"],

0 commit comments

Comments
 (0)