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:

Linking the wrapper manually

The original Python scripts are stored in EPYTHON-named subdirectories of /usr/lib/python-exec:

Installing scripts manually

Ebuilds that are relying on python-exec:2 need to pull it explicitly into the dependencies. When it is installed, the eclass will automatically start using it:

Requesting python-exec:2

python-exec:0
This is the previous version of Python script wrapper.

The wrapper is installed to bindir: /usr/bin/python-exec. Therefore, if it is necessary to link it manually:

Linking the wrapper manually

The original Python scripts are appended -${EPYTHON} suffix:

Installing scripts manually

Ebuilds that are relying on python-exec:0 need to force it via the following snippet:

Requesting python-exec:0