MCPcopy
hub / github.com/pex-tool/pex / create

Method create

pex/cache/dirs.py:853–906  ·  view source on GitHub ↗
(
        cls,
        sdist,  # type: str
        fingerprint,  # type: str
        pnav=None,  # type: Optional[ProjectNameAndVersion]
        target=None,  # type: Optional[Target]
        editable=False,  # type: bool
        pex_root=ENV,  # type: Union[str, Variables]
    )

Source from the content-addressed store, hash-verified

851
852 @classmethod
853 def create(
854 cls,
855 sdist, # type: str
856 fingerprint, # type: str
857 pnav=None, # type: Optional[ProjectNameAndVersion]
858 target=None, # type: Optional[Target]
859 editable=False, # type: bool
860 pex_root=ENV, # type: Union[str, Variables]
861 ):
862 # type: (...) -> BuiltWheelDir
863
864 from pex import targets
865 from pex.dist_metadata import is_sdist
866
867 if is_sdist(sdist):
868 dist_type = "sdists"
869 file_name = os.path.basename(sdist)
870 dist_name = file_name
871 else:
872 dist_type = "editable_projects" if editable else "local_projects"
873 file_name = None
874 dist_name = str(
875 base64.urlsafe_b64encode(hashlib.sha1(sdist.encode("utf-8")).digest())
876 .decode("utf-8")
877 .rstrip("=")
878 )
879
880 # For the purposes of building a wheel from source, the product should be uniqued by the
881 # wheel name which is unique on the host os up to the python and abi tags. In other words,
882 # the product of a CPython 2.7.6 wheel build and a CPython 2.7.18 wheel build should be
883 # functionally interchangeable if the two CPython interpreters have matching abis.
884 #
885 # However, this is foiled by at least two scenarios:
886 # 1. Running a vm / container with shared storage mounted. This can introduce a different
887 # platform on the host.
888 # 2. On macOS the same host can report / use different OS versions (c.f.: the
889 # MACOSX_DEPLOYMENT_TARGET environment variable and the 10.16 / 11.0 macOS Big Sur
890 # transitional case in particular).
891 #
892 # As such, we must be pessimistic and assume the wheel will be platform specific to the
893 # full extent possible.
894 interpreter = (target or targets.current()).get_interpreter()
895 target_tags = "{python_tag}-{abi_tag}-{platform_tag}".format(
896 python_tag=interpreter.identity.python_tag,
897 abi_tag=interpreter.identity.abi_tag,
898 platform_tag=interpreter.identity.platform_tag,
899 )
900 sdist_dir = CacheDir.BUILT_WHEELS.path(dist_type, dist_name, pex_root=pex_root)
901 dist_dir = os.path.join(sdist_dir, fingerprint, target_tags)
902
903 if is_sdist(sdist):
904 return cls(path=sdist_dir, dist_dir=dist_dir, file_name=file_name, pnav=pnav)
905 else:
906 return cls(path=dist_dir, dist_dir=dist_dir, file_name=file_name, pnav=pnav)
907
908 def __init__(
909 self,

Callers

nothing calls this directly

Calls 8

is_sdistFunction · 0.90
decodeMethod · 0.80
digestMethod · 0.45
encodeMethod · 0.45
get_interpreterMethod · 0.45
currentMethod · 0.45
pathMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected