casbin-async-django-orm-adapter 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. async_casbin_adapter/__init__.py +0 -0
  2. async_casbin_adapter/adapter.py +100 -0
  3. async_casbin_adapter/apps.py +24 -0
  4. async_casbin_adapter/enforcer.py +81 -0
  5. async_casbin_adapter/migrations/0001_initial.py +37 -0
  6. async_casbin_adapter/migrations/__init__.py +0 -0
  7. async_casbin_adapter/models.py +48 -0
  8. async_casbin_adapter/utils.py +25 -0
  9. casbin_async_django_orm_adapter-1.0.0.dist-info/METADATA +116 -0
  10. casbin_async_django_orm_adapter-1.0.0.dist-info/RECORD +74 -0
  11. casbin_async_django_orm_adapter-1.0.0.dist-info/WHEEL +5 -0
  12. casbin_async_django_orm_adapter-1.0.0.dist-info/licenses/LICENSE +201 -0
  13. casbin_async_django_orm_adapter-1.0.0.dist-info/top_level.txt +3 -0
  14. node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py +45 -0
  15. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +365 -0
  16. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
  17. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1272 -0
  18. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
  19. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
  20. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +152 -0
  21. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +270 -0
  22. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
  23. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +704 -0
  24. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py +709 -0
  25. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +173 -0
  26. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +169 -0
  27. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +113 -0
  28. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
  29. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  30. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +805 -0
  31. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1172 -0
  32. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1319 -0
  33. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +128 -0
  34. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +104 -0
  35. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +462 -0
  36. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
  37. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +56 -0
  38. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2745 -0
  39. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3976 -0
  40. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
  41. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2965 -0
  42. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +67 -0
  43. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1391 -0
  44. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +26 -0
  45. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py +3112 -0
  46. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +99 -0
  47. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +767 -0
  48. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1260 -0
  49. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
  50. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
  51. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +373 -0
  52. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1939 -0
  53. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +54 -0
  54. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +303 -0
  55. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3196 -0
  56. node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
  57. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +15 -0
  58. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +108 -0
  59. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +252 -0
  60. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +83 -0
  61. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +359 -0
  62. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +61 -0
  63. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +192 -0
  64. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/markers.py +252 -0
  65. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +825 -0
  66. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  67. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +90 -0
  68. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +1030 -0
  69. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/tags.py +553 -0
  70. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/utils.py +172 -0
  71. node_modules/npm/node_modules/node-gyp/gyp/pylib/packaging/version.py +563 -0
  72. node_modules/npm/node_modules/node-gyp/gyp/test_gyp.py +261 -0
  73. node_modules/semantic-release-pypi/dist/py/set_version.py +32 -0
  74. node_modules/semantic-release-pypi/dist/py/verify_setup.py +24 -0
@@ -0,0 +1,553 @@
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+ import logging
6
+ import platform
7
+ import struct
8
+ import subprocess
9
+ import sys
10
+ import sysconfig
11
+ from importlib.machinery import EXTENSION_SUFFIXES
12
+ from typing import (
13
+ Dict,
14
+ FrozenSet,
15
+ Iterable,
16
+ Iterator,
17
+ List,
18
+ Optional,
19
+ Sequence,
20
+ Tuple,
21
+ Union,
22
+ cast,
23
+ )
24
+
25
+ from . import _manylinux, _musllinux
26
+
27
+ logger = logging.getLogger(__name__)
28
+
29
+ PythonVersion = Sequence[int]
30
+ MacVersion = Tuple[int, int]
31
+
32
+ INTERPRETER_SHORT_NAMES: Dict[str, str] = {
33
+ "python": "py", # Generic.
34
+ "cpython": "cp",
35
+ "pypy": "pp",
36
+ "ironpython": "ip",
37
+ "jython": "jy",
38
+ }
39
+
40
+
41
+ _32_BIT_INTERPRETER = struct.calcsize("P") == 4
42
+
43
+
44
+ class Tag:
45
+ """
46
+ A representation of the tag triple for a wheel.
47
+
48
+ Instances are considered immutable and thus are hashable. Equality checking
49
+ is also supported.
50
+ """
51
+
52
+ __slots__ = ["_interpreter", "_abi", "_platform", "_hash"]
53
+
54
+ def __init__(self, interpreter: str, abi: str, platform: str) -> None:
55
+ self._interpreter = interpreter.lower()
56
+ self._abi = abi.lower()
57
+ self._platform = platform.lower()
58
+ # The __hash__ of every single element in a Set[Tag] will be evaluated each time
59
+ # that a set calls its `.disjoint()` method, which may be called hundreds of
60
+ # times when scanning a page of links for packages with tags matching that
61
+ # Set[Tag]. Pre-computing the value here produces significant speedups for
62
+ # downstream consumers.
63
+ self._hash = hash((self._interpreter, self._abi, self._platform))
64
+
65
+ @property
66
+ def interpreter(self) -> str:
67
+ return self._interpreter
68
+
69
+ @property
70
+ def abi(self) -> str:
71
+ return self._abi
72
+
73
+ @property
74
+ def platform(self) -> str:
75
+ return self._platform
76
+
77
+ def __eq__(self, other: object) -> bool:
78
+ if not isinstance(other, Tag):
79
+ return NotImplemented
80
+
81
+ return (
82
+ (self._hash == other._hash) # Short-circuit ASAP for perf reasons.
83
+ and (self._platform == other._platform)
84
+ and (self._abi == other._abi)
85
+ and (self._interpreter == other._interpreter)
86
+ )
87
+
88
+ def __hash__(self) -> int:
89
+ return self._hash
90
+
91
+ def __str__(self) -> str:
92
+ return f"{self._interpreter}-{self._abi}-{self._platform}"
93
+
94
+ def __repr__(self) -> str:
95
+ return f"<{self} @ {id(self)}>"
96
+
97
+
98
+ def parse_tag(tag: str) -> FrozenSet[Tag]:
99
+ """
100
+ Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
101
+
102
+ Returning a set is required due to the possibility that the tag is a
103
+ compressed tag set.
104
+ """
105
+ tags = set()
106
+ interpreters, abis, platforms = tag.split("-")
107
+ for interpreter in interpreters.split("."):
108
+ for abi in abis.split("."):
109
+ for platform_ in platforms.split("."):
110
+ tags.add(Tag(interpreter, abi, platform_))
111
+ return frozenset(tags)
112
+
113
+
114
+ def _get_config_var(name: str, warn: bool = False) -> Union[int, str, None]:
115
+ value: Union[int, str, None] = sysconfig.get_config_var(name)
116
+ if value is None and warn:
117
+ logger.debug(
118
+ "Config variable '%s' is unset, Python ABI tag may be incorrect", name
119
+ )
120
+ return value
121
+
122
+
123
+ def _normalize_string(string: str) -> str:
124
+ return string.replace(".", "_").replace("-", "_").replace(" ", "_")
125
+
126
+
127
+ def _abi3_applies(python_version: PythonVersion) -> bool:
128
+ """
129
+ Determine if the Python version supports abi3.
130
+
131
+ PEP 384 was first implemented in Python 3.2.
132
+ """
133
+ return len(python_version) > 1 and tuple(python_version) >= (3, 2)
134
+
135
+
136
+ def _cpython_abis(py_version: PythonVersion, warn: bool = False) -> List[str]:
137
+ py_version = tuple(py_version) # To allow for version comparison.
138
+ abis = []
139
+ version = _version_nodot(py_version[:2])
140
+ debug = pymalloc = ucs4 = ""
141
+ with_debug = _get_config_var("Py_DEBUG", warn)
142
+ has_refcount = hasattr(sys, "gettotalrefcount")
143
+ # Windows doesn't set Py_DEBUG, so checking for support of debug-compiled
144
+ # extension modules is the best option.
145
+ # https://github.com/pypa/pip/issues/3383#issuecomment-173267692
146
+ has_ext = "_d.pyd" in EXTENSION_SUFFIXES
147
+ if with_debug or (with_debug is None and (has_refcount or has_ext)):
148
+ debug = "d"
149
+ if py_version < (3, 8):
150
+ with_pymalloc = _get_config_var("WITH_PYMALLOC", warn)
151
+ if with_pymalloc or with_pymalloc is None:
152
+ pymalloc = "m"
153
+ if py_version < (3, 3):
154
+ unicode_size = _get_config_var("Py_UNICODE_SIZE", warn)
155
+ if unicode_size == 4 or (
156
+ unicode_size is None and sys.maxunicode == 0x10FFFF
157
+ ):
158
+ ucs4 = "u"
159
+ elif debug:
160
+ # Debug builds can also load "normal" extension modules.
161
+ # We can also assume no UCS-4 or pymalloc requirement.
162
+ abis.append(f"cp{version}")
163
+ abis.insert(
164
+ 0,
165
+ "cp{version}{debug}{pymalloc}{ucs4}".format(
166
+ version=version, debug=debug, pymalloc=pymalloc, ucs4=ucs4
167
+ ),
168
+ )
169
+ return abis
170
+
171
+
172
+ def cpython_tags(
173
+ python_version: Optional[PythonVersion] = None,
174
+ abis: Optional[Iterable[str]] = None,
175
+ platforms: Optional[Iterable[str]] = None,
176
+ *,
177
+ warn: bool = False,
178
+ ) -> Iterator[Tag]:
179
+ """
180
+ Yields the tags for a CPython interpreter.
181
+
182
+ The tags consist of:
183
+ - cp<python_version>-<abi>-<platform>
184
+ - cp<python_version>-abi3-<platform>
185
+ - cp<python_version>-none-<platform>
186
+ - cp<less than python_version>-abi3-<platform> # Older Python versions down to 3.2.
187
+
188
+ If python_version only specifies a major version then user-provided ABIs and
189
+ the 'none' ABItag will be used.
190
+
191
+ If 'abi3' or 'none' are specified in 'abis' then they will be yielded at
192
+ their normal position and not at the beginning.
193
+ """
194
+ if not python_version:
195
+ python_version = sys.version_info[:2]
196
+
197
+ interpreter = f"cp{_version_nodot(python_version[:2])}"
198
+
199
+ if abis is None:
200
+ if len(python_version) > 1:
201
+ abis = _cpython_abis(python_version, warn)
202
+ else:
203
+ abis = []
204
+ abis = list(abis)
205
+ # 'abi3' and 'none' are explicitly handled later.
206
+ for explicit_abi in ("abi3", "none"):
207
+ try:
208
+ abis.remove(explicit_abi)
209
+ except ValueError:
210
+ pass
211
+
212
+ platforms = list(platforms or platform_tags())
213
+ for abi in abis:
214
+ for platform_ in platforms:
215
+ yield Tag(interpreter, abi, platform_)
216
+ if _abi3_applies(python_version):
217
+ yield from (Tag(interpreter, "abi3", platform_) for platform_ in platforms)
218
+ yield from (Tag(interpreter, "none", platform_) for platform_ in platforms)
219
+
220
+ if _abi3_applies(python_version):
221
+ for minor_version in range(python_version[1] - 1, 1, -1):
222
+ for platform_ in platforms:
223
+ interpreter = "cp{version}".format(
224
+ version=_version_nodot((python_version[0], minor_version))
225
+ )
226
+ yield Tag(interpreter, "abi3", platform_)
227
+
228
+
229
+ def _generic_abi() -> List[str]:
230
+ """
231
+ Return the ABI tag based on EXT_SUFFIX.
232
+ """
233
+ # The following are examples of `EXT_SUFFIX`.
234
+ # We want to keep the parts which are related to the ABI and remove the
235
+ # parts which are related to the platform:
236
+ # - linux: '.cpython-310-x86_64-linux-gnu.so' => cp310
237
+ # - mac: '.cpython-310-darwin.so' => cp310
238
+ # - win: '.cp310-win_amd64.pyd' => cp310
239
+ # - win: '.pyd' => cp37 (uses _cpython_abis())
240
+ # - pypy: '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38_pp73
241
+ # - graalpy: '.graalpy-38-native-x86_64-darwin.dylib'
242
+ # => graalpy_38_native
243
+
244
+ ext_suffix = _get_config_var("EXT_SUFFIX", warn=True)
245
+ if not isinstance(ext_suffix, str) or ext_suffix[0] != ".":
246
+ raise SystemError("invalid sysconfig.get_config_var('EXT_SUFFIX')")
247
+ parts = ext_suffix.split(".")
248
+ if len(parts) < 3:
249
+ # CPython3.7 and earlier uses ".pyd" on Windows.
250
+ return _cpython_abis(sys.version_info[:2])
251
+ soabi = parts[1]
252
+ if soabi.startswith("cpython"):
253
+ # non-windows
254
+ abi = "cp" + soabi.split("-")[1]
255
+ elif soabi.startswith("cp"):
256
+ # windows
257
+ abi = soabi.split("-")[0]
258
+ elif soabi.startswith("pypy"):
259
+ abi = "-".join(soabi.split("-")[:2])
260
+ elif soabi.startswith("graalpy"):
261
+ abi = "-".join(soabi.split("-")[:3])
262
+ elif soabi:
263
+ # pyston, ironpython, others?
264
+ abi = soabi
265
+ else:
266
+ return []
267
+ return [_normalize_string(abi)]
268
+
269
+
270
+ def generic_tags(
271
+ interpreter: Optional[str] = None,
272
+ abis: Optional[Iterable[str]] = None,
273
+ platforms: Optional[Iterable[str]] = None,
274
+ *,
275
+ warn: bool = False,
276
+ ) -> Iterator[Tag]:
277
+ """
278
+ Yields the tags for a generic interpreter.
279
+
280
+ The tags consist of:
281
+ - <interpreter>-<abi>-<platform>
282
+
283
+ The "none" ABI will be added if it was not explicitly provided.
284
+ """
285
+ if not interpreter:
286
+ interp_name = interpreter_name()
287
+ interp_version = interpreter_version(warn=warn)
288
+ interpreter = "".join([interp_name, interp_version])
289
+ if abis is None:
290
+ abis = _generic_abi()
291
+ else:
292
+ abis = list(abis)
293
+ platforms = list(platforms or platform_tags())
294
+ if "none" not in abis:
295
+ abis.append("none")
296
+ for abi in abis:
297
+ for platform_ in platforms:
298
+ yield Tag(interpreter, abi, platform_)
299
+
300
+
301
+ def _py_interpreter_range(py_version: PythonVersion) -> Iterator[str]:
302
+ """
303
+ Yields Python versions in descending order.
304
+
305
+ After the latest version, the major-only version will be yielded, and then
306
+ all previous versions of that major version.
307
+ """
308
+ if len(py_version) > 1:
309
+ yield f"py{_version_nodot(py_version[:2])}"
310
+ yield f"py{py_version[0]}"
311
+ if len(py_version) > 1:
312
+ for minor in range(py_version[1] - 1, -1, -1):
313
+ yield f"py{_version_nodot((py_version[0], minor))}"
314
+
315
+
316
+ def compatible_tags(
317
+ python_version: Optional[PythonVersion] = None,
318
+ interpreter: Optional[str] = None,
319
+ platforms: Optional[Iterable[str]] = None,
320
+ ) -> Iterator[Tag]:
321
+ """
322
+ Yields the sequence of tags that are compatible with a specific version of Python.
323
+
324
+ The tags consist of:
325
+ - py*-none-<platform>
326
+ - <interpreter>-none-any # ... if `interpreter` is provided.
327
+ - py*-none-any
328
+ """
329
+ if not python_version:
330
+ python_version = sys.version_info[:2]
331
+ platforms = list(platforms or platform_tags())
332
+ for version in _py_interpreter_range(python_version):
333
+ for platform_ in platforms:
334
+ yield Tag(version, "none", platform_)
335
+ if interpreter:
336
+ yield Tag(interpreter, "none", "any")
337
+ for version in _py_interpreter_range(python_version):
338
+ yield Tag(version, "none", "any")
339
+
340
+
341
+ def _mac_arch(arch: str, is_32bit: bool = _32_BIT_INTERPRETER) -> str:
342
+ if not is_32bit:
343
+ return arch
344
+
345
+ if arch.startswith("ppc"):
346
+ return "ppc"
347
+
348
+ return "i386"
349
+
350
+
351
+ def _mac_binary_formats(version: MacVersion, cpu_arch: str) -> List[str]:
352
+ formats = [cpu_arch]
353
+ if cpu_arch == "x86_64":
354
+ if version < (10, 4):
355
+ return []
356
+ formats.extend(["intel", "fat64", "fat32"])
357
+
358
+ elif cpu_arch == "i386":
359
+ if version < (10, 4):
360
+ return []
361
+ formats.extend(["intel", "fat32", "fat"])
362
+
363
+ elif cpu_arch == "ppc64":
364
+ # TODO: Need to care about 32-bit PPC for ppc64 through 10.2?
365
+ if version > (10, 5) or version < (10, 4):
366
+ return []
367
+ formats.append("fat64")
368
+
369
+ elif cpu_arch == "ppc":
370
+ if version > (10, 6):
371
+ return []
372
+ formats.extend(["fat32", "fat"])
373
+
374
+ if cpu_arch in {"arm64", "x86_64"}:
375
+ formats.append("universal2")
376
+
377
+ if cpu_arch in {"x86_64", "i386", "ppc64", "ppc", "intel"}:
378
+ formats.append("universal")
379
+
380
+ return formats
381
+
382
+
383
+ def mac_platforms(
384
+ version: Optional[MacVersion] = None, arch: Optional[str] = None
385
+ ) -> Iterator[str]:
386
+ """
387
+ Yields the platform tags for a macOS system.
388
+
389
+ The `version` parameter is a two-item tuple specifying the macOS version to
390
+ generate platform tags for. The `arch` parameter is the CPU architecture to
391
+ generate platform tags for. Both parameters default to the appropriate value
392
+ for the current system.
393
+ """
394
+ version_str, _, cpu_arch = platform.mac_ver()
395
+ if version is None:
396
+ version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2])))
397
+ if version == (10, 16):
398
+ # When built against an older macOS SDK, Python will report macOS 10.16
399
+ # instead of the real version.
400
+ version_str = subprocess.run(
401
+ [
402
+ sys.executable,
403
+ "-sS",
404
+ "-c",
405
+ "import platform; print(platform.mac_ver()[0])",
406
+ ],
407
+ check=True,
408
+ env={"SYSTEM_VERSION_COMPAT": "0"},
409
+ stdout=subprocess.PIPE,
410
+ text=True,
411
+ ).stdout
412
+ version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2])))
413
+ else:
414
+ version = version
415
+ if arch is None:
416
+ arch = _mac_arch(cpu_arch)
417
+ else:
418
+ arch = arch
419
+
420
+ if (10, 0) <= version and version < (11, 0):
421
+ # Prior to Mac OS 11, each yearly release of Mac OS bumped the
422
+ # "minor" version number. The major version was always 10.
423
+ for minor_version in range(version[1], -1, -1):
424
+ compat_version = 10, minor_version
425
+ binary_formats = _mac_binary_formats(compat_version, arch)
426
+ for binary_format in binary_formats:
427
+ yield "macosx_{major}_{minor}_{binary_format}".format(
428
+ major=10, minor=minor_version, binary_format=binary_format
429
+ )
430
+
431
+ if version >= (11, 0):
432
+ # Starting with Mac OS 11, each yearly release bumps the major version
433
+ # number. The minor versions are now the midyear updates.
434
+ for major_version in range(version[0], 10, -1):
435
+ compat_version = major_version, 0
436
+ binary_formats = _mac_binary_formats(compat_version, arch)
437
+ for binary_format in binary_formats:
438
+ yield "macosx_{major}_{minor}_{binary_format}".format(
439
+ major=major_version, minor=0, binary_format=binary_format
440
+ )
441
+
442
+ if version >= (11, 0):
443
+ # Mac OS 11 on x86_64 is compatible with binaries from previous releases.
444
+ # Arm64 support was introduced in 11.0, so no Arm binaries from previous
445
+ # releases exist.
446
+ #
447
+ # However, the "universal2" binary format can have a
448
+ # macOS version earlier than 11.0 when the x86_64 part of the binary supports
449
+ # that version of macOS.
450
+ if arch == "x86_64":
451
+ for minor_version in range(16, 3, -1):
452
+ compat_version = 10, minor_version
453
+ binary_formats = _mac_binary_formats(compat_version, arch)
454
+ for binary_format in binary_formats:
455
+ yield "macosx_{major}_{minor}_{binary_format}".format(
456
+ major=compat_version[0],
457
+ minor=compat_version[1],
458
+ binary_format=binary_format,
459
+ )
460
+ else:
461
+ for minor_version in range(16, 3, -1):
462
+ compat_version = 10, minor_version
463
+ binary_format = "universal2"
464
+ yield "macosx_{major}_{minor}_{binary_format}".format(
465
+ major=compat_version[0],
466
+ minor=compat_version[1],
467
+ binary_format=binary_format,
468
+ )
469
+
470
+
471
+ def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:
472
+ linux = _normalize_string(sysconfig.get_platform())
473
+ if not linux.startswith("linux_"):
474
+ # we should never be here, just yield the sysconfig one and return
475
+ yield linux
476
+ return
477
+ if is_32bit:
478
+ if linux == "linux_x86_64":
479
+ linux = "linux_i686"
480
+ elif linux == "linux_aarch64":
481
+ linux = "linux_armv8l"
482
+ _, arch = linux.split("_", 1)
483
+ archs = {"armv8l": ["armv8l", "armv7l"]}.get(arch, [arch])
484
+ yield from _manylinux.platform_tags(archs)
485
+ yield from _musllinux.platform_tags(archs)
486
+ for arch in archs:
487
+ yield f"linux_{arch}"
488
+
489
+
490
+ def _generic_platforms() -> Iterator[str]:
491
+ yield _normalize_string(sysconfig.get_platform())
492
+
493
+
494
+ def platform_tags() -> Iterator[str]:
495
+ """
496
+ Provides the platform tags for this installation.
497
+ """
498
+ if platform.system() == "Darwin":
499
+ return mac_platforms()
500
+ elif platform.system() == "Linux":
501
+ return _linux_platforms()
502
+ else:
503
+ return _generic_platforms()
504
+
505
+
506
+ def interpreter_name() -> str:
507
+ """
508
+ Returns the name of the running interpreter.
509
+
510
+ Some implementations have a reserved, two-letter abbreviation which will
511
+ be returned when appropriate.
512
+ """
513
+ name = sys.implementation.name
514
+ return INTERPRETER_SHORT_NAMES.get(name) or name
515
+
516
+
517
+ def interpreter_version(*, warn: bool = False) -> str:
518
+ """
519
+ Returns the version of the running interpreter.
520
+ """
521
+ version = _get_config_var("py_version_nodot", warn=warn)
522
+ if version:
523
+ version = str(version)
524
+ else:
525
+ version = _version_nodot(sys.version_info[:2])
526
+ return version
527
+
528
+
529
+ def _version_nodot(version: PythonVersion) -> str:
530
+ return "".join(map(str, version))
531
+
532
+
533
+ def sys_tags(*, warn: bool = False) -> Iterator[Tag]:
534
+ """
535
+ Returns the sequence of tag triples for the running interpreter.
536
+
537
+ The order of the sequence corresponds to priority order for the
538
+ interpreter, from most to least important.
539
+ """
540
+
541
+ interp_name = interpreter_name()
542
+ if interp_name == "cp":
543
+ yield from cpython_tags(warn=warn)
544
+ else:
545
+ yield from generic_tags()
546
+
547
+ if interp_name == "pp":
548
+ interp = "pp3"
549
+ elif interp_name == "cp":
550
+ interp = "cp" + interpreter_version(warn=warn)
551
+ else:
552
+ interp = None
553
+ yield from compatible_tags(interpreter=interp)