Skip to content

Arch type error when creating apk for project with setup.py#2978

Merged
AndreMiras merged 1 commit into
kivy:developfrom
rivian:arch-ref-fix
Feb 29, 2024
Merged

Arch type error when creating apk for project with setup.py#2978
AndreMiras merged 1 commit into
kivy:developfrom
rivian:arch-ref-fix

Conversation

@pramodin

Copy link
Copy Markdown
Contributor

p4a apk failing for project with setup.py because arch string is being passed into a method that's expecting the arch object. Below is the build output

INFO:p4a:[INFO]: android==1.0
Cython==3.0.8
pyjnius==1.6.1
six==1.15.0

[INFO]: Populating venv's site-packages with ctx.get_site_packages_dir()...
INFO:p4a:[INFO]: Populating venv's site-packages with ctx.get_site_packages_dir()...
Traceback (most recent call last):
File "/home/pimmaneni/.local/bin/p4a", line 8, in
sys.exit(main())
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/toolchain.py", line 685, in init
getattr(self, command)(args)
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/toolchain.py", line 104, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/toolchain.py", line 163, in build_dist_from_args
build_recipes(build_order, python_modules, ctx,
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/build.py", line 528, in build_recipes
run_pymodules_install(
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/build.py", line 767, in run_pymodules_install
run_setuppy_install(ctx, project_dir, env, arch.arch)
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/build.py", line 579, in run_setuppy_install
os.path.abspath(ctx.get_site_packages_dir(arch))
File "/home/pimmaneni/.local/lib/python3.10/site-packages/pythonforandroid/build.py", line 424, in get_site_packages_dir
return self.get_python_install_dir(arch.arch)
AttributeError: 'str' object has no attribute 'arch'

@AndreMiras

AndreMiras commented Feb 29, 2024

Copy link
Copy Markdown
Member

Thanks for the report and the fix.
We must have a bug somewhere else then because I think it should really be a Arch object and not the string.
We need to look this up higher in the stack, like why is the Context.archs list is being fed with strings rather than Arch objects at some points. Because in other scenarios I think it does receive the right Arch object, so I think the fix you're proposing currently would break something else.
We miss a lot of type hint across the project too that doesn't help with debugging/maintaining these types of issues

Edit:
My bad I think I'm getting confused, give me some time to go through some testing.
Could you also provide a minimal reproduction scenario to help debugging the issue?

@AndreMiras

Copy link
Copy Markdown
Member

Took a deeper look and yes you're definitely right with that change. Will run through few more tests and merge later.
Thanks for the heads up and the fix again. After merging I'll probably update some unit tests and add some type hints

@AndreMiras AndreMiras merged commit b3cc034 into kivy:develop Feb 29, 2024
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

Successfully merging this pull request may close these issues.

2 participants