Reputation: 3249
I embedded Python 3.7 into my C++ application and ship my own Python installation. Here is my application directory (for Windows and macOS):
- foo.exe
- foo.app/
- python37/
|- bin/ <-- for macOS
| |- python
|
|- Lib/
| |...
| |- site-packages/
|
|- python.exe
Executing the following commands on Windows installs the modules correctly in the site-packages directory.
$ python.exe get-pip.py
$ pip3 install xyz
However, on macOS the following command...
$ export PYTHONHOME=/path/to/foo/python37
$ bin/python get-pip.py
...installs pip
in ./python37/Lib/python37/site-packages
. Which means the subfolder in Lib/python37
is incorrect. Does anyone know why this happens? PYTHONHOME seems to be correctly set (simply the first ./python37
) and I don't have an explanation for that behaviour.
Upvotes: 4
Views: 508
Reputation: 2195
The answer is heavily based upon the installation references provided by the python3 guide. install guide
Python modules can be built from scratch using build and install commands: (Also, can be done in one run with python setup.py install
)
python setup.py build
python setup.py install
Now, I would not concentrate towards build, but more on the install. The install command typically copies all the build/lib
files into a choosen directory and if no directory is choosen then default is chosen. The location varies from platform to platform, also there are variants in them as well like Unix (Pure) and Unix (Non Pure). Now, let us look at the following below:
Unix (pure)1: /usr/local/lib/pythonX.Y/site-packages
Unix (non-pure): /usr/local/lib/pythonX.Y/site-packages
Windows: C:\PythonXY\Lib\site-packages
Now, it can be seen that by default for Unix platforms the /lib/pythonX.Y
is added by default. This behavior can also be modified specifying options during python setup.py install
(More on install guide about it) I have not tried them myself.
Upvotes: 2