kivy / kivy-ios

Toolchain for compiling Python / Kivy / other libraries for iOS
https://kivy.org/docs/guide/packaging-ios.html
MIT License
781 stars 240 forks source link

./toolchain.py build pycrypto doesnt work #384

Closed khanhhien06 closed 5 years ago

khanhhien06 commented 5 years ago

After building python3, openssl and kivy, I want to build pycrypto by typing: ./toolchain.py build pycrypto It spits out the following error:


[INFO    ] Building with 4 processes, where supported
[INFO    ] Want to build ['pycrypto']
[INFO    ] Loaded recipe pycrypto (depends of ['python', 'openssl'], optional are [])
[INFO    ] Loaded recipe python (depends of [u'python3'], optional are [])
[INFO    ] Loaded recipe openssl (depends of [], optional are [])
[INFO    ] Loaded recipe python3 (depends of ['hostpython3', 'libffi', 'openssl'], optional are [])
[INFO    ] Loaded recipe hostpython3 (depends of [], optional are ['openssl'])
[INFO    ] Loaded recipe libffi (depends of [], optional are [])
[INFO    ] Build order is ['libffi', 'openssl', 'hostpython3', u'python3', 'python', 'pycrypto']
[INFO    ] Recipe order is ['libffi', 'openssl', 'hostpython3', 'python3', 'pycrypto']
[INFO    ] Include dir added: {arch.arch}/ffi
[INFO    ] Include dir added: {arch.arch}/openssl
[INFO    ] Global: hostpython located at /Users/hcao/Desktop/kivyios-python3/kivy-ios/dist/hostpython3/bin/python
[INFO    ] Global: hostpgen located at /Users/hcao/Desktop/kivyios-python3/kivy-ios/dist/hostpython3/bin/pgen
[DEBUG   ] Cached result: Download libffi. Ignoring
[DEBUG   ] Cached result: Extract libffi. Ignoring
[DEBUG   ] Cached result: Build_all libffi. Ignoring
[DEBUG   ] Cached result: Download openssl. Ignoring
[DEBUG   ] Cached result: Extract openssl. Ignoring
[DEBUG   ] Cached result: Build_all openssl. Ignoring
[DEBUG   ] Cached result: Download hostpython3. Ignoring
[DEBUG   ] Cached result: Extract hostpython3. Ignoring
[DEBUG   ] Cached result: Build_all hostpython3. Ignoring
[DEBUG   ] Cached result: Download python3. Ignoring
[DEBUG   ] Cached result: Extract python3. Ignoring
[DEBUG   ] Cached result: Build_all python3. Ignoring
[INFO    ] Download pycrypto
[INFO    ] Downloading https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.1.tar.gz
Traceback (most recent call last):
  File "./toolchain.py", line 1569, in <module>
    ToolchainCL()
  File "./toolchain.py", line 1284, in __init__
    getattr(self, args.command)()
  File "./toolchain.py", line 1325, in build
    build_recipes(args.recipe, ctx)
  File "./toolchain.py", line 1161, in build_recipes
    recipe.execute()
  File "/Users/hcao/Desktop/kivyios-python3/kivy-ios/toolchain.py", line 726, in execute
    self.download()
  File "/Users/hcao/Desktop/kivyios-python3/kivy-ios/toolchain.py", line 84, in _cache_execution
    f(self, *args, **kwargs)
  File "/Users/hcao/Desktop/kivyios-python3/kivy-ios/toolchain.py", line 761, in download
    self.download_file(self.url.format(version=self.version), fn)
  File "/Users/hcao/Desktop/kivyios-python3/kivy-ios/toolchain.py", line 478, in download_file
    urlretrieve(url, filename, report_hook)
  File "/Library/Python/2.7/site-packages/future/backports/urllib/request.py", line 1731, in retrieve
    fp = self.open(url, data)
  File "/Library/Python/2.7/site-packages/future/backports/urllib/request.py", line 1703, in open
    raise_with_traceback(IOError('socket error', msg))
  File "/Library/Python/2.7/site-packages/future/backports/urllib/request.py", line 1697, in open
    return getattr(self, name)(url)
  File "/Library/Python/2.7/site-packages/future/backports/urllib/request.py", line 1907, in open_https
    return self._open_generic_http(self._https_connection, url, data)
  File "/Library/Python/2.7/site-packages/future/backports/urllib/request.py", line 1856, in _open_generic_http
    http_conn.request("GET", selector, headers=headers)
  File "/Library/Python/2.7/site-packages/future/backports/http/client.py", line 1083, in request
    self._send_request(method, url, body, headers)
  File "/Library/Python/2.7/site-packages/future/backports/http/client.py", line 1121, in _send_request
    self.endheaders(body)
  File "/Library/Python/2.7/site-packages/future/backports/http/client.py", line 1079, in endheaders
    self._send_output(message_body)
  File "/Library/Python/2.7/site-packages/future/backports/http/client.py", line 924, in _send_output
    self.send(msg)
  File "/Library/Python/2.7/site-packages/future/backports/http/client.py", line 860, in send
    self.connect()
  File "/Library/Python/2.7/site-packages/future/backports/http/client.py", line 1221, in connect
    self.timeout, self.source_address)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 575, in create_connection
    raise err
IOError: [Errno socket error] [Errno 61] Connection refused
Dirk-Sandberg commented 5 years ago

It looks like the where the pycrypto tar file was being hosted is no longer available. The URL where the file was hosted previously looks dead(?). This is an interesting recipe because it tries to get the tar file from https://ftp.dlitz.net rather than the pypi website like most of the other recipes. A work around is to change the URL manually to where the file is hosted on pypi.

QUICK FIX: Try changing "https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-{version}.tar.gz" to "https://files.pythonhosted.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz" in line 11 of the init.py file of the pycrypto recipe. The init.py file for the pycrypto recipe can be found in /foo/bar/kivy-ios/recipes/pycrypto folder.

SOLUTION IN THE FUTURE: Update the recipe in kivy-ios for pycrypto to grab the proper URL from the get go.

tito commented 5 years ago

I think pycrypto should be removed. It is deprecated, contains security issues. It must be replaced with pycryptodome.

khanhhien06 commented 5 years ago

Thanks guys. I can now install pycrypto but it is still not working correctly. I have a very simple app: from firebase import firebase I run the following command lines:

./toolchain.py build python3 openssl kivy
./toolchain.py build python3 pycrypto
./toolchain.py create kindact ~/Desktop/main
./toolchain.py pip3 install firebase
./toolchain.py pip3 install pycryptodome
./toolchain.py pip3 install python_jwt

When I click the 'Play' button in Xcode, I get the following errors. I assume it has to do with pycrypto. How do I go about this issue?

2019-09-19 00:20:03.716608-0400 kindact[55466:291354] [framework] CUIThemeStore: No theme registered with id=0
2019-09-19 00:20:03.957463-0400 kindact[55466:291354] Available orientation: KIVY_ORIENTATION=LandscapeLeft LandscapeRight Portrait PortraitUpsideDown
2019-09-19 00:20:03.957772-0400 kindact[55466:291354] Initializing python
/Users/hiencao/Library/Developer/CoreSimulator/Devices/9E046BFB-CB75-4394-BBBB-CD52178F0DEA/data/Containers/Bundle/Application/73683AE3-2088-4B84-9B74-248B20FB0932/kindact.app/kindact:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
2019-09-19 00:20:04.169015-0400 kindact[55466:291354] Running main.py: /Users/hiencao/Library/Developer/CoreSimulator/Devices/9E046BFB-CB75-4394-BBBB-CD52178F0DEA/data/Containers/Bundle/Application/73683AE3-2088-4B84-9B74-248B20FB0932/kindact.app/YourApp/main.pyc
Traceback (most recent call last):
  File "<string>", line 39, in load_module
  File "/Users/hiencao/Desktop/4/kivy-ios/dist/root/python3/lib/python3.7/imp.py", line 342, in load_dynamic
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: dynamic module does not define module export function (PyInit_cryptography_hazmat_bindings__constant_time)
Traceback (most recent call last):
  File "<string>", line 39, in load_module
  File "/Users/hiencao/Desktop/4/kivy-ios/dist/root/python3/lib/python3.7/imp.py", line 342, in load_dynamic
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: dynamic module does not define module export function (PyInit_cryptography_hazmat_bindings__constant_time)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hiencao/Desktop/4/kivy-ios/kindact-ios/YourApp/main.py", line 1, in <module>
  File "/Users/hiencao/Library/Developer/CoreSimulator/Devices/9E046BFB-CB75-4394-BBBB-CD52178F0DEA/data/Containers/Bundle/Application/73683AE3-2088-4B84-9B74-248B20FB0932/kindact.app/lib/python3.7/site-packages/firebase/__init__.py", line 14, in <module>
    import python_jwt as jwt
  File "/Users/hiencao/Library/Developer/CoreSimulator/Devices/9E046BFB-CB75-4394-BBBB-CD52178F0DEA/data/Containers/Bundle/Application/73683AE3-2088-4B84-9B74-248B20FB0932/kindact.app/lib/python3.7/site-packages/python_jwt/__init__.py", line 8, in <module>
    from jwcrypto.jws import JWS, JWSHeaderRegistry
  File "/Users/hiencao/Library/Developer/CoreSimulator/Devices/9E046BFB-CB75-4394-BBBB-CD52178F0DEA/data/Containers/Bundle/Application/73683AE3-2088-4B84-9B74-248B20FB0932/kindact.app/lib/python3.7/site-packages/jwcrypto/jws.py", line 8, in <module>
    from jwcrypto.jwa import JWA
  File "/Users/hiencao/Library/Developer/CoreSimulator/Devices/9E046BFB-CB75-4394-BBBB-CD52178F0DEA/data/Containers/Bundle/Application/73683AE3-2088-4B84-9B74-248B20FB0932/kindact.app/lib/python3.7/site-packages/jwcrypto/jwa.py", line 10, in <module>
    from cryptography.hazmat.primitives import constant_time, hashes, hmac
  File "/Users/hiencao/Library/Developer/CoreSimulator/Devices/9E046BFB-CB75-4394-BBBB-CD52178F0DEA/data/Containers/Bundle/Application/73683AE3-2088-4B84-9B74-248B20FB0932/kindact.app/lib/python3.7/site-packages/cryptography/hazmat/primitives/constant_time.py", line 11, in <module>
    from cryptography.hazmat.bindings._constant_time import lib
  File "<string>", line 43, in load_module
  File "/Users/hiencao/Desktop/4/kivy-ios/dist/root/python3/lib/python3.7/imp.py", line 342, in load_dynamic
ImportError: dynamic module does not define module export function (PyInit__constant_time)
2019-09-19 00:20:05.240365-0400 kindact[55466:291354] Application quit abnormally!
2019-09-19 00:20:05.263239-0400 kindact[55466:291354] Leaving
khanhhien06 commented 5 years ago

Closing issue since Firebase module can be replaced by Requests and json as a workaround.