Project:Python/python-exec

python-exec is the tool used to wrap Python scripts for multiple implementations. In the process of wrapping, the original Python script is replaced by a special wrapper executable that invokes a proper version of the original script depending on which Python interpreter is used/requested.

It is recommended to assume that the details of script wrapping are treated private implementation detail and not relied upon within ebuilds. If that rule is respected, the ebuilds in question work properly with any of the wrapper versions installed. Otherwise, the ebuilds need to enforce a particular version of wrapper and be updated every time a new wrapper is released.

Guarantees of the wrapper
The wrapper guarantees that:


 * The wrapped scripts can be run either through /usr/bin/foo or python /usr/bin/foo.
 * When run via python /usr/bin/foo, the currently running Python implementation will be respected.
 * When run via /usr/bin/foo, the implementation choice respects following preferences:
 * EPYTHON environment variable,
 * eselect-python choices,
 * eclass-defined implementation order.

python-exec:2
python-exec2 is the modern Python wrapper. The differences from the old wrapper are:


 * tab-completion is no longer polluted by wrapped scripts,
 * basename(sys.argv[0]) is not changed by the wrapping (the path is),
 * script preference can be implemented using proper PATH with no explicit need to call the wrapper executable.

The wrapper is installed to a private location: /usr/lib/python-exec/python-exec2. Therefore, if it is necessary to link it manually:

The original Python scripts are stored in PYTHON_SCRIPTDIR: