T-Dynamos/materialyoucolor-python

Pure python alternative

Closed this issue · 8 comments

Android and iOS need to build binaries from python only sources. This (and therefore kivymd) are currently not able to compile for mobile devices.
I know it would be slower but is it possible to make an alternative that didn't use cpp

I believe that it isn't super hard to make a recipe for IOS, and Android one just works fine. If you have any issues while compiling please post logs.

Hi I am using KivyMD latest version (master branch). I can install the materialyoucolor in my python env using pip3 install https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip However, when I want to deploy to iSO simulator or devices I need to install the same through the toolchain (kivy-ios project) using toolchain pip3 install https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip but I get the below error.

$ toolchain pip3 install https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip
[INFO    ] Using the bundled version for recipe 'hostopenssl'
[INFO    ] Using the bundled version for recipe 'hostpython3'
[INFO    ] Global: hostpython located at /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/python
[INFO    ] Global: hostpgen located at /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pgen
[INFO    ] Using the bundled version for recipe 'ios'
[INFO    ] Using the bundled version for recipe 'kivy'
[INFO    ] Using the bundled version for recipe 'libffi'
[INFO    ] Include dir added: {arch.arch}/ffi
[INFO    ] Using the bundled version for recipe 'libpng'
[INFO    ] Include dir added: common/libpng
[INFO    ] Using the bundled version for recipe 'openssl'
[INFO    ] Include dir added: {arch.arch}/openssl
[INFO    ] Using the bundled version for recipe 'pyobjus'
[INFO    ] Using the bundled version for recipe 'python3'
[INFO    ] Using the bundled version for recipe 'sdl2'
[INFO    ] Include dir added: common/sdl2
[INFO    ] Using the bundled version for recipe 'sdl2_image'
[INFO    ] Include dir added: common/sdl2_image
[INFO    ] Using the bundled version for recipe 'sdl2_mixer'
[INFO    ] Include dir added: common/sdl2_mixer
[INFO    ] Using the bundled version for recipe 'sdl2_ttf'
[INFO    ] Include dir added: common/sdl2_ttf
[INFO    ] Executing pip with: ['install', '--isolated', '--prefix', '/Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3', 'https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip']
[INFO    ] Running Shell: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pip3 ('install', '--isolated', '--prefix', '/Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3', 'https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip') {'_env': {'CC': '/bin/false', 'CXX': '/bin/false', 'PYTHONPATH': '/Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3/lib/python3.10/site-packages', 'PYTHONOPTIMIZE': '2'}, '_iter': True, '_out_bufsize': 1, '_err_to_out': True}
[DEBUG   ] Collecting https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip
[DEBUG   ]   Downloading https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip
[DEBUG   ]      - 0 bytes ? 0:00:00
     - 3.4 kB ? 0:00:00
     - 13.7 kB 194.0 kB/s 0:00:00
     \ 42.9 kB 388.9 kB/s 0:00:00
     \ 47.4 kB 363.3 kB/s 0:00:00
[DEBUG   ]   Preparing metadata (setup.py) ... error
[DEBUG   ]   error: subprocess-exited-with-error
[DEBUG   ]   
[DEBUG   ]   ? python setup.py egg_info did not run successfully.
[DEBUG   ]   ? exit code: 1
[DEBUG   ]   ??> [6 lines of output]
[DEBUG   ]       Traceback (most recent call last):
[DEBUG   ]         File "<string>", line 2, in <module>
[DEBUG   ]         File "<pip-setuptools-caller>", line 34, in <module>
[DEBUG   ]         File "/private/tmp/pip-req-build-byiv0o7h/setup.py", line 6, in <module>
[DEBUG   ]           from pybind11.setup_helpers import Pybind11Extension
[DEBUG   ]       ModuleNotFoundError: No module named 'pybind11'
[DEBUG   ]       [end of output]
[DEBUG   ]   
[DEBUG   ]   note: This error originates from a subprocess, and is likely not a problem with pip.
[DEBUG   ] error: metadata-generation-failed
[DEBUG   ] 
[DEBUG   ] ? Encountered error while generating package metadata.
[DEBUG   ] ??> See above for output.
[DEBUG   ] 
[DEBUG   ] note: This is an issue with the package mentioned above, not pip.
[DEBUG   ] hint: See above for details.
[DEBUG   ] 
[DEBUG   ] [notice] A new release of pip available: 22.3.1 -> 24.0
[DEBUG   ] [notice] To update, run: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/python3.10 -m pip install --upgrade pip
[DEBUG   ] 
Exception in thread background thread for pid 13676:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 1639, in wrap
    fn(*rgs, **kwargs)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 2641, in background_thread
    handle_exit_code(exit_code)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 2332, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 826, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pip3 install --isolated --prefix /Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3 https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip

  STDOUT:
Collecting https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip
  Downloading https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip
     \ 47.4 kB 363.3 kB/s 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1... (1209 more, please see e.stdout)

  STDERR:

Traceback (most recent call last):
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/bin/toolchain", line 8, in <module>
    sys.exit(main())
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1562, in main
    ToolchainCL()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1306, in __init__
    getattr(self, args.command)()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1518, in pip3
    self.pip()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1521, in pip
    _pip(sys.argv[2:])
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1193, in _pip
    shprint(pip_cmd, *args, _env=pip_env)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 60, in shprint
    for line in cmd:
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 882, in __next__
    self.wait()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 799, in wait
    self.handle_command_exit_code(exit_code)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 826, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pip3 install --isolated --prefix /Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3 https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip

  STDOUT:
Collecting https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip
  Downloading https://github.com/T-Dynamos/materialyoucolor-python/archive/develop.zip
     \ 47.4 kB 363.3 kB/s 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1... (1209 more, please see e.stdout)

  STDERR:

@T-Dynamos
As you mentioned above the making a recipe for iOS will not be hard, then could you please try that? I have a tried to build a few packages like sallies spatial package before but no luck with building the libraries using kivy-ios toolchain :(

Could you please help?

Thanks in Advance!!

@subhashsharma
Please use master version instead of develop.

@T-Dynamos
Hi I used the master version and similar error again:

 toolchain pip3 install https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
[INFO    ] Using the bundled version for recipe 'hostopenssl'
[INFO    ] Using the bundled version for recipe 'hostpython3'
[INFO    ] Global: hostpython located at /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/python
[INFO    ] Global: hostpgen located at /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pgen
[INFO    ] Using the bundled version for recipe 'ios'
[INFO    ] Using the bundled version for recipe 'kivy'
[INFO    ] Using the bundled version for recipe 'libffi'
[INFO    ] Include dir added: {arch.arch}/ffi
[INFO    ] Using the bundled version for recipe 'libpng'
[INFO    ] Include dir added: common/libpng
[INFO    ] Using the bundled version for recipe 'openssl'
[INFO    ] Include dir added: {arch.arch}/openssl
[INFO    ] Using the bundled version for recipe 'pyobjus'
[INFO    ] Using the bundled version for recipe 'python3'
[INFO    ] Using the bundled version for recipe 'sdl2'
[INFO    ] Include dir added: common/sdl2
[INFO    ] Using the bundled version for recipe 'sdl2_image'
[INFO    ] Include dir added: common/sdl2_image
[INFO    ] Using the bundled version for recipe 'sdl2_mixer'
[INFO    ] Include dir added: common/sdl2_mixer
[INFO    ] Using the bundled version for recipe 'sdl2_ttf'
[INFO    ] Include dir added: common/sdl2_ttf
[INFO    ] Executing pip with: ['install', '--isolated', '--prefix', '/Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3', 'https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip']
[INFO    ] Running Shell: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pip3 ('install', '--isolated', '--prefix', '/Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3', 'https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip') {'_env': {'CC': '/bin/false', 'CXX': '/bin/false', 'PYTHONPATH': '/Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3/lib/python3.10/site-packages', 'PYTHONOPTIMIZE': '2'}, '_iter': True, '_out_bufsize': 1, '_err_to_out': True}
[DEBUG   ] Collecting https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
[DEBUG   ]   Downloading https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
[DEBUG   ]      - 0 bytes ? 0:00:00
     - 10.2 kB 20.4 MB/s 0:00:00
     - 32.0 kB 582.3 kB/s 0:00:00
     \ 32.0 kB 582.3 kB/s 0:00:00
     \ 32.0 kB 582.3 kB/s 0:00:00
     | 86.4 kB 505.5 kB/s 0:00:00
     | 202.4 kB 873.9 kB/s 0:00:00
[DEBUG   ]   Preparing metadata (setup.py) ... error
[DEBUG   ]   error: subprocess-exited-with-error
[DEBUG   ]   
[DEBUG   ]   ? python setup.py egg_info did not run successfully.
[DEBUG   ]   ? exit code: 1
[DEBUG   ]   ??> [44 lines of output]
[DEBUG   ]       Traceback (most recent call last):
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/urllib/request.py", line 1348, in do_open
[DEBUG   ]           h.request(req.get_method(), req.selector, req.data, headers,
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/http/client.py", line 1282, in request
[DEBUG   ]           self._send_request(method, url, body, headers, encode_chunked)
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/http/client.py", line 1328, in _send_request
[DEBUG   ]           self.endheaders(body, encode_chunked=encode_chunked)
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/http/client.py", line 1277, in endheaders
[DEBUG   ]           self._send_output(message_body, encode_chunked=encode_chunked)
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/http/client.py", line 1037, in _send_output
[DEBUG   ]           self.send(msg)
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/http/client.py", line 975, in send
[DEBUG   ]           self.connect()
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/http/client.py", line 1454, in connect
[DEBUG   ]           self.sock = self._context.wrap_socket(self.sock,
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/ssl.py", line 513, in wrap_socket
[DEBUG   ]           return self.sslsocket_class._create(
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/ssl.py", line 1071, in _create
[DEBUG   ]           self.do_handshake()
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/ssl.py", line 1342, in do_handshake
[DEBUG   ]           self._sslobj.do_handshake()
[DEBUG   ]       ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
[DEBUG   ]       
[DEBUG   ]       During handling of the above exception, another exception occurred:
[DEBUG   ]       
[DEBUG   ]       Traceback (most recent call last):
[DEBUG   ]         File "<string>", line 2, in <module>
[DEBUG   ]         File "<pip-setuptools-caller>", line 34, in <module>
[DEBUG   ]         File "/private/tmp/pip-req-build-woan2ayx/setup.py", line 540, in <module>
[DEBUG   ]           write_buffer.write(urllib.request.urlopen(URL + file).read().decode("utf-8"))
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/urllib/request.py", line 216, in urlopen
[DEBUG   ]           return opener.open(url, data, timeout)
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/urllib/request.py", line 519, in open
[DEBUG   ]           response = self._open(req, data)
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/urllib/request.py", line 536, in _open
[DEBUG   ]           result = self._call_chain(self.handle_open, protocol, protocol +
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/urllib/request.py", line 496, in _call_chain
[DEBUG   ]           result = func(*args)
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/urllib/request.py", line 1391, in https_open
[DEBUG   ]           return self.do_open(http.client.HTTPSConnection, req,
[DEBUG   ]         File "/Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/lib/python3.10/urllib/request.py", line 1351, in do_open
[DEBUG   ]           raise URLError(err)
[DEBUG   ]       urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
[DEBUG   ]       Downloading required files...
[DEBUG   ]       [end of output]
[DEBUG   ]   
[DEBUG   ]   note: This error originates from a subprocess, and is likely not a problem with pip.
[DEBUG   ] error: metadata-generation-failed
[DEBUG   ] 
[DEBUG   ] ? Encountered error while generating package metadata.
[DEBUG   ] ??> See above for output.
[DEBUG   ] 
[DEBUG   ] note: This is an issue with the package mentioned above, not pip.
[DEBUG   ] hint: See above for details.
[DEBUG   ] 
[DEBUG   ] [notice] A new release of pip available: 22.3.1 -> 24.0
[DEBUG   ] [notice] To update, run: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/python3.10 -m pip install --upgrade pip
[DEBUG   ] 
Exception in thread background thread for pid 45879:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 1639, in wrap
    fn(*rgs, **kwargs)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 2641, in background_thread
    handle_exit_code(exit_code)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 2332, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 826, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pip3 install --isolated --prefix /Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3 https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip

  STDOUT:
Collecting https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
  Downloading https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
     | 202.4 kB 873.9 kB/s 0:00:00
  Preparing metadata (setup.py) ... error
  err... (5136 more, please see e.stdout)

  STDERR:

Traceback (most recent call last):
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/bin/toolchain", line 8, in <module>
    sys.exit(main())
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1562, in main
    ToolchainCL()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1306, in __init__
    getattr(self, args.command)()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1518, in pip3
    self.pip()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1521, in pip
    _pip(sys.argv[2:])
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 1193, in _pip
    shprint(pip_cmd, *args, _env=pip_env)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/kivy_ios/toolchain.py", line 60, in shprint
    for line in cmd:
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 882, in __next__
    self.wait()
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 799, in wait
    self.handle_command_exit_code(exit_code)
  File "/Users/subhash/Development/personal/ios/Kivy/mappo/venv/lib/python3.10/site-packages/sh.py", line 826, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /Users/subhash/Development/personal/ios/Kivy/mappo/dist/hostpython3/bin/pip3 install --isolated --prefix /Users/subhash/Development/personal/ios/Kivy/mappo/dist/root/python3 https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip

  STDOUT:
Collecting https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
  Downloading https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip
     | 202.4 kB 873.9 kB/s 0:00:00
  Preparing metadata (setup.py) ... error
  err... (5136 more, please see e.stdout)

  STDERR:

You have new mail in /var/mail/subhash

@subhashsharma Something is wrong with you internet libs?

[DEBUG   ]       ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

Are you able to make requests with python on your system?

Edit: Please follow https://stackoverflow.com/questions/52805115/certificate-verify-failed-unable-to-get-local-issuer-certificate and rerun.

@T-Dynamos - no mate I still can't solve this SSL CERTIFICATE issue. I have spent couple of hours searching for solution on internet and still no luck.

Linked kivy-ios PR: kivy/kivy-ios#898

PR has been merged.