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

Implement Android support #95

Open
mixmastamyk opened this issue May 9, 2017 · 3 comments
Open

Implement Android support #95

mixmastamyk opened this issue May 9, 2017 · 3 comments

Comments

@mixmastamyk
Copy link

Would appreciate being able to use this on Android with a Kivy app I'm working on.

A few resources I've found:

@zoofood
Copy link
Contributor

zoofood commented May 14, 2017

Right I can see how this could be useful for Kivy apps. I don't currently have time to implement, but will look into it when I set about getting appdirs to v2.0. PRs always appreciated!

@robertpfeiffer
Copy link

I'm also interested in this, I might write a patch. Is it ok if it's kivy/P4A-specific first or would it need to support other distributions/packaging tools like beeware and termux?

@YariKartoshe4ka
Copy link

I want to add android support and suggests these additions:

  1. Now appdirs on android has a linux-style behavior, because sys.platform is linux*. It is logical to start with this and I suggest adding an additional condition for checking environment variables (more specifically, EXTERNAL_STORAGE or ANDROID_ROOT)
  2. Having a little understanding of android, I suggest the following directory scheme
user_data_dir -> /data/data/com.example/files/<AppName>
site_data_dir -> user_data_dir
user_config_dir -> /data/data/com.example/shared_prefs/<AppName>
site_config_dir -> user_config_dir
user_cache_dir -> /data/data/com.example/cache/<AppName>
user_state_dir -> user_data_dir
user_log_dir -> /data/data/com.example/cache/<AppName>/log
  1. There is a problem with the definition of package name (com.example). I think we need to:
    1. Define it via pyjnius (since appdirs does not use third-party libraries, we'll just check if this module is installed, maybe we'll be lucky to do it beautifully and without crutches)
    2. Define it via bruteforcing sys.path with regular expression e.g. /data/data/(A-Za-z0-9)* or similar (do not forget that it also can be in /data/user/0). I reviewed other algorithms:
      1. Android have not any environment variables hinting at the package name
      2. os.path.expanduser('~') outputs /data (idk why).
      3. Cutting the package name from sys.prefix, sys.executable or another, but in programs compiled through P4A, these attributes are empty (as I understand it, P4A uses the so library instead of a binary python file).
      4. Alternatively, the package name can be cut from __ file__, but programs running on termux/pydroid or similar will not work correctly

All in all i am waiting for the meeting offers

This was referenced Jul 9, 2021
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

4 participants