python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

allow directory path as url

Open tcaduser opened this issue 2 years ago • 6 comments

This patch allows the use of a local directory path for the url in a recipe.

For example, when building a local c extension, it is then possible to use a directory url, instead of having to contact the server:

    url = '/home/jsanchez/git/devsim'

I was encountering many difficulties using the git+https scheme and it was slowing down development time.

tcaduser avatar Nov 21 '23 02:11 tcaduser

Did file:\\ not work?

Julian-O avatar Nov 21 '23 02:11 Julian-O

Did file:// not work?

no, the recipe.py file does not parse the file:\\ scheme, and I am processing a directory and not a file.

[INFO]:    Unpacking devsim for arm64-v8a
[DEBUG]:   -> running basename file:///home/jsanchez/git/devsim
[DEBUG]:   	devsim
[INFO]:    -> directory context /home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/devsim/arm64-v8a__ndk_target_21
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1262, in <module>
    main()
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
    ToolchainCL()
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 680, in __init__
    getattr(self, command)(args)
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 99, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 158, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx,
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 490, in build_recipes
    recipe.prepare_build_dir(arch.arch)
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 588, in prepare_build_dir
    self.unpack(arch)
  File "/home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 482, in unpack
    raise Exception(
Exception: Given path is neither a file nor a directory: /home/jsanchez/git/tcadapp/devsim/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/packages/devsim/devsim

The kivy-ios project accepts a local directory as a url, so I would argue that it should be consistent in python-for-android.

tcaduser avatar Nov 21 '23 02:11 tcaduser

Thanks for the contribution :pray: I haven't used it in a while and I don't know if it's documented, but don't we already support local recipes via --local-recipes? https://github.com/kivy/python-for-android/blob/v2023.09.16/pythonforandroid/toolchain.py#L319-L322

Also since you're touching a core component, do you mind updating the tests to match this feature?

AndreMiras avatar Nov 21 '23 08:11 AndreMiras

Pair that with: https://github.com/kivy/buildozer/blob/937a076dbfd77864bd3eabdc2831c00bc2ca2e4b/buildozer/default.spec#L47-L50

Effectively export P4A_devsim_DIR=path

HyTurtle avatar Nov 21 '23 09:11 HyTurtle

Hi @HyTurtle

export P4A_devsim_DIR=$HOME/git/tmp/devsim

seems to work. I was not able to get:

requirements.source.kivy = /home/jsanchez/git/tmp/devsim

to work. I suppose it is supposed to be requirements.source.devsim? (Still waiting for the environment variable based build).

Can you let me know if this is the official documentation: https://buildozer.readthedocs.io/en/latest/specifications.html

Please let me know the documentation repository, and I'll file a pull request with documentation.

tcaduser avatar Nov 22 '23 16:11 tcaduser

Hi @HyTurtle

export P4A_devsim_DIR=$HOME/git/tmp/devsim

seems to work. I was not able to get:

requirements.source.kivy = /home/jsanchez/git/tmp/devsim

to work. I suppose it is supposed to be requirements.source.devsim? (Still waiting for the environment variable based build).

Can you let me know if this is the official documentation: https://buildozer.readthedocs.io/en/latest/specifications.html

Please let me know the documentation repository, and I'll file a pull request with documentation.

It would indeed be requirements.source.devsim in the buildozer spec, posted the export line as that's how p4a reads it, and this is the p4a repo.

I'll have a look to see where/how well that's documented (ultimately it may currently just be the spec comments)

HyTurtle avatar Nov 22 '23 16:11 HyTurtle

@HyTurtle your solution works for me so i will cancel this pull request

tcaduser avatar Feb 28 '24 17:02 tcaduser