Reputation: 83798
I am trying to get PyCrypto working with Google App Engine, and I have a lengthy description of an issue I have encountered that is reported as issue 7925 for Google App Engine.
Essentially, I do not know of a sensible way to install PyCrypto on Mac OS X 10.8 in such a way that dev_appserver.py
will use it - other than the workaround of putting Crypto/
into the project's root directory.
Unfortunately an issue seems to have just cropped up that causes a project to crash when the project is deployed with Crypto/
in the project's root.
It may be possible to edit or monkeypatch the GAE code, but I am not familiar enough with GAE's code to be comfortable doing that. All of the suggestions I have seen were for Python2.5 and Mac OS X < 10.8.
I would be grateful for thoughts about alternative, sensible ways to get PyCrypto working with the GAE development appserver on Mac OS X 10.8.
Upvotes: 7
Views: 2081
Reputation: 83798
This is the madness I have had to engage in:
Delete all version of PyCrypto
Download PyCrypto v2.3 from https://github.com/dlitz/pycrypto/tags and install with
dlitz-pycrypto-7e141bd/$ python setup.py build
dlitz-pycrypto-7e141bd/$ sudo python setup.py install
(version 2.6 balks with a no blockalgo
package)
Apply to dev_appserver_import_hook.py
in /Application/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/
the patch suggested in comment 1 of Issue 1627, i.e. add
try:
import Crypto as _CryptoTest
_CryptoBase = os.path.dirname(_CryptoTest.__file__).replace(
os.path.join(os.path.dirname(os.__file__), 'site-packages'),
"") # removes preceding slash
del _CryptoTest
except ImportError:
logging.info("No Crypto could be imported")
_CryptoBase = "Crypto"
around line 314
then modify the ALLOWED_SITE_PACKAGES lines from
ALLOWED_SITE_PACKAGE_FILES = set(
os.path.normcase(os.path.abspath(os.path.join(
os.path.dirname(os.__file__), 'site-packages', path)))
to
ALLOWED_SITE_PACKAGE_FILES = set(
path
and change all references from 'Crypto'
to _CryptoBase
in the GeneratePythonPaths
calls for ALLOWED_SITE_PACKAGES.
(I would expect if one is using dev_appserver from the command line i.e. /usr/local/google_appengine, the dev_appserver_import_hook.py would be modified there)
Restart the project.
Obviously one must rinse and repeat the patch whenever Google App Engine is updated.
Note — This issue appears to have been fixed as of patch 1.7.4 released 14 Dec. 2012.
Upvotes: 4