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 av #1012

Open
sinabolouki opened this issue Nov 3, 2023 · 10 comments
Open

Failed to install av #1012

sinabolouki opened this issue Nov 3, 2023 · 10 comments
Labels

Comments

@sinabolouki
Copy link

Chaquopy version

14.0.2

Relevant parts of your build.gradle file

app build.gradle:

python {
            pip {
                install "six"
                install "av"
            }
        }
        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }

Describe your issue

ERROR: Failed to install av from https://files.pythonhosted.org/packages/09/45/eb750ba15c44e8106f58a22e6789f5ddbe5584d9dcb4e755b08d47ed6261/av-10.0.0.tar.gz#sha256=8afd3d5610e1086f3b2d8389d66672ea78624516912c93612de64dcaa4c67e05.

build log (:app:generateDebugPythonRequirements):

> Task :app:generateDebugPythonRequirements
Chaquopy: Installing for arm64-v8a
Looking in indexes: https://pypi.org/simple, https://chaquo.com/pypi-7.0, https://chaquo.com/pypi-13.1
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting av
  Using cached av-10.0.0.tar.gz (2.4 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /Users/sinabolouki/.pyenv/versions/3.8.5/bin/python3.8 /Users/sinabolouki/CrowdCognitionProjects/chaquopy-console/app/build/generated/python/bp/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/tmp_19pei3c
  ERROR: Command errored out with exit status 1:

       cwd: /private/var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/pip-install-7ekrgg26/av
  Complete output (77 lines):
  Compiling av/plane.pyx because it changed.
  [1/1] Cythonizing av/plane.pyx
  Compiling av/dictionary.pyx because it changed.
  [1/1] Cythonizing av/dictionary.pyx
  Compiling av/stream.pyx because it changed.
  [1/1] Cythonizing av/stream.pyx
  Compiling av/option.pyx because it changed.
  [1/1] Cythonizing av/option.pyx
  Compiling av/enum.pyx because it changed.
  [1/1] Cythonizing av/enum.pyx
  Compiling av/bytesource.pyx because it changed.
  [1/1] Cythonizing av/bytesource.pyx
  Compiling av/buffer.pyx because it changed.
  [1/1] Cythonizing av/buffer.pyx
  Compiling av/packet.pyx because it changed.
  [1/1] Cythonizing av/packet.pyx
  Compiling av/error.pyx because it changed.
  [1/1] Cythonizing av/error.pyx
  Compiling av/_core.pyx because it changed.
  [1/1] Cythonizing av/_core.pyx
  Compiling av/format.pyx because it changed.
  [1/1] Cythonizing av/format.pyx
  performance hint: av/logging.pyx:232:5: Exception check on 'log_callback' will always require the GIL to be acquired.
  Possible solutions:
  	1. Declare the function as 'noexcept' if you control the definition and you're sure you don't want the function to raise exceptions.
  	2. Use an 'int' return type on the function to allow an error code to be returned.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  cdef const char *log_context_name(void *ptr) nogil:
      cdef log_context *obj = <log_context*>ptr
      return obj.name
  
  cdef lib.AVClass log_class
  log_class.item_name = log_context_name
                        ^
  ------------------------------------------------------------
  
  av/logging.pyx:216:22: Cannot assign type 'const char *(void *) except? NULL nogil' to 'const char *(*)(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'const char *(void *) except? NULL nogil'.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  
  # Start the magic!
  # We allow the user to fully disable the logging system as it will not play
  # nicely with subinterpreters due to FFmpeg-created threads.
  if os.environ.get('PYAV_LOGGING') != 'off':
      lib.av_log_set_callback(log_callback)
                              ^
  ------------------------------------------------------------
  
  av/logging.pyx:351:28: Cannot assign type 'void (void *, int, const char *, va_list) except * nogil' to 'av_log_callback'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (void *, int, const char *, va_list) except * nogil'.
  Compiling av/logging.pyx because it changed.
  [1/1] Cythonizing av/logging.pyx
  Traceback (most recent call last):
    File "/Users/sinabolouki/CrowdCognitionProjects/chaquopy-console/app/build/generated/python/bp/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/Users/sinabolouki/CrowdCognitionProjects/chaquopy-console/app/build/generated/python/bp/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/sinabolouki/CrowdCognitionProjects/chaquopy-console/app/build/generated/python/bp/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/pip-build-env-0jm_ci9b/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/private/var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/pip-build-env-0jm_ci9b/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/pip-build-env-0jm_ci9b/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 507, in run_setup
      super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
    File "/private/var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/pip-build-env-0jm_ci9b/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in run_setup
      exec(code, locals())
    File "<string>", line 157, in <module>
    File "/private/var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/pip-build-env-0jm_ci9b/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
      cythonize_one(*args)
    File "/private/var/folders/tq/06mpcysn5496dy4jmr3fknb00000gp/T/pip-build-env-0jm_ci9b/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: av/logging.pyx

I think the problem can be fixed by changing default Cython version. Is it possible?

@sinabolouki
Copy link
Author

@mhsmith Can you help me with this issue?

@mhsmith
Copy link
Member

mhsmith commented Nov 7, 2023

This package contains native components, so it would have to be built into a 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.

@mhsmith
Copy link
Member

mhsmith commented Nov 7, 2023

Originally posted by @sinabolouki in #1018


I'm trying to build the pyAV for Chaquopy but I face this error:

build-wheel: cd /root/chaquopyStuff/chaquopy/server/pypi/packages/av/build/10.0.0/cp310-cp310-android_21_armeabi_v7a/src
Package libavformat was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavformat.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavformat' found
Package libavcodec was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavcodec.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavcodec' found
Package libavdevice was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavdevice.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavdevice' found
Package libavutil was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavutil.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavutil' found
Package libavfilter was not found in the pkg-config search path.
Perhaps you should add the directory containing `libavfilter.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libavfilter' found
Package libswscale was not found in the pkg-config search path.
Perhaps you should add the directory containing `libswscale.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libswscale' found
Package libswresample was not found in the pkg-config search path.
Perhaps you should add the directory containing `libswresample.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libswresample' found
pkg-config could not find libraries ['avformat', 'avcodec', 'avdevice', 'avutil', 'avfilter', 'swscale', 'swresample']
build-wheel: Error: Backend subprocess exited when trying to invoke build_wheel

can anyone help fix this?

@mhsmith
Copy link
Member

mhsmith commented Nov 7, 2023

If you're trying to build a Python library that depends on a non-Python library, you'll usually have to build the non-Python library first as a separate package, unless the Python library comes with a bundled copy.

For example, see the packages chaquopy-libzmq and pyzmq, which are mentioned in the README.

@sinabolouki
Copy link
Author

I found out that these libraries are from ffmpeg project. I tried to build the libraries using ffmpeg-android-maker. I created a directory called chaquopy-ffmpeg under packages. There are two files called metal.yaml and build.sh under this directory.

meta.yaml:

{% set version = "2.8.4" %}

package:
  name: chaquopy-ffmpeg
  version: {{ version }} 

build:
  number: 0

source:
  url: https://github.com/Javernaut/ffmpeg-android-maker/archive/refs/tags/v{{version}}.tar.gz

build.sh:

#!/bin/bash
set -eu

./ffmpeg-android-maker.sh

while ffmpeg-android-maker.sh works fine when I run independently, I encounter an error when I'm trying to build-wheel.
The error:

$ANDROID_HOME/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android19-clang is unable to create an executable file.

C compiler test failed.

Can I fix this issue?

@mhsmith
Copy link
Member

mhsmith commented Nov 17, 2023

I think that when you set the ANDROID_NDK_HOME variable, you accidentally included a literal $ANDROID_HOME in the value, rather than allowing the environment variable to expand.

I also notice that the ffmpeg-android-maker README says "The script expects to use at least Android NDK r23", so it would be a good idea to set ANDROID_NDK_HOME accordingly.

@sinabolouki
Copy link
Author

I changed ANDROID_NDK_HOME to r23 but I still could not fix this issue.

The new error:

Building the component: ffmpeg
/home/sina/chaquopyStuff/android-sdk/ndk/23.2.8568313/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android19-clang is unable to create an executable file.
C compiler test failed.

@mhsmith
Copy link
Member

mhsmith commented Nov 27, 2023

The script's error handling isn't very good – it displays that error even if the compiler executable doesn't exist. You can install it by running $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager 'ndk;23.2.8568313'

Also, for convenience, I suggest adding the following lines to the top of build.sh:

export ANDROID_SDK_HOME=$ANDROID_HOME
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313

That way, you only need to set ANDROID_HOME.

@sinabolouki
Copy link
Author

sinabolouki commented Dec 6, 2023

unfortunately, that did not fix the issue. Is there anyway I can find the real problem? like log or something

@mhsmith
Copy link
Member

mhsmith commented Dec 6, 2023

Do you mean you've installed ndk;23.2.8568313, and edited the script as suggested, but you still get the "unable to create an executable file" message? If so, does the clang path in the message actually exist?

Or if you got a different error, please post it here.

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