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

Please add chaquopy support to be built into a library module (AAR) #94

Closed
gecsbernat opened this issue Mar 12, 2019 · 26 comments
Closed

Comments

@gecsbernat
Copy link

gecsbernat commented Mar 12, 2019

I am trying to use chaquopy https://chaquo.com/chaquopy/ android plugin for developing an android app that uses python script for some serious calculations, and I would like to make the app module as an android library (.AAR) to be able to reuse that in other project. (.eg ionic app).

@audvi
Copy link

audvi commented May 28, 2019

Yes, that would be a really nice feature. I would need it too.

@mhsmith
Copy link
Member

mhsmith commented May 28, 2019

If anyone else would like this feature, please subscribe to this issue and add a thumbs-up above.

@im-ranu
Copy link

im-ranu commented Oct 14, 2019

I need too

@SNVID
Copy link

SNVID commented Oct 23, 2019

Agree - would be a great feature!

@VicentIborra
Copy link

VicentIborra commented Jan 20, 2020

I need to use chaquopy plugin from an android library too.

@ghost
Copy link

ghost commented Mar 3, 2020

This feature is great

@VicentIborra
Copy link

VicentIborra commented Mar 12, 2020

Hi, we need to use Python in an app module (com.android.library). It's possible to install ChaquoPy in a module with 7.0.2 version? Thanks!

@mhsmith
Copy link
Member

mhsmith commented Mar 12, 2020

Currently Chaquopy can only be used in a top-level app, not in an AAR.

@VicentIborra
Copy link

VicentIborra commented Mar 13, 2020

We need this feature for our project. It's scheduled to develop this function in Chaquopy?

@mhsmith
Copy link
Member

mhsmith commented Mar 13, 2020

Can you give some details of your development workflow, and explain why you want to use Chaquopy in an AAR rather than directly in the top-level app?

@mhsmith
Copy link
Member

mhsmith commented Mar 13, 2020

@audvi @im-ranu @SNVID @TheForgetTime: Can you answer the question above? I'd like to understand why people need this feature.

@audvi
Copy link

audvi commented Mar 13, 2020

@VicentIborra
Copy link

VicentIborra commented Mar 13, 2020

Hi Malcolm,
We are developing a module for a project. This project is an Android app, but our module is only an optional part of this project. We need allow people of another University to work with the app without this module. We can't force people to install ChaquoPy, dependencies, Python libraries... They only need these features if they decide to install our module, so we need install Python from the module, not from the app.

@SNVID
Copy link

SNVID commented Mar 13, 2020

Hi @mhsmith ,

I gave a thumbs up for this feature because my company has a Xamarin application that could make use of a separate python application we have.

Xamarin cannot directly use Android code, however it can bind Android libraries for use.

BTW The native Android application we tested Chaquopy with worked wonderfully well as a top level app!

@mhsmith
Copy link
Member

mhsmith commented Mar 13, 2020

Thanks everyone for your replies. I'm thinking of adding support for a single Chaquopy-based AAR per app. So your options would be either:

  • Build Chaquopy into the top-level app, but not any AAR; or
  • Build Chaquopy into exactly one AAR, but not the top-level app. The top-level app would still be able to use the Chaquopy API to access the AAR's Python code, but it wouldn't be able to contain any Python code of its own.

Would this solve your use cases?

@VicentIborra
Copy link

VicentIborra commented Mar 13, 2020

Thanks Malcolm,
Could I build Chaquopy in the AAR and run Python scripts from this AAR? In this case, settings will be in gradle files of the module, right? Do I need some configuration in app level files?

@mhsmith
Copy link
Member

mhsmith commented Mar 13, 2020

All the Python settings would be in the library module's build.gradle file. The only change required to the app-level build.gradle file would be to add the library as a dependency.

@VicentIborra
Copy link

VicentIborra commented Mar 13, 2020

Thanks, I tested and I received this error (with ChaquoPy 6.3.0):

groovy.lang.MissingPropertyException: Could not get unknown property 'applicationVariants' for object of type com.android.build.gradle.LibraryExtension.
	at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:87)
	at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:61)
	at com.android.build.gradle.LibraryExtension_Decorated.getProperty(Unknown Source)
	at com.chaquo.python.PythonPlugin.afterEvaluate(PythonPlugin.groovy:182)
	at com.chaquo.python.PythonPlugin$_apply_closure2.doCall(PythonPlugin.groovy:54)

@mhsmith
Copy link
Member

mhsmith commented Mar 13, 2020

Yes, it won't work in the current version, I was talking about a plan for the next version.

@bdovaz
Copy link

bdovaz commented Mar 19, 2020

Yes, please. I'm also developing an Android app in Xamarin that need to use this library to run some python code.

@mhsmith mhsmith changed the title Please add chaquopy support to be built into an AAR Please add chaquopy support to be built into a library module (AAR) Apr 17, 2020
@aditmodhvadia
Copy link

aditmodhvadia commented Apr 17, 2020

This would be a very useful feature. As it provides separation of concern and independence in development flow.

@mhsmith
Copy link
Member

mhsmith commented Jun 15, 2020

This issue is fixed in Chaquopy 8.0.0. To upgrade, open your app's top-level build.gradle file and change the version number of com.chaquo.python:gradle.

As mentioned above, Chaquopy can still only be used in one module in a project: either in the app module, or in exactly one library module. Attempting to use it in multiple modules will give the error “More than one file was found with OS independent path”.

@mhsmith mhsmith closed this as completed Jun 15, 2020
@vidheyoza
Copy link

vidheyoza commented Jun 26, 2020

Hi,

Thank you for the new release!

We use JitPack to easily sync up our library modules to the main app. I added a new release for the library and went to JitPack to import as dependency, but it is showing this error log:

A problem occurred starting process 'command 'python3''. Please set buildPython to your Python executable path. See https://chaquo.com/chaquopy/doc/current/android.html#buildpython.

Also, I'm getting this error while trying to add the dependency:

Failed to resolve: com.github.organization:app-python-library:v0.0.1

Are these issues connected? And how do I resolve them? I've passed the right dependencies for JitPack as well as Chaquopy.

@mhsmith
Copy link
Member

mhsmith commented Jun 26, 2020

If you're using a service to build a Chaquopy-based module, then that service will need to have Python available. The only way to avoid this is if your module doesn't use any feature which runs Python at build time: specifically, the features in these sections of the documentation:

  • Requirements
  • Bytecode compilation
  • Static proxy generator

@vidheyoza
Copy link

vidheyoza commented Jun 26, 2020

Okay, so the alternative would be to update the package manually on the main app whenever I make changes on the AAR right?

@mhsmith
Copy link
Member

mhsmith commented Jun 26, 2020

I think your options are:

  • Arrange for Python to be available on the JitPack server, if possible; or
  • Build the AAR yourself rather than using JitPack.

@chaquo chaquo deleted a comment from arnavpon May 1, 2022
@chaquo chaquo deleted a comment from arnavpon May 5, 2022
@chaquo chaquo locked and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants