MCPcopy Index your code
hub / github.com/pex-tool/pex / create_isolated_cmd

Method create_isolated_cmd

pex/interpreter.py:1629–1687  ·  view source on GitHub ↗
(
        self,
        args=None,  # type: Optional[Iterable[str]]
        pythonpath=None,  # type: Optional[Iterable[str]]
        env=None,  # type: Optional[Mapping[str, str]]
    )

Source from the content-addressed store, hash-verified

1627 )
1628
1629 def create_isolated_cmd(
1630 self,
1631 args=None, # type: Optional[Iterable[str]]
1632 pythonpath=None, # type: Optional[Iterable[str]]
1633 env=None, # type: Optional[Mapping[str, str]]
1634 ):
1635 # type: (...) -> Tuple[Iterable[str], Mapping[str, str]]
1636 env_copy = dict(env or os.environ)
1637
1638 if self._identity.configured_macosx_deployment_target:
1639 # System interpreters on mac have a history of bad configuration from one source or
1640 # another. See `cls._sanitized_environment` for one example of this.
1641 #
1642 # When a Python interpreter is used to build platform specific wheels on a mac, it needs
1643 # to report a platform of `macosx-X.Y-<machine>` to conform to PEP-425 & PyPAs
1644 # `packaging` tags library. The X.Y release is derived from the MACOSX_DEPLOYMENT_TARGET
1645 # sysconfig (Makefile) variable. Sometimes the configuration is provided by a user
1646 # building a custom Python. See https://github.com/pypa/wheel/issues/385 for an example
1647 # where MACOSX_DEPLOYMENT_TARGET is set to 11. Other times the configuration is provided
1648 # by the system maintainer (Apple). See https://github.com/pantsbuild/pants/issues/11061
1649 # for an example of this via XCode 12s system Python 3.8 interpreter which reports
1650 # 10.14.6.
1651 release = self._identity.configured_macosx_deployment_target
1652 version = release.split(".")
1653 if len(version) == 1:
1654 release = "{}.0".format(version[0])
1655 elif len(version) > 2:
1656 release = ".".join(version[:2])
1657
1658 if release != self._identity.configured_macosx_deployment_target:
1659 osname, _, machine = sysconfig.get_platform().split("-")
1660 pep425_compatible_platform = "{osname}-{release}-{machine}".format(
1661 osname=osname, release=release, machine=machine
1662 )
1663 # An undocumented feature of `sysconfig.get_platform()` is respect for the
1664 # _PYTHON_HOST_PLATFORM environment variable. We can fix up badly configured macOS
1665 # interpreters by influencing the platform this way, which is enough to get wheels
1666 # building with proper platform tags. This is supported for the CPythons we support:
1667 # + https://github.com/python/cpython/blob/v2.7.18/Lib/sysconfig.py#L567-L569
1668 # ... through ...
1669 # + https://github.com/python/cpython/blob/v3.9.2/Lib/sysconfig.py#L652-L654
1670 TRACER.log(
1671 "Correcting mis-configured MACOSX_DEPLOYMENT_TARGET of {} to {} corresponding "
1672 "to a valid PEP-425 platform of {} for {}.".format(
1673 self._identity.configured_macosx_deployment_target,
1674 release,
1675 pep425_compatible_platform,
1676 self,
1677 )
1678 )
1679 env_copy.update(_PYTHON_HOST_PLATFORM=pep425_compatible_platform)
1680
1681 return self._create_isolated_cmd(
1682 self.binary,
1683 args=args,
1684 pythonpath=pythonpath,
1685 env=env_copy,
1686 version=self.version,

Callers 3

executeMethod · 0.95
open_processMethod · 0.95
cmdlineMethod · 0.80

Calls 4

_create_isolated_cmdMethod · 0.95
logMethod · 0.80
joinMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected