Let’s say I have a pip package with an executable (console_scripts
in entry_points
).
I can decide to install it in a random directory by using pip install --target <DIR> <PKG>
.
If I am also using a Python interpreter in a non-standard location, like for example:
<MY_PYTHON>/python -m pip install --target <DIR> <PKG>
pip
will be smart enough to generate a shebang that points to this location, DIR/bin/PKG
will contain:
#!<MY_PYTHON>/python
# -*- coding: utf-8 -*-
Now, the question is, is there any way, through command-line options, to make pip
also add something that goes like this:
import os
file_path = os.path.realpath(__file__)
sys.path.append(os.path.dirname(os.path.dirname(file_path)))
so that the console script automatically finds its main Python code?