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

Tree-Shake python dependencies #26

Open
baseplate-admin opened this issue Jan 24, 2024 Discussed in #22 · 5 comments
Open

Tree-Shake python dependencies #26

baseplate-admin opened this issue Jan 24, 2024 Discussed in #22 · 5 comments

Comments

@baseplate-admin
Copy link

Discussed in https://github.com/orgs/kivy/discussions/22

Originally posted by baseplate-admin January 5, 2024
As it stands,

The apk generated by python-for-android are large in size and nature.

I was wondering if it was possible to tree shake the android venv to reduce size.

Possible paths :

  • Compile python with bare minimum: This means we remove the stdlib to a bare minimum for our app to function.
  • Remove codes from venv : Tools like dead and vulture can be of use here.
  • Use better compression algorithm : Maybe support brotli/zstd instead of .zip ( or maybe even 7-zip )
@NomadDemon
Copy link

about last dot:
ok, but it cannot cost us startup time

ii would prefer faster startup than filesize to be honest

100-150 mb is ok size for decent phones imho

@baseplate-admin
Copy link
Author

ok, but it cannot cost us startup time

I dont think adding brotli increases the startup time that much (since 38% of the web uses brotli)

@baseplate-admin
Copy link
Author

Hi @misl6, could we please move this?

@misl6
Copy link
Member

misl6 commented Feb 20, 2024

Move where? I'm missing something?

The apk generated by python-for-android are large in size and nature.

Are really that large? Can you set your expectation and describe the current status?

@baseplate-admin
Copy link
Author

baseplate-admin commented Feb 21, 2024

Move where? I'm missing something?

I am extremely sorry that i was not clear with my words. I meant transfer this issue to python-for-android issue.

Are really that large? Can you set your expectation and describe the current status?

I am sorry that i overexaggerated the size. But yes it is quite large.

Please take a look at flet-dev/flet#2319 (reply in thread) .

In here the python bundle is 7Mb without any dependencies, in reality, when an app has a lot of dependencies, ( such as numpy ) the size tends to add up.

My proposal is to remove redundant codes when building the apk using buildozer / python-for-android. This approach is used by pythoninstaller


Now that kivy toolchains are used to build applications outside of kivy ecosystem, I think this approach will vastly improve the python android ecosystem all-together

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

No branches or pull requests

3 participants