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

Method build

pex/pex_builder.py:621–699  ·  view source on GitHub ↗

Package the PEX application. By default, the PEX is packaged as a zipapp for ease of shipping as a single file, but it can also be packaged in spread mode for efficiency of syncing over the network incrementally. :param path: The path where the PEX should be stored.

(
        self,
        path,  # type: str
        bytecode_compile=True,  # type: bool
        deterministic=False,  # type: bool
        layout=Layout.ZIPAPP,  # type: Layout.Value
        compress=True,  # type: bool
        check=Check.NONE,  # type: Check.Value
    )

Source from the content-addressed store, hash-verified

619 self._frozen = True
620
621 def build(
622 self,
623 path, # type: str
624 bytecode_compile=True, # type: bool
625 deterministic=False, # type: bool
626 layout=Layout.ZIPAPP, # type: Layout.Value
627 compress=True, # type: bool
628 check=Check.NONE, # type: Check.Value
629 ):
630 # type: (...) -> None
631 """Package the PEX application.
632
633 By default, the PEX is packaged as a zipapp for ease of shipping as a single file, but it
634 can also be packaged in spread mode for efficiency of syncing over the network
635 incrementally.
636
637 :param path: The path where the PEX should be stored.
638 :param bytecode_compile: If True, precompile .py files into .pyc files.
639 :param deterministic: If True, will use our hardcoded time for zipfile timestamps.
640 :param layout: The layout to use for the PEX.
641 :param compress: Whether to compress zip entries when building to a layout that uses zip
642 files.
643 :param check: The check to perform on the built PEX.
644 If the PEXBuilder is not yet frozen, it will be frozen by ``build``. This renders the
645 PEXBuilder immutable.
646 """
647 if not self._frozen:
648 self.freeze(bytecode_compile=bytecode_compile)
649
650 # The PEX building proceeds assuming a user will not race themselves building to a single
651 # non-PEX_ROOT output path they requested;
652 tmp_pex = path + "~"
653 if os.path.exists(tmp_pex):
654 self._logger.warning("Previous binary unexpectedly exists, cleaning: {}".format(path))
655 if os.path.isfile(tmp_pex):
656 os.unlink(tmp_pex)
657 else:
658 shutil.rmtree(tmp_pex, True)
659
660 if layout == Layout.LOOSE:
661 shutil.copytree(
662 self.path(),
663 tmp_pex,
664 ignore=None if bytecode_compile else lambda _, names: filter(is_pyc_file, names),
665 )
666 elif layout == Layout.PACKED:
667 self._build_packedapp(
668 dirname=tmp_pex,
669 deterministic=deterministic,
670 compress=compress,
671 bytecode_compile=bytecode_compile,
672 )
673 else:
674 self._build_zipapp(
675 filename=tmp_pex,
676 deterministic=deterministic,
677 compress=compress,
678 bytecode_compile=bytecode_compile,

Calls 10

freezeMethod · 0.95
pathMethod · 0.95
_build_packedappMethod · 0.95
_build_zipappMethod · 0.95
chmod_plus_xFunction · 0.90
safe_renameFunction · 0.90
safe_symlinkFunction · 0.90
safe_deleteFunction · 0.90
perform_checkMethod · 0.80
joinMethod · 0.45