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

Method set_executable

pex/pex_builder.py:244–268  ·  view source on GitHub ↗

Set the executable for this environment. :param filename: The file that should be executed within the PEX environment when the PEX is invoked. :keyword env_filename: (optional) The name that the executable file should be stored as within the PEX. By default this

(self, filename, env_filename=None)

Source from the content-addressed store, hash-verified

242 self._pex_info.add_requirement(req)
243
244 def set_executable(self, filename, env_filename=None):
245 """Set the executable for this environment.
246
247 :param filename: The file that should be executed within the PEX environment when the PEX is
248 invoked.
249 :keyword env_filename: (optional) The name that the executable file should be stored as within
250 the PEX. By default this will be the base name of the given filename.
251
252 The entry point of the PEX may also be specified via ``PEXBuilder.set_entry_point``.
253 """
254 self._ensure_unfrozen("Setting the executable")
255 if self._pex_info.script:
256 raise self.InvalidExecutableSpecification(
257 "Cannot set both entry point and script of PEX!"
258 )
259 if env_filename is None:
260 env_filename = os.path.basename(filename)
261 if self._chroot.get("executable"):
262 raise self.InvalidExecutableSpecification(
263 "Setting executable on a PEXBuilder that already has one!"
264 )
265 self._copy_or_link(filename, env_filename, "executable")
266 entry_point = env_filename
267 entry_point = entry_point.replace(os.path.sep, ".")
268 self._pex_info.entry_point = entry_point.rpartition(".")[0]
269
270 def set_script(self, script):
271 """Set the entry point of this PEX environment based upon a distribution script.

Callers 11

_pip_installationFunction · 0.95
build_pexFunction · 0.95
test_pex_executableFunction · 0.95
test_pex_run_strip_envFunction · 0.95
write_and_run_simple_pexFunction · 0.95
build_and_checkFunction · 0.95
test_build_compressionFunction · 0.95
write_simple_pexFunction · 0.95

Calls 3

_ensure_unfrozenMethod · 0.95
_copy_or_linkMethod · 0.95
getMethod · 0.45

Tested by 8

test_pex_executableFunction · 0.76
test_pex_run_strip_envFunction · 0.76
write_and_run_simple_pexFunction · 0.76
build_and_checkFunction · 0.76
test_build_compressionFunction · 0.76