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

Failed to install asammdf: error: CCompiler.compile: Chaquopy cannot compile native code #1242

Open
RicBar10 opened this issue Sep 11, 2024 · 3 comments
Labels

Comments

@RicBar10
Copy link

RicBar10 commented Sep 11, 2024

I'm trying to install asammdf in chaquopy to use this python library in my project but I can't find the way to solve this error: Chaquopy cannot compile native code

Chaquopy version

plugins {
    id("com.android.application") version "8.5.0" apply false
    id("com.chaquo.python") version "15.0.1" apply false
}

Relevant parts of your build.gradle file

android {
    namespace = "com.example.libicsneo_test"
    compileSdk = 34
    defaultConfig {
        applicationId = "com.example.libicsneo_test"
        minSdk = 23
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags += "-std=c++17"
            }
        }

        ndk {
            abiFilters += listOf("arm64-v8a", "x86_64")
        }

    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
        create("customDebugType") {
            isDebuggable = true
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    externalNativeBuild {
        cmake {
            path = file("src/main/cpp/CMakeLists.txt")
            version = "3.22.1"
        }
    }
    buildFeatures {
        viewBinding = true
    }
}
chaquopy {
    defaultConfig {
        buildPython("C:/Users/Public/Python3_9_9/python.exe")
        pip {
            install ("numpy")
            install ("asammdf")
        }
    }
    productFlavors {

    }
    sourceSets {
        getByName("main") {
            srcDir("src/main/python")
        }
    }
}

Describe your issue

I'm trying to include a python interpreter in my code in order to run the library asammdf.

Building wheel for asammdf (PEP 517): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: 'C:\ws\Adapt_icsneo\libicsneo_android\app\build\python\env\debug\Scripts\python.exe' 'C:\ws\Adapt_icsneo\libicsneo_android\app\build\python\env\debug\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\p123130\AppData\Local\Temp\tmpvdjpakm8'
       cwd: C:\Users\p123130\AppData\Local\Temp\pip-install-g9m11d00\asammdf
  Complete output (170 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-cpython-39
  creating build\lib.win-amd64-cpython-39\asammdf
  ERROR: Command errored out with exit status 1:

  copying src\asammdf\mdf.py -> build\lib.win-amd64-cpython-39\asammdf
  copying src\asammdf\signal.py -> build\lib.win-amd64-cpython-39\asammdf
  copying src\asammdf\tool.py -> build\lib.win-amd64-cpython-39\asammdf
  copying src\asammdf\types.py -> build\lib.win-amd64-cpython-39\asammdf
  copying src\asammdf\version.py -> build\lib.win-amd64-cpython-39\asammdf
  copying src\asammdf\__init__.py -> build\lib.win-amd64-cpython-39\asammdf
  creating build\lib.win-amd64-cpython-39\asammdf\blocks
  copying src\asammdf\blocks\bus_logging_utils.py -> build\lib.win-amd64-cpython-39\asammdf\blocks

 copying src\asammdf\gui\ui\tabular_filter.ui -> build\lib.win-amd64-cpython-39\asammdf\gui\ui
  copying src\asammdf\gui\ui\vrtt_widget.ui -> build\lib.win-amd64-cpython-39\asammdf\gui\ui
  copying src\asammdf\gui\ui\vtt_widget.ui -> build\lib.win-amd64-cpython-39\asammdf\gui\ui
  copying src\asammdf\gui\ui\windows_selection_dialog.ui -> build\lib.win-amd64-cpython-39\asammdf\gui\ui
  running build_ext
  building 'asammdf.blocks.cutils' extension
  error: CCompiler.compile: Chaquopy cannot compile native code

ERROR: Failed to install asammdf from https://files.pythonhosted.org/packages/3b/2a/dd0e1e65a7b7d196d3114b3b1819c329f5576282cf377b55376572b84455/asammdf-7.4.5.tar.gz#sha256=b0c149daea22c5b2a47ceb2f63099f78adbd68117894473f21ed9dfc2c5217a4.
For assistance, please raise an issue at https://github.com/chaquo/chaquopy/issues.
  error: CCompiler.compile: Chaquopy cannot compile native code

Failed to install asammdf from https://files.pythonhosted.org/packages/3b/2a/dd0e1e65a7b7d196d3114b3b1819c329f5576282cf377b55376572b84455/asammdf-7.4.5.tar.gz#sha256=b0c149daea22c5b2a47ceb2f63099f78adbd68117894473f21ed9dfc2c5217a4.

Chaquopy: Exit status 1

> Task :app:generateDebugPythonRequirements FAILED
Execution failed for task ':app:generateDebugPythonRequirements'.
> Process 'command 'C:\ws\Adapt_icsneo\libicsneo_android\app\build\python\env\debug\Scripts\python.exe'' finished with non-zero exit value 1 
@mhsmith
Copy link
Member

mhsmith commented Sep 13, 2024

This package contains native components, so it would have to be built into an Android wheel file. If you'd like to try doing this yourself, follow the instructions here. And if you're successful, please make a pull request so we can add the package to the public repository.

If anyone else wants this package too, let us know by clicking the thumbs-up button above.

@RicBar10
Copy link
Author

RicBar10 commented Sep 16, 2024

Hello, Thank you for your answer. I see that to use the building-wheel tool I need to create a PACKAGE with a meta.yaml. Inside this file I understood that in requirement:host: we need to add our requirements for the lib we want to build. For asammdf I see in the pypi website the requirements. But some of them like numexpr, wheel, canmatrix, natsort, and python-dateuil are not in the the public repository to save them manually in dist/ repository.
Should I create a package for those repositories too?

@mhsmith
Copy link
Member

mhsmith commented Sep 16, 2024

You only need to worry about the requirements which are native-compiled, i.e. those which DON'T have a "none-any" wheel in the package's "download files" page on PyPI. For example, numexpr is native, but wheel is pure-Python.

And even if you need to build some native requirements, they don't usually need to be listed in the meta.yaml file. Only requirements used during the build need to be listed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants