chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
807 stars 132 forks source link

jpype #1230

Open idbeny opened 1 month ago

idbeny commented 1 month ago

Chaquopy version

15.0.1

Relevant parts of your build.gradle file

android {
    // Android 14 == SDK Level 34. This number should generally be kept up to date with
    // the most recent supported Android release.
    compileSdkVersion 34

    namespace "com.abc.testbee.testbee"

    defaultConfig {
        applicationId "com.abc.testbee.testbee"
        versionCode 100
        versionName "0.0.1"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        // Briefcase currently requires API Level 24 for the `pidof` command, and the `--pid`
        // argument to `adb logcat`. This supports over 90% of active devices
        // (https://github.com/beeware/rubicon-java/issues/74).
        minSdkVersion 24
        // This should gnerally match the compileSDKVersion from above.

        targetSdkVersion 34

        python {
            version "3.11"
            pip {
                install "-r", "requirements.txt"
            }
            extractPackages "tests"
        }
        ndk {

            // Chaquopy also supports x86, but it's not very useful anymore, so we'll
            // disable it to speed up the build.
            abiFilters "arm64-v8a", "armeabi-v7a", "x86_64"

        }
    }

    compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            python.srcDirs = [
                "src/main/python",  // App code
                "src/main/python-briefcase",  // Template code
            ]
        }
    }
}

Describe your issue

Building wheels for collected packages: JPype1
  Building wheel for JPype1 (PEP 517): started
  Building wheel for JPype1 (PEP 517): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /Users/ben/tmp/beeware/testbee/build/testbee/android/gradle/app/build/python/env/debug/bin/python /Users/ben/tmp/beeware/testbee/build/testbee/android/gradle/app/build/python/env/debug/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/9l/1h4kh9kd5236t_rjrc7n7ldw0000gn/T/tmp2_d4010q
       cwd: /private/var/folders/9l/1h4kh9kd5236t_rjrc7n7ldw0000gn/T/pip-install-1rlk9vet/JPype1
  Complete output (61 lines):
  /private/var/folders/9l/1h4kh9kd5236t_rjrc7n7ldw0000gn/T/pip-install-1rlk9vet/JPype1/setupext/pytester.py:20: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated.
  !!

          ********************************************************************************
          Please remove any references to `setuptools.command.test` in all supported versions of the affected package.

          By 2024-Nov-15, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.
          ********************************************************************************

  !!
    from setuptools.command.test import test as TestCommand
  /private/var/folders/9l/1h4kh9kd5236t_rjrc7n7ldw0000gn/T/pip-build-env-n6_pkxhv/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py:268: UserWarning: Unknown distribution option: 'tests_require'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-universal2-cpython-311
  creating build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jcollection.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_classpath.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jio.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_pykeywords.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jproxy.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_gui.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/config.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jmethod.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/nio.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jstring.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/protocol.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/__init__.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/types.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/beans.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jvmfinder.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/imports.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jcustomizer.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_core.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jthread.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jinit.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jarray.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jobject.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/dbapi2.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/pickle.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jclass.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jexception.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jpackage.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  creating build/lib.macosx-10.9-universal2-cpython-311/jpype/_pyinstaller
  copying jpype/_pyinstaller/entry_points.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype/_pyinstaller
  copying jpype/_pyinstaller/test_jpype_pyinstaller.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype/_pyinstaller
  copying jpype/_pyinstaller/example.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype/_pyinstaller
  copying jpype/_pyinstaller/hook-jpype.py -> build/lib.macosx-10.9-universal2-cpython-311/jpype/_pyinstaller
  copying jpype/_jio.pyi -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  copying jpype/_jcollection.pyi -> build/lib.macosx-10.9-universal2-cpython-311/jpype
  running build_ext
  Call build extensions
  Using Jar cache
  copying native/jars/org.jpype.jar -> build/lib.macosx-10.9-universal2-cpython-311
  Call build ext
  building '_jpype' extension
  error: CCompiler.compile: Chaquopy cannot compile native code
  ----------------------------------------
ERROR: Failed to install JPype1==1.5.0 from https://files.pythonhosted.org/packages/25/42/8ca50a0e27e3053829545829e7bcba071cbfa4d5d8fd7fc5d1d988f325b1/JPype1-1.5.0.tar.gz#sha256=425a6e1966afdd5848b60c2688bcaeb7e40ba504a686f1114589668e0631e878 (from -r requirements.txt (line 21)).
For assistance, please raise an issue at https://github.com/chaquo/chaquopy/issues.
Chaquopy: Exit status 1

> Task :app:generateDebugPythonRequirements FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateDebugPythonRequirements'.
> Process 'command '/Users/ben/tmp/beeware/testbee/build/testbee/android/gradle/app/build/python/env/debug/bin/python'' finished with non-zero exit value 1

  To view full details in Android Studio:
  * Click the 'Build: failed' caption to the left of this message.
  * Then scroll up to see the full output.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 46s
2 actionable tasks: 1 executed, 1 up-to-date
Building... errored

Error while building project.
idbeny commented 1 month ago

I want to use jpype to support android and linux. I don't know how to deal with it, please help me.

mhsmith commented 1 month ago

For previous discussion about jpype, see #120.

Why exactly do you want to use jpype, i.e. which Java libraries do you want to access?

idbeny commented 1 month ago

Our research team believes that jpype has the most active community. It supports Linux and Android. Our other non-mobile Python projects all use jpype, and we also hope to reuse it.

mhsmith commented 1 month ago

Unfortunately there's no simple way of using Jpype on Android right now, but the Chaquopy Python API has a very similar syntax.

If you're including JARs with your app, you'll need to list them in the dependencies section of your build.gradle file. Loading JARs at runtime is not possible, because Android uses a different bytecode format.