Kodi Community Forum

Full Version: PyCryptodome issues on windows
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
After reinserting pycrytodome into our buildsystem (revert removal from here: https://github.com/xbmc/xbmc/commit/615a...2be7adf1d5), calling cmake again and rebuilding, two issues appear:

1.) module MD5 not found (seems to be identical to that already found in crypto library), needs an identical fix, for testing I put "Cryprtodome.hash." before the import.
2.) something does not work with _ctyptes, this isue will most likely also pop up for PIL:

log:
File "D:\Dev\xbmc\build\system\python\Lib\ctypes\__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

Can be reproduced by installing netflix addon, credentials are not needed for reproduction

Edit: For android the first (MD5.py) point seems not to be an issue, so there are differences in how/where modules are searched.
(2019-10-17, 11:39)peak3d Wrote: [ -> ]After reinserting pycrytodome into our buildsystem (revert removal from here: https://github.com/xbmc/xbmc/commit/615a...2be7adf1d5), calling cmake again and rebuilding, two issues appear:

1.) module MD5 not found (seems to be identical to that already found in crypto library), needs an identical fix, for testing I put "Cryprtodome.hash." before the import.
2.) something does not work with _ctyptes, this isue will most likely also pop up for PIL:

log:
File "D:\Dev\xbmc\build\system\python\Lib\ctypes\__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

Can be reproduced by installing netflix addon, credentials are not needed for reproduction

Edit: For android the first (MD5.py) point seems not to be an issue, so there are differences in how/where modules are searched.
can be a libffi build problem
I don't know if it could be the following problem:
https://bugs.python.org/issue34823
Can you check it out?
(2019-11-06, 16:07)stefive83 Wrote: [ -> ]
(2019-10-17, 11:39)peak3d Wrote: [ -> ]After reinserting pycrytodome into our buildsystem (revert removal from here: https://github.com/xbmc/xbmc/commit/615a...2be7adf1d5), calling cmake again and rebuilding, two issues appear:

(...)
can be a libffi build problem
I don't know if it could be the following problem:
https://bugs.python.org/issue34823
Can you check it out? 
Thx for the hint @"stefive83". For a temporary workarounf I pip installed (a new version of) pyCryptoDomex with the py3 binaries we use for kodi and copied things around.
After that, it works, but I stopped further investigation because some team members are currently enhancing the dependency build system (build dependency instead providing precompiled binaries)
i have seen, i will follow the situation
(2019-11-12, 21:57)peak3d Wrote: [ -> ]For a temporary workarounf I pip installed (a new version of) pyCryptoDomex with the py3 binaries we use for kodi and copied things around.
@peak3d Can you explain what you did exactly with these binaries? I would like to get this working to test "Up Next" with Netflix on Kodi 19.
Download a pre-compiled wheel for Python 3.7 on Windows from PyPI, unpack it (it's a zip file) and then copy its contents to pycryptodrome addon directory, replacing existing .py and .pyd files.
Thanks for the help. I copied Cryptodome to
Code:
C:\Program Files\Kodi\system\python\lib\site-packages]C:\Program Files\Kodi\system\python\lib\site-packages

Now I got this error:

Code:


2019-11-27 15:09:42.263 T:1620   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <class 'ModuleNotFoundError'>
                                            Error Contents: No module named '_ctypes'
                                            Traceback (most recent call last):
                                              File "C:\Users\öl\AppData\Roaming\Kodi\addons\plugin.video.netflix\resources\lib\services\msl\default_crypto.py", line 8, in <module>
                                                from Crypto.Random import get_random_bytes
                                            ModuleNotFoundError: No module named 'Crypto'
                                            
                                            During handling of the above exception, another exception occurred:
                                            
                                            Traceback (most recent call last):
                                              File "C:\Program Files\Kodi\system\python\lib\site-packages\Cryptodome\Util\_raw_api.py", line 84, in <module>
                                                from cffi import FFI
                                            ModuleNotFoundError: No module named 'cffi'
                                            
                                            During handling of the above exception, another exception occurred:
                                            
                                            Traceback (most recent call last):
                                              File "C:\Users\öl\AppData\Roaming\Kodi\addons\plugin.video.netflix\service.py", line 21, in <module>
                                                import resources.lib.services as services
                                              File "C:\Users\öl\AppData\Roaming\Kodi\addons\plugin.video.netflix\resources\lib\services\__init__.py", line 6, in <module>
                                                from .msl.http_server import MSLTCPServer
                                              File "C:\Users\öl\AppData\Roaming\Kodi\addons\plugin.video.netflix\resources\lib\services\msl\http_server.py", line 27, in <module>
                                                from .msl_handler import MSLHandler
                                              File "C:\Users\öl\AppData\Roaming\Kodi\addons\plugin.video.netflix\resources\lib\services\msl\msl_handler.py", line 23, in <module>
                                                from .request_builder import MSLRequestBuilder
                                              File "C:\Users\öl\AppData\Roaming\Kodi\addons\plugin.video.netflix\resources\lib\services\msl\request_builder.py", line 24, in <module>
                                                from .default_crypto import DefaultMSLCrypto as MSLCrypto
                                              File "C:\Users\öl\AppData\Roaming\Kodi\addons\plugin.video.netflix\resources\lib\services\msl\default_crypto.py", line 16, in <module>
                                                from Cryptodome.Hash import HMAC, SHA256
                                              File "C:\Program Files\Kodi\system\python\lib\site-packages\Cryptodome\Hash\HMAC.py", line 38, in <module>
                                                from Cryptodome.Hash import MD5
                                              File "C:\Program Files\Kodi\system\python\lib\site-packages\Cryptodome\Hash\MD5.py", line 23, in <module>
                                                from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib,
                                              File "C:\Program Files\Kodi\system\python\lib\site-packages\Cryptodome\Util\_raw_api.py", line 165, in <module>
                                                import ctypes
                                              File "C:\Program Files\Kodi\system\python\Lib\ctypes\__init__.py", line 7, in <module>
                                                from _ctypes import Union, Structure, Array
                                            ModuleNotFoundError: No module named '_ctypes'
                                            -->End of Python script error report<--


Then I copied _ctypes.pyd from 
Code:
C:\Users\öl\AppData\Local\Programs\Python\Python37\DLLs
to the same directory but Kodi crashes while starting up. I'm not sure the Python37 binaries are compatible with Kodi.
I found the same thing, although not with PyCryptodome.  In v19 the system\Python\DLLs folder on Windows is empty and trying to include a "real" copy of  _ctypes.pyd  caused my addon to crash Kodi immediately.

Martin
The issues fixed thanks to Paxxi.

https://github.com/xbmc/xbmc/pull/17157

The Netflix plugin working fine now with this nightly for Kodi 19 on windows 64bit.

https://mirrors.kodi.tv/nightlies/window...er-x64.exe