pex-tool / pex

A tool for generating .pex (Python EXecutable) files, lock files and venvs.
https://docs.pex-tool.org
Apache License 2.0
2.49k stars 254 forks source link

Add `--provided`: like `--exclude`, but require the excluded project is available at boot time. #2426

Open jsirois opened 1 month ago

jsirois commented 1 month ago

The --exclude feature is a very sharp tool. It requires you know to arrange the excluded project is made available to the PEX at runtime through --inherit-path / PEX_INHERIT_PATH or PEX_EXTRA_SYS_PATH in the case where the exclusion was configured to save size / bandwidth when the PEX is being deployed to an environment with pre-installed appropriate projects (the huge ML wheel case).

Ideally, Pex would support --provided and instead of discovering a missing --excluded project some time after PEX boot when the import finally triggers (this could be an arbitrary time in the future for dynamic plugin systems or in code with lazy imports in infrequently used code paths.

This idea was originally described here: https://github.com/pex-tool/pex/issues/2097#issuecomment-1743370744