chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
748 stars 127 forks source link

How to use third party package zip file stored in server #1103

Closed bharatkhadodra1996 closed 3 months ago

bharatkhadodra1996 commented 4 months ago

I am using Pychubby python project in my android application. I have stored this project in server. Here is my gradle code.

python { pip { install "https://www.bharatk.com/myfiles/pychubby_master_1.zip" } }

Now my question is when I build apk, it includes this file at building time but I want to download this zip file at runtime when user install the application. So is that possible and if yes then how ?

mhsmith commented 4 months ago

You can download files at runtime using any HTTP library such as requests, as long as your app has the INTERNET permission.

Having downloaded it, you can extract it into a directory and add the directory to sys.path, or possibly add the ZIP to sys.path directly if its internal structure is suitable.

bharatkhadodra1996 commented 3 months ago

Ok but in this case, I will have to code in python to download files. I need a solution in android because the zip file I am using already contain python.exe and other dependencies. So is it possible to download the zip file with android and then use it ?

mhsmith commented 3 months ago

Chaquopy doesn't use any python.exe, so I don't know what you mean by that. If you're trying to use a python.exe you got from somewhere else, that's very unlikely to work.

Of course you can download a ZIP with Java or Kotlin using their own standard libraries. But you'll still have to edit sys.path in order to use it, so it would be easier to do the whole thing in Python.