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

recipes: Introduce `RustCompiledComponentsRecipe`, add `pydantic-core` and update `cryptography`

Open T-Dynamos opened this issue 1 year ago • 12 comments

Closes #2661 #2955 Surpasses #2957

CC: @AndreMiras @misl6 Is approach used here is fine?

T-Dynamos avatar Jan 25 '24 18:01 T-Dynamos

@Julian-O Hi, can you please triggre CI?

T-Dynamos avatar Jan 26 '24 05:01 T-Dynamos

Sorry, I don't have permissions for that. @misl6?

Julian-O avatar Jan 26 '24 07:01 Julian-O

Interesting approach, thanks for looking this up. The CI actually tried running, but failed because of a syntax error:

[Invalid workflow file: .github/workflows/push.yml#L232](https://github.com/kivy/python-for-android/actions/runs/7658579349/workflow)
The workflow is not valid. .github/workflows/push.yml (Line: 232, Col: 13): Unexpected symbol: '|'. Located at position 23 within expression: (
  github.event_path | contains('pydantic-core')
  # github.event_path | contains('dir2') ||
  # github.event_path | contains('dir3')
)

See here https://github.com/kivy/python-for-android/actions/runs/7658579349 This would be our first Rust recipe I think. It's probably OK that we don't generalize anything yet, but we may want as we get more of them. I don't have much knowledge about Rust, so I don't know if the current method is future proof for dealing with different compiler versions plus dependencies, but I'm fine with it as it's a first, as long as the CI is happy about it. misl6 should have the last word as I haven't been very active in p4a for a long time

AndreMiras avatar Jan 26 '24 11:01 AndreMiras

Build works, please somebody cancel all the previous actions triggred except the latest one.

T-Dynamos avatar Jan 26 '24 14:01 T-Dynamos

@T-Dynamos FYI, Unit tests are failing.

Regarding the approach, there's something that will be repetitive along all the upcoming recipes for rust-backed libraries? If yes, how about moving these things into a RustCompiledComponentsRecipe ?

misl6 avatar Jan 28 '24 17:01 misl6

RustCompiledComponentsRecipe

It's good idea. As cryptography is also built on rust.

T-Dynamos avatar Jan 28 '24 17:01 T-Dynamos

RustCompiledComponentsRecipe

It's good idea. As cryptography is also built on rust.

Do not take it as a "we should do it like that", feel free to improve the thinking.

Please also remind to add the new dependency into prerequisites.py, and in docs.

misl6 avatar Jan 28 '24 17:01 misl6

@misl6 Done!, After review I will document all.

T-Dynamos avatar Jan 30 '24 17:01 T-Dynamos

Hi @T-Dynamos ,

While we will do our best to fix "Unit tests & build apps / Pytest" tests (not your fault), "Unit tests & build apps / Test updated recipes" are failing due to the rust-related changes.

Can you please take care of it?

misl6 avatar Feb 09 '24 17:02 misl6

@misl6 Done!

T-Dynamos avatar Feb 11 '24 06:02 T-Dynamos

Cool I tested it here and got pydantic 2 compiled with rust in my Android app! That's very impressive work @T-Dynamos

FilipeMarch avatar Feb 17 '24 04:02 FilipeMarch

@misl6 Happens only on Apple M1, something wrong with linking?

    File "/Users/admin/.python-for-android/build/other_builds/cryptography/arm64-v8a__ndk_target_21/cryptography/src/rust/cryptography-cffi/../../_cffi_src/utils.py", line 61, in build_ffi
      ffi = FFI()
            ^^^^^
    File "/Users/admin/.python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/cffi/api.py", line 48, in __init__
      import _cffi_backend as backend
  ImportError: dlopen(/Users/admin/.python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/Lib/site-packages/_cffi_backend.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_ffi_prep_closure'

On my linux x86_64 machine:

❯ nm -gD libffi.so | grep ffi_prep_closure
0000000000006e10 T ffi_prep_closure@@LIBFFI_CLOSURE_8.0
0000000000006da0 T ffi_prep_closure_loc@@LIBFFI_CLOSURE_8.0

Lib file is located at .buildozer/android/platform/build-armeabi-v7a/build/libs_collections/myapp/armeabi-v7a/

Edit: Actually I think this issue presisted in previous runs also but github didn't reported it. image All Apple M1 actions ran for 0 seconds :).

T-Dynamos avatar Feb 18 '24 13:02 T-Dynamos

@misl6 A friendly ping. Any progress on review?

T-Dynamos avatar Mar 09 '24 14:03 T-Dynamos

Apple M1 runner had some issues, let's wait until it picks up the jobs.

Apart from that, I can't test it promptly ATM as I'm majorly focused on kivy/kivy, but code LGTM and I do not see anything that can hurt the current packaging, so looks like just an improvement.

If the CI is happy, I will be happy too.

Just take into consideration to help out other users with docs/additional PRs if any issue arises.

misl6 avatar Mar 10 '24 09:03 misl6

@T-Dynamos can you please rebase on top of develop as CI pipeline for apple-silicon-m1 looks to fail on an issue that has already been fixed via https://github.com/kivy/python-for-android/pull/2842

misl6 avatar Mar 10 '24 13:03 misl6

@misl6 CI looks happy now.

T-Dynamos avatar Mar 17 '24 10:03 T-Dynamos

Looks like we have a failure on 3 jobs with almost the same issue:

2024-03-17T08:12:12.1384103Z     sources = self.generate_sources(sources, (lib_name, build_info))
2024-03-17T08:12:12.1384888Z               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-17T08:12:12.1386664Z   File "/home/user/.local/share/python-for-android/build/other_builds/numpy/arm64-v8a__ndk_target_21/numpy/numpy/distutils/command/build_src.py", line 378, in generate_sources
2024-03-17T08:12:12.1388177Z     source = func(extension, build_dir)
2024-03-17T08:12:12.1388716Z              ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-17T08:12:12.1390355Z   File "/home/user/.local/share/python-for-android/build/other_builds/numpy/arm64-v8a__ndk_target_21/numpy/numpy/core/setup.py", line 702, in get_mathlib_info
2024-03-17T08:12:12.1391864Z     config_cmd.compiler = bk_c.cxx_compiler()
2024-03-17T08:12:12.1392413Z                           ^^^^^^^^^^^^^^^^^
2024-03-17T08:12:12.1393495Z AttributeError: 'UnixCCompiler' object has no attribute 'cxx_compiler'

Can you make sure you have rebased on top of latest develop branch?

I'm wondering if the setuptools version bump may be the issue?

misl6 avatar Mar 19 '24 17:03 misl6

Looks like we have a failure on 3 jobs with almost the same issue:

2024-03-17T08:12:12.1384103Z     sources = self.generate_sources(sources, (lib_name, build_info))
2024-03-17T08:12:12.1384888Z               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-17T08:12:12.1386664Z   File "/home/user/.local/share/python-for-android/build/other_builds/numpy/arm64-v8a__ndk_target_21/numpy/numpy/distutils/command/build_src.py", line 378, in generate_sources
2024-03-17T08:12:12.1388177Z     source = func(extension, build_dir)
2024-03-17T08:12:12.1388716Z              ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-17T08:12:12.1390355Z   File "/home/user/.local/share/python-for-android/build/other_builds/numpy/arm64-v8a__ndk_target_21/numpy/numpy/core/setup.py", line 702, in get_mathlib_info
2024-03-17T08:12:12.1391864Z     config_cmd.compiler = bk_c.cxx_compiler()
2024-03-17T08:12:12.1392413Z                           ^^^^^^^^^^^^^^^^^
2024-03-17T08:12:12.1393495Z AttributeError: 'UnixCCompiler' object has no attribute 'cxx_compiler'

Can you make sure you have rebased on top of latest develop branch?

I'm wondering if the setuptools version bump may be the issue?

Yes setuptools version bump is the issue, I think this is the time to update numpy to latest version. I will do this ASAP.

T-Dynamos avatar Mar 19 '24 17:03 T-Dynamos

@misl6 Done! :fire: .

T-Dynamos avatar Mar 20 '24 11:03 T-Dynamos

@misl6 Any update on this?

T-Dynamos avatar Mar 27 '24 17:03 T-Dynamos

@misl6 Fixed.

T-Dynamos avatar Mar 31 '24 05:03 T-Dynamos

Sorry had to do one last change, please cancel other actions.

T-Dynamos avatar Mar 31 '24 08:03 T-Dynamos