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)
| 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. |