Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyrebase4 needs pycryptodome, which doesn't have a recipe #701

Open
nkehoe opened this issue Apr 22, 2022 · 4 comments
Open

pyrebase4 needs pycryptodome, which doesn't have a recipe #701

nkehoe opened this issue Apr 22, 2022 · 4 comments

Comments

@nkehoe
Copy link

nkehoe commented Apr 22, 2022

Versions

  • Python : 3.9.7
  • MacOS version : 12.3.1
  • XCode Version :13.3.3
  • Cython version : 0.29.19

Describe the bug
I am trying to add pyrebase to my build to connect my firebase database.

To Reproduce
python toolchain.py pip install pyrebase4

Expected behavior
install pyrebase

Logs

[DEBUG   ]       building 'Crypto.Hash._MD2' extension
[DEBUG   ]       creating build/temp.macosx-12.3-arm64-3.9
[DEBUG   ]       creating build/temp.macosx-12.3-arm64-3.9/src
[DEBUG   ]       /bin/false -DPYCRYPTO_LITTLE_ENDIAN -DSYS_BITS=64 -DLTC_NO_ASM -Isrc/ -I/Users/noelkehoe/kivy-ios/dist/hostpython3/include/python3.9 -c src/MD2.c -o build/temp.macosx-12.3-arm64-3.9/src/MD2.o
[DEBUG   ]       error: command '/bin/false' failed: No such file or directory
[DEBUG   ]       [end of output]
[DEBUG   ]   
[DEBUG   ]   note: This error originates from a subprocess, and is likely not a problem with pip.
[DEBUG   ] error: legacy-install-failure
[DEBUG   ] 
[DEBUG   ] ? Encountered error while trying to install package.
[DEBUG   ] ??> pycryptodome
[DEBUG   ] 
[DEBUG   ] note: This is an issue with the package mentioned above, not pip.
[DEBUG   ] hint: See above for output from the failure.
[DEBUG   ] 
Exception in thread background thread for pid 99657:
Traceback (most recent call last):
  File "/Users/noelkehoe/opt/anaconda3/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/Users/noelkehoe/opt/anaconda3/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/noelkehoe/venv/lib/python3.9/site-packages/sh.py", line 1683, in wrap
    fn(*rgs, **kwargs)
  File "/Users/noelkehoe/venv/lib/python3.9/site-packages/sh.py", line 2662, in background_thread
    handle_exit_code(exit_code)
  File "/Users/noelkehoe/venv/lib/python3.9/site-packages/sh.py", line 2349, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/Users/noelkehoe/venv/lib/python3.9/site-packages/sh.py", line 905, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /Users/noelkehoe/kivy-ios/dist/hostpython3/bin/pip3 install --isolated --prefix /Users/noelkehoe/kivy-ios/dist/root/python3 pyrebase4

  STDOUT:
Collecting pyrebase4
  Using cached Pyrebase4-4.5.0-py3-none-any.whl (8.9 kB)
Requirement already satisfied: requests-toolbelt>=0.7.1 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (0.9.1)
Requirement already satisfied: requests>=2.19.1 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (2.27.1)
Requirement already satisfied: oauth2client>=4.1.2 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (4.1.3)
Requirement already satisfied: gcloud>=0.18.3 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (0.18.3)
Collecting python-jwt>=2.0.1
  Using cached python_jwt-3.3.2-py2.py3-none-any.whl (6.8 kB)
Collecting pycryptodome>=3.6.4
  Using cached pycryptodome-3.14.1.tar.gz (... (35985 more, please see e.stdout)

  STDERR:

Traceback (most recent call last):
  File "/Users/noelkehoe/kivy-ios/toolchain.py", line 3, in <module>
    main()
  File "/Users/noelkehoe/kivy-ios/kivy_ios/toolchain.py", line 1555, in main
    ToolchainCL()
  File "/Users/noelkehoe/kivy-ios/kivy_ios/toolchain.py", line 1299, in __init__
    getattr(self, args.command)()
  File "/Users/noelkehoe/kivy-ios/kivy_ios/toolchain.py", line 1514, in pip
    _pip(sys.argv[2:])
  File "/Users/noelkehoe/kivy-ios/kivy_ios/toolchain.py", line 1186, in _pip
    shprint(pip_cmd, *args, _env=pip_env)
  File "/Users/noelkehoe/kivy-ios/kivy_ios/toolchain.py", line 56, in shprint
    for line in cmd:
  File "/Users/noelkehoe/venv/lib/python3.9/site-packages/sh.py", line 953, in next
    self.wait()
  File "/Users/noelkehoe/venv/lib/python3.9/site-packages/sh.py", line 879, in wait
    self.handle_command_exit_code(exit_code)
  File "/Users/noelkehoe/venv/lib/python3.9/site-packages/sh.py", line 905, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /Users/noelkehoe/kivy-ios/dist/hostpython3/bin/pip3 install --isolated --prefix /Users/noelkehoe/kivy-ios/dist/root/python3 pyrebase4

  STDOUT:
Collecting pyrebase4
  Using cached Pyrebase4-4.5.0-py3-none-any.whl (8.9 kB)
Requirement already satisfied: requests-toolbelt>=0.7.1 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (0.9.1)
Requirement already satisfied: requests>=2.19.1 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (2.27.1)
Requirement already satisfied: oauth2client>=4.1.2 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (4.1.3)
Requirement already satisfied: gcloud>=0.18.3 in ./dist/root/python3/lib/python3.9/site-packages (from pyrebase4) (0.18.3)
Collecting python-jwt>=2.0.1
  Using cached python_jwt-3.3.2-py2.py3-none-any.whl (6.8 kB)
Collecting pycryptodome>=3.6.4
  Using cached pycryptodome-3.14.1.tar.gz (... (35985 more, please see e.stdout)

  STDERR:

Screenshots

Additional context
Add any other context about the problem here.

@nkehoe nkehoe changed the title Trying to add pyre base Trying to add pyrebase to my Xcode build Apr 22, 2022
@misl6
Copy link
Member

misl6 commented Jun 27, 2022

Unfortunately pyrebase needs pycryptodome, which needs a recipe in order to build.

Writing a recipe for pycryptodome may be trivial and will need a lot of patching, as it dynamically loads shared libraries via load_pycryptodome_raw_lib.

@misl6 misl6 changed the title Trying to add pyrebase to my Xcode build pyrebase4 needs pycryptodome, which doesn't have a recipe Dec 26, 2022
@mrtruongleo
Copy link

Hi @misl6, any update on this issue?

@pakal
Copy link

pakal commented Aug 23, 2023

If I understand correctly, kivy-ios "hacks" the production of .so/.pyd files (they are empty at the end), and generates .a files that can be compiled statically in Xcode, instead.

I don't know anything about this part, would the same hack be usable on pycryptodome?

Then the next part, I guess, would be to patch the cryptodome function below so that it opens "self" (the current process) instead of a separate .so/.pyd.

    def load_lib(name, cdecl):
        """Load a shared library and return a handle to it.

        @name,  either an absolute path or the name of a library
                in the system search path.

        @cdecl, the C function declarations.
        """

        if hasattr(ffi, "RTLD_DEEPBIND") and not os.getenv('PYCRYPTODOME_DISABLE_DEEPBIND'):
            lib = ffi.dlopen(name, ffi.RTLD_DEEPBIND)
        else:
            lib = ffi.dlopen(name)
        ffi.cdef(cdecl)
        return lib

@vesellov
Copy link

Hello people. Any progress on that? I would love to contribute to it, but need some assistance with building a recipe.

Is there a simple way to build pycryptodome itself with iOS (both simulator and real device) support without using kivy-ios toolchain at all?

~/tmp/pycryptodome$ python3 setup.py --platforms
Posix; MacOS X; Windows

Is it possible somehow to compile pycryptodome directly by setting proper compiler environment flags?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants