[MacPorts] #68542: pycryptodome fails with google appengine cloud SDK, pycrypto works
MacPorts
noreply at macports.org
Tue Oct 24 20:38:51 UTC 2023
#68542: pycryptodome fails with google appengine cloud SDK, pycrypto works
----------------------+----------------------------------------------------
Reporter: katzlbt | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.8.1
Resolution: | Keywords: pycrypto pycryptodome google-cloud-sdk
Port: |
----------------------+----------------------------------------------------
Description changed by ryandesign:
Old description:
> Google appengine standard environment (Google cloud SDK) uses a sandbox
> that prohibits the use of _ctype. pycryptodome uses _ctype, which fails
> to import in the cloud sdk sandbox "ImportError: No module named
> _ctypes". This was really hard to diagnose correctly.
>
> This incompatibility should be documented in the package descriptions of
> both ports, as pycryptodome is not a 100% replacement for pycrypto.
>
> WORKAROUND: download and manually build pycrypto-2.6.1
>
> Traceback (most recent call last):
> File "/Users/cat/google-cloud-
> sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py",
> line 238, in Handle
> handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
> File "/Users/cat/google-cloud-
> sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py",
> line 309, in _LoadHandler
> handler, path, err = LoadObject(self._handler)
> File "/Users/cat/google-cloud-
> sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py",
> line 83, in LoadObject
> obj = __import__(path[0])
> File "/Users/cat/repositories/locandy-web/app/main.py", line 65, in
> <module>
> pyramid_config = app_config()
> File "/Users/cat/repositories/locandy-web/app/main.py", line 31, in
> app_config
> config.include('pyramid_beaker') # --> includeme: of pyramid_beaker
> File "distlib/pyramid/config/__init__.py", line 808, in include
> c = self.maybe_dotted(callable)
> File "distlib/pyramid/config/__init__.py", line 912, in maybe_dotted
> return self.name_resolver.maybe_resolve(dotted)
> File "distlib/pyramid/path.py", line 320, in maybe_resolve
> return self._resolve(dotted, package)
> File "distlib/pyramid/path.py", line 327, in _resolve
> return self._zope_dottedname_style(dotted, package)
> File "distlib/pyramid/path.py", line 376, in _zope_dottedname_style
> found = __import__(used)
> File "distlib/pyramid_beaker/__init__.py", line 3, in <module>
> from beaker import cache
> File "distlib/beaker/cache.py", line 15, in <module>
> from beaker.crypto.util import sha1
> File "distlib/beaker/crypto/__init__.py", line 9, in <module>
> from beaker.crypto.pycrypto import getKeyLength, aesEncrypt,
> aesDecrypt
> File "distlib/beaker/crypto/pycrypto.py", line 17, in <module>
> from Crypto.Cipher import AES
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
> /site-packages/Crypto/Cipher/__init__.py", line 27, in <module>
> from Crypto.Cipher._mode_ecb import _create_ecb_cipher
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
> /site-packages/Crypto/Cipher/_mode_ecb.py", line 29, in <module>
> from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
> /site-packages/Crypto/Util/_raw_api.py", line 164, in <module>
> INFO 2023-10-24 14:16:28,661 module.py:862] default: "GET /_ah/warmup
> HTTP/1.1" 500 1919
> import ctypes
> File
> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py",
> line 7, in <module>
> from _ctypes import Union, Structure, Array
> File "/Users/cat/google-cloud-
> sdk/platform/google_appengine/python27/sdk/google/appengine/tools/devappserver2/python/runtime/sandbox.py",
> line 1144, in load_module
> raise ImportError('No module named %s' % fullname)
> ImportError: No module named _ctypes
New description:
Google appengine standard environment (Google cloud SDK) uses a sandbox
that prohibits the use of _ctype. pycryptodome uses _ctype, which fails to
import in the cloud sdk sandbox "ImportError: No module named _ctypes".
This was really hard to diagnose correctly.
This incompatibility should be documented in the package descriptions of
both ports, as pycryptodome is not a 100% replacement for pycrypto.
WORKAROUND: download and manually build pycrypto-2.6.1
{{{
Traceback (most recent call last):
File "/Users/cat/google-cloud-
sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py",
line 238, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/cat/google-cloud-
sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py",
line 309, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Users/cat/google-cloud-
sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py",
line 83, in LoadObject
obj = __import__(path[0])
File "/Users/cat/repositories/locandy-web/app/main.py", line 65, in
<module>
pyramid_config = app_config()
File "/Users/cat/repositories/locandy-web/app/main.py", line 31, in
app_config
config.include('pyramid_beaker') # --> includeme: of pyramid_beaker
File "distlib/pyramid/config/__init__.py", line 808, in include
c = self.maybe_dotted(callable)
File "distlib/pyramid/config/__init__.py", line 912, in maybe_dotted
return self.name_resolver.maybe_resolve(dotted)
File "distlib/pyramid/path.py", line 320, in maybe_resolve
return self._resolve(dotted, package)
File "distlib/pyramid/path.py", line 327, in _resolve
return self._zope_dottedname_style(dotted, package)
File "distlib/pyramid/path.py", line 376, in _zope_dottedname_style
found = __import__(used)
File "distlib/pyramid_beaker/__init__.py", line 3, in <module>
from beaker import cache
File "distlib/beaker/cache.py", line 15, in <module>
from beaker.crypto.util import sha1
File "distlib/beaker/crypto/__init__.py", line 9, in <module>
from beaker.crypto.pycrypto import getKeyLength, aesEncrypt,
aesDecrypt
File "distlib/beaker/crypto/pycrypto.py", line 17, in <module>
from Crypto.Cipher import AES
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/site-packages/Crypto/Cipher/__init__.py", line 27, in <module>
from Crypto.Cipher._mode_ecb import _create_ecb_cipher
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/site-packages/Crypto/Cipher/_mode_ecb.py", line 29, in <module>
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/site-packages/Crypto/Util/_raw_api.py", line 164, in <module>
INFO 2023-10-24 14:16:28,661 module.py:862] default: "GET /_ah/warmup
HTTP/1.1" 500 1919
import ctypes
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py",
line 7, in <module>
from _ctypes import Union, Structure, Array
File "/Users/cat/google-cloud-
sdk/platform/google_appengine/python27/sdk/google/appengine/tools/devappserver2/python/runtime/sandbox.py",
line 1144, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named _ctypes
}}}
--
--
Ticket URL: <https://trac.macports.org/ticket/68542#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list