Exemplo n.º 1
0
    def _prepare_code(self):
        self._pex_info.code_hash = CacheHelper.pex_code_hash(
            self._chroot.path())

        hasher = hashlib.sha1()
        hasher.update("code:{}".format(
            self._pex_info.code_hash).encode("utf-8"))
        for location, sha in sorted(self._pex_info.distributions.items()):
            hasher.update("{}:{}".format(location, sha).encode("utf-8"))
        self._pex_info.pex_hash = hasher.hexdigest()

        self._chroot.write(self._pex_info.dump().encode("utf-8"),
                           PexInfo.PATH,
                           label="manifest")

        bootstrap = BOOTSTRAP_ENVIRONMENT.format(
            bootstrap_dir=BOOTSTRAP_DIR,
            pex_root=self._pex_info.raw_pex_root,
            pex_hash=self._pex_info.pex_hash,
            interpreter_constraints=self._pex_info.interpreter_constraints,
            is_unzip=self._pex_info.unzip,
            is_venv=self._pex_info.venv,
        )
        self._chroot.write(to_bytes(self._preamble + "\n" + bootstrap),
                           "__main__.py",
                           label="main")
Exemplo n.º 2
0
    def _prepare_code(self):
        self._pex_info.code_hash = CacheHelper.pex_code_hash(
            self._chroot.path())
        self._pex_info.pex_hash = hashlib.sha1(
            self._pex_info.dump().encode("utf-8")).hexdigest()
        self._chroot.write(self._pex_info.dump().encode("utf-8"),
                           PexInfo.PATH,
                           label="manifest")

        bootstrap = BOOTSTRAP_ENVIRONMENT.format(
            bootstrap_dir=BOOTSTRAP_DIR,
            pex_root=self._pex_info.raw_pex_root,
            pex_hash=self._pex_info.pex_hash,
            interpreter_constraints=self._pex_info.interpreter_constraints,
            pex_path=self._pex_info.pex_path,
            is_unzip=self._pex_info.unzip,
            is_venv=self._pex_info.venv,
        )
        self._chroot.write(to_bytes(self._preamble + "\n" + bootstrap),
                           "__main__.py",
                           label="main")