1from typing import List, Optional
2
3from .base import BaseDistribution, BaseEnvironment
4
5__all__ = [
6    "BaseDistribution",
7    "BaseEnvironment",
8    "get_default_environment",
9    "get_environment",
10    "get_wheel_distribution",
11]
12
13
14def get_default_environment() -> BaseEnvironment:
15    """Get the default representation for the current environment.
16
17    This returns an Environment instance from the chosen backend. The default
18    Environment instance should be built from ``sys.path`` and may use caching
19    to share instance state accorss calls.
20    """
21    from .pkg_resources import Environment
22
23    return Environment.default()
24
25
26def get_environment(paths: Optional[List[str]]) -> BaseEnvironment:
27    """Get a representation of the environment specified by ``paths``.
28
29    This returns an Environment instance from the chosen backend based on the
30    given import paths. The backend must build a fresh instance representing
31    the state of installed distributions when this function is called.
32    """
33    from .pkg_resources import Environment
34
35    return Environment.from_paths(paths)
36
37
38def get_wheel_distribution(wheel_path: str, canonical_name: str) -> BaseDistribution:
39    """Get the representation of the specified wheel's distribution metadata.
40
41    This returns a Distribution instance from the chosen backend based on
42    the given wheel's ``.dist-info`` directory.
43
44    :param canonical_name: Normalized project name of the given wheel.
45    """
46    from .pkg_resources import Distribution
47
48    return Distribution.from_wheel(wheel_path, canonical_name)
49