PyCrypto on Google App Engine (1.7.0) with Python 2.7 on Mac OS X 10.8 raises ImportError

I am trying to get PyCrypto to work with the Google App Engine, and I have a detailed description of the problem I am facing, which is called issue 7925 for the Google App Engine.

In fact, I don’t know a reasonable way to install PyCrypto on Mac OS X 10.8 so that dev_appserver.py will use it - except for a workaround to add Crypto/ to the project root directory.

Unfortunately, the problem just appeared, which leads to the failure of the project when deploying the project with Crypto/ in the root of the project.

It may be possible to edit or defuse the GAE code, but I am not good enough in GAE code to make this convenient. All the suggestions I saw were for Python2.5 and Mac OS X <10.8.

I would be grateful for the thoughts on alternative, reasonable ways to get PyCrypto to work with the GAE application server in Mac OS X 10.8.

+7
source share
1 answer

This is the madness that I had to participate in:

  • Uninstall all versions of PyCrypto

  • Download PyCrypto v2.3 from https://github.com/dlitz/pycrypto/tags and install using

     dlitz-pycrypto-7e141bd/$ python setup.py build dlitz-pycrypto-7e141bd/$ sudo python setup.py install 

    (version 2.6 is forbidden with the no blockalgo )

  • Apply to dev_appserver_import_hook.py in /Application/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/ patch suggested in comment 1 is /Application/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/ from number 1

     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 change the lines ALLOWED_SITE_PACKAGES 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 GeneratePythonPaths for ALLOWED_SITE_PACKAGES.

    (I would expect if you use dev_appserver from the command line ie / usr / local / google_appengine, dev_appserver_import_hook.py will be changed there)

  • Restart the project.

Obviously, every time the Google App Engine application is updated, it is necessary to rinse and repeat the patch.


Note This issue seems to be fixed with patch 1.7.4 released on December 14, 2012 .

+4
source

All Articles