chaquo / chaquopy

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

Restore `extractPackages` setting #754

Closed mhsmith closed 1 year ago

mhsmith commented 2 years ago

See discussion at https://github.com/beeware/toga/pull/1687#discussion_r1028474660, including the need to preserve .py files.

Things that this would be useful for:

Only extract_dir needs to check the setting: the actual import mechanism probably doesn't need to change.

eldon922 commented 1 year ago

Hi, what's the status of this issue? i need it exactly for the PyTorch hubconf.py files part 😅

mhsmith commented 1 year ago

We'll fix this issue in the next version of Chaquopy. Meanwhile, you can extract your hubconf.py file using the technique shown at https://github.com/chaquo/chaquopy/issues/501#issuecomment-845265141.

eldon922 commented 1 year ago

what if we want to extract only 1 file? the old way seems doesn't work anymore in the latest version

mhsmith commented 1 year ago

You should still be able to use the technique linked above to extract as many or as few files as you want. Or you can use extractPackages to extract an entire directory of Python files.

If something doesn't work, please give details.

eldon922 commented 1 year ago

this is the error if i update the version to 14.0.2. it doesn't happen in 13.0.0

com.chaquo.python.PyException: AttributeError: 'AssetFinder' object has no attribute 'extract_packages'
mhsmith commented 1 year ago

Please post the full stack trace, and the relevant sections of your code.

mhsmith commented 1 year ago

Actually, this is probably related to #820. Make sure you're using the __loader__ of the top-level package. I've updated https://github.com/chaquo/chaquopy/issues/501#issuecomment-845265141 to explain this.