MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / Environment

Class Environment

etc/scripts/utils_thirdparty.py:1512–1598  ·  view source on GitHub ↗

An Environment describes a target installation environment with its supported Python version, ABI, platform, implementation and related attributes. We can use these to pass as `pip download` options and force fetching only the subset of packages that match these Environment con

Source from the content-addressed store, hash-verified

1510
1511@attr.attributes
1512class Environment:
1513 """
1514 An Environment describes a target installation environment with its
1515 supported Python version, ABI, platform, implementation and related
1516 attributes.
1517
1518 We can use these to pass as `pip download` options and force fetching only
1519 the subset of packages that match these Environment constraints as opposed
1520 to the current running Python interpreter constraints.
1521 """
1522
1523 python_version = attr.ib(
1524 type=str,
1525 default="",
1526 metadata=dict(help="Python version supported by this environment."),
1527 )
1528
1529 operating_system = attr.ib(
1530 type=str,
1531 default="",
1532 metadata=dict(help="operating system supported by this environment."),
1533 )
1534
1535 implementation = attr.ib(
1536 type=str,
1537 default="cp",
1538 metadata=dict(help="Python implementation supported by this environment."),
1539 repr=False,
1540 )
1541
1542 abis = attr.ib(
1543 type=list,
1544 default=attr.Factory(list),
1545 metadata=dict(help="List of ABI tags supported by this environment."),
1546 repr=False,
1547 )
1548
1549 platforms = attr.ib(
1550 type=list,
1551 default=attr.Factory(list),
1552 metadata=dict(help="List of platform tags supported by this environment."),
1553 repr=False,
1554 )
1555
1556 @classmethod
1557 def from_pyver_and_os(cls, python_version, operating_system):
1558 if "." in python_version:
1559 python_version = "".join(python_version.split("."))
1560
1561 return cls(
1562 python_version=python_version,
1563 implementation="cp",
1564 abis=ABIS_BY_PYTHON_VERSION[python_version],
1565 platforms=PLATFORMS_BY_OS[operating_system],
1566 operating_system=operating_system,
1567 )
1568
1569 def get_pip_cli_options(self):

Callers 4

regenerateFunction · 0.85
get_templateFunction · 0.85
generateFunction · 0.85
generateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected