mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-05 09:27:38 +08:00
Support environment markers in requires fields (#12711)
This commit is contained in:
@@ -28,8 +28,8 @@ You can list or install all of a stubs package's external dependencies using the
|
||||
(.venv3)$ python tests/get_external_stub_requirements.py <third_party_stub1> <third_party_stub2> # List external dependencies for <third_party_stub1> and <third_party_stub2>
|
||||
(.venv3)$ python tests/get_external_stub_requirements.py # List external dependencies for all third-party stubs in typeshed
|
||||
# Install external dependencies for all third-party stubs in typeshed
|
||||
(.venv3)$ DEPENDENCIES=$(python tests/get_external_stub_requirements.py)
|
||||
(.venv3)$ if [ -n "$DEPENDENCIES" ]; then pip install $DEPENDENCIES; fi
|
||||
(.venv3)$ mapfile -t DEPENDENCIES < <( python tests/get_external_stub_requirements.py )
|
||||
(.venv3)$ if [ -n "$DEPENDENCIES" ]; then pip install "${DEPENDENCIES[@]}"; fi
|
||||
```
|
||||
|
||||
## Run all tests for a specific stub
|
||||
|
||||
@@ -289,8 +289,6 @@ def read_metadata(distribution: str) -> StubMetadata:
|
||||
|
||||
def parse_requires(distribution: str, req: object) -> Requirement:
|
||||
assert isinstance(req, str), f"Invalid requirement {req!r} for {distribution!r}"
|
||||
for space in " \t\n":
|
||||
assert space not in req, f"For consistency, requirement should not have whitespace: {req!r}"
|
||||
return Requirement(req)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# TODO: It should be possible to specify the Python version and platform
|
||||
# and limit the output to the packages that are compatible with that version
|
||||
# and platform.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
@@ -163,7 +163,12 @@ def _is_supported_stdlib_version(module_versions: SupportedVersionsDict, filenam
|
||||
|
||||
|
||||
def _get_pkgs_associated_with_requirement(req_name: str) -> list[str]:
|
||||
dist = importlib.metadata.distribution(req_name)
|
||||
try:
|
||||
dist = importlib.metadata.distribution(req_name)
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
# The package wasn't installed, probably because an environment
|
||||
# marker excluded it.
|
||||
return []
|
||||
toplevel_txt_contents = dist.read_text("top_level.txt")
|
||||
if toplevel_txt_contents is None:
|
||||
if dist.files is None:
|
||||
|
||||
Reference in New Issue
Block a user