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

Method compile

pex/compiler.py:81–103  ·  view source on GitHub ↗

Compiles the given python source files using this compiler's interpreter. :param root: The root path all the source files are found under. :param relpaths: The relative paths from the `root` of the source files to compile. :returns: A list of relative paths of the compiled b

(self, root, relpaths)

Source from the content-addressed store, hash-verified

79 self._interpreter = interpreter
80
81 def compile(self, root, relpaths):
82 # type: (str, Iterable[str]) -> List[Text]
83 """Compiles the given python source files using this compiler's interpreter.
84
85 :param root: The root path all the source files are found under.
86 :param relpaths: The relative paths from the `root` of the source files to compile.
87 :returns: A list of relative paths of the compiled bytecode files.
88 :raises: A :class:`Compiler.Error` if there was a problem bytecode compiling any of the files.
89 """
90 with named_temporary_file() as fp:
91 fp.write(
92 to_bytes(_COMPILER_MAIN % {"root": root, "relpaths": relpaths}, encoding="utf-8")
93 )
94 fp.flush()
95
96 try:
97 _, out, _ = self._interpreter.execute(args=[fp.name])
98 except Executor.NonZeroExit as e:
99 raise self.CompilationFailure(
100 "encountered %r during bytecode compilation.\nstderr was:\n%s\n" % (e, e.stderr)
101 )
102
103 return cast("Text", out).splitlines()

Callers 15

_precompile_sourceMethod · 0.95
compilationFunction · 0.95
PythonInterpreterClass · 0.80
ProjectNameClass · 0.80
ShimClass · 0.80
patch_wheel_modelFunction · 0.80
analyzeMethod · 0.80
_parse_regex_formsMethod · 0.80
_vcs_dir_filterFunction · 0.80
__init__Method · 0.80

Calls 5

named_temporary_fileFunction · 0.90
to_bytesFunction · 0.90
castFunction · 0.90
writeMethod · 0.45
executeMethod · 0.45

Tested by 5

compilationFunction · 0.76
test_parse_greedyFunction · 0.64
test_issue_1782Function · 0.64
test_boot_resolve_failFunction · 0.64
test_tailer_filterFunction · 0.64