How to correctly and safely move a python pyramid application? SEE BELOW, I updated the details after feedback in the comments.
I first used the following command to prepare the environment:
virtualenv --relocatable ENV
After that, the app was still working correctly. I then moved the python app to another directory, but get the following error:
[Thu Jul 27 16:09:08.884534 2017] [wsgi:error] [pid 14775] [remote 185.54.183.194:58084] mod_wsgi (pid=14775): Target WSGI script '/home/develop/web/checklist/prod/backend/pyramid.wsgi' cannot be loaded as Python module.
[Thu Jul 27 16:09:08.884660 2017] [wsgi:error] [pid 14775] [remote 185.54.183.194:58084] mod_wsgi (pid=14775): Exception occurred processing WSGI script '/home/develop/web/checklist/prod/backend/pyramid.wsgi'.
.......
[Thu Jul 27 16:09:08.886634 2017] [wsgi:error] [pid 14775] [remote
185.54.183.194:58084] pkg_resources.DistributionNotFound: The 'checklist' distribution was not found and is required by the application
(checklist is the python application). I changed the path's in the apache config of WSGIDaemonProcess and WSGIScriptAlias to the new location. And I changed the path in the pyramid.ini file used in WSGIDaemonProcess. My apache config:
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess checklistTest user=apache group=apache threads=4 python-path=/home/develop/web/test/checklist/backend:/home/develop/web/test/checklist/backend/env/lib/python3.4/site-packages
WSGIScriptAlias /bdh-checklist-test /home/develop/web/test/checklist/backend/pyramid.wsgi
<Directory /home/develop/web/test/checklist/backend>
WSGIProcessGroup checklistTest
Require all granted
</Directory>
I updated the above config after feedback from Graham. I compiled mod_wsgi with the same python version as used by the python app (version 3.4). However, I still can't use the python-home attribute, it results in a timeout error (with the relocatable environment):
Timeout when reading response headers from daemon process 'checklistTest':
In case I use the python-home, the above DaemonProcess entry looks like:
WSGIDaemonProcess checklistTest user=apache group=apache threads=4 python-home=/home/develop/web/test/checklist/backend/env/lib/python3.4
How to solve this? Why should I use the python-home instead of python-path? I have to include the path to the app itself in the python-app attribute, else the apache log will contain an error saying that it can't find the app distribution.