chaquo / chaquopy

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

Problems using curl_cffi python library #866

Open vitalikover opened 1 year ago

vitalikover commented 1 year ago

Chaquopy version

14.0.2

Devices or emulators where the issue happens

All

Relevant parts of your code

python {
            buildPython "C:/Users/User/AppData/Local/Programs/Python/Python310/python.exe"
            pip {
                install "requests==2.28.1"
                install "beautifulsoup4==4.12.0"
                install "websocket_client==1.5.1"
                install "curl_cffi"
            }
        }

Describe your issue

ERROR: Command errored out with exit status 1:
   command: 'C:\Users\User\AppData\Local\Programs\Python\Python310\python.exe' 'C:\Users\User\AndroidStudioProjects\kit\Analyzer\app\build\generated\python\bp\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\USER~1\AppData\Local\Temp\tmphqcrxkjg'
       cwd: C:\Users\User\AppData\Local\Temp\pip-install-b8n6_9ow\curl-cffi
  Complete output (82 lines):
  C:\Users\User\AppData\Local\Temp\pip-build-env-82gwkxnb\overlay\Lib\site-packages\setuptools\config\pyprojecttoml.py:66: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
    config = read_configuration(filepath, True, ignore_option_errors, dist)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-cpython-310
  creating build\lib.win-amd64-cpython-310\curl_cffi
  copying curl_cffi\aio.py -> build\lib.win-amd64-cpython-310\curl_cffi
  copying curl_cffi\build.py -> build\lib.win-amd64-cpython-310\curl_cffi
  copying curl_cffi\const.py -> build\lib.win-amd64-cpython-310\curl_cffi
  copying curl_cffi\curl.py -> build\lib.win-amd64-cpython-310\curl_cffi
  copying curl_cffi\__init__.py -> build\lib.win-amd64-cpython-310\curl_cffi
  creating build\lib.win-amd64-cpython-310\curl_cffi\requests
  copying curl_cffi\requests\cookies.py -> build\lib.win-amd64-cpython-310\curl_cffi\requests
  copying curl_cffi\requests\errors.py -> build\lib.win-amd64-cpython-310\curl_cffi\requests
  copying curl_cffi\requests\headers.py -> build\lib.win-amd64-cpython-310\curl_cffi\requests
  copying curl_cffi\requests\session.py -> build\lib.win-amd64-cpython-310\curl_cffi\requests
  copying curl_cffi\requests\__init__.py -> build\lib.win-amd64-cpython-310\curl_cffi\requests
  running egg_info
  writing curl_cffi.egg-info\PKG-INFO
  writing dependency_links to curl_cffi.egg-info\dependency_links.txt
  writing requirements to curl_cffi.egg-info\requires.txt
  writing top-level names to curl_cffi.egg-info\top_level.txt
  reading manifest file 'curl_cffi.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching 'curl_cffi\cacert.pem'
  warning: no files found matching 'curl_cffi\_wrapper.*'
  warning: no files found matching 'curl_cffi\include\curl\*'
  adding license file 'LICENSE'
  writing manifest file 'curl_cffi.egg-info\SOURCES.txt'
  C:\Users\User\AppData\Local\Temp\pip-build-env-82gwkxnb\overlay\Lib\site-packages\setuptools\command\build_py.py:201: _Warning: Package 'curl_cffi.ffi' is absent from the `packages` configuration.
  !!

          ********************************************************************************
          ############################
          # Package would be ignored #
          ############################
          Python recognizes 'curl_cffi.ffi' as an importable package[^1],
          but it is absent from setuptools' `packages` configuration.

          This leads to an ambiguous overall configuration. If you want to distribute this
          package, please make sure that 'curl_cffi.ffi' is explicitly added
          to the `packages` configuration field.

          Alternatively, you can also rely on setuptools' discovery methods
  ERROR: Command errored out with exit status 1:

          (for example by using `find_namespace_packages(...)`/`find_namespace:`
          instead of `find_packages(...)`/`find:`).

          You can read more about "package discovery" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

          If you don't want 'curl_cffi.ffi' to be distributed and are
          already explicitly excluding 'curl_cffi.ffi' via
          `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
          you can try to use `exclude_package_data`, or `include-package-data=False` in
          combination with a more fine grained `package-data` configuration.

          You can read more about "package data files" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

          [^1]: For Python, any directory (with suitable naming) can be imported,
                even if it does not contain any `.py` files.
                On the other hand, currently there is no concept of package data
                directory, all directories are treated like packages.
          ********************************************************************************

  !!
    check.warn(importable)
  creating build\lib.win-amd64-cpython-310\curl_cffi\ffi
  copying curl_cffi\ffi\cdef.c -> build\lib.win-amd64-cpython-310\curl_cffi\ffi
  copying curl_cffi\ffi\shim.c -> build\lib.win-amd64-cpython-310\curl_cffi\ffi
  copying curl_cffi\ffi\shim.h -> build\lib.win-amd64-cpython-310\curl_cffi\ffi
  running build_ext
  generating cffi module 'build\\temp.win-amd64-cpython-310\\Release\\curl_cffi._wrapper.c'
  creating build\temp.win-amd64-cpython-310
  creating build\temp.win-amd64-cpython-310\Release
  building 'curl_cffi._wrapper' extension
  error: CCompiler.compile: Chaquopy cannot compile native code
  ----------------------------------------
ERROR: Failed to install curl_cffi from https://files.pythonhosted.org/packages/c2/dd/4d9eb70a400d8f083e88721f89f14ce9d0fd6cff1d19191f97c7a595752e/curl_cffi-0.5.5.tar.gz#sha256=db94b8d0ad52f3b5c55d32225c29a8219a19592d882075965a78aa9e1a0dead1.
For assistance, please raise an issue at https://github.com/chaquo/chaquopy/issues.
  warning: no files found matching 'curl_cffi\cacert.pem'

  warning: no files found matching 'curl_cffi\_wrapper.*'

  warning: no files found matching 'curl_cffi\include\curl\*'

  error: CCompiler.compile: Chaquopy cannot compile native code

Failed to install curl_cffi from https://files.pythonhosted.org/packages/c2/dd/4d9eb70a400d8f083e88721f89f14ce9d0fd6cff1d19191f97c7a595752e/curl_cffi-0.5.5.tar.gz#sha256=db94b8d0ad52f3b5c55d32225c29a8219a19592d882075965a78aa9e1a0dead1.

Chaquopy: Exit status 1

Cannot install curl_cffi python plugin or library. This allows you to make a request skipping the CloudFlare and the fingerprint.

mhsmith commented 1 year ago

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.

Randomboiii03 commented 1 year ago

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.

I tried following the instructions, i don't know if I'm doing it right, I get an error when BUILDING PACKAGE, and if I may request if you could add "curl-cffi" package in CHAQUOPY, greatly appreciated and thanks 🎉

image

mhsmith commented 1 year ago

build-wheel doesn't support the complete Conda meta.yaml syntax, only the subset defined in meta-schema.yaml. So you'll have to remove the sha256 line, and in this case you can probably remove the entire source section and let it download the sdist from PyPI automatically.

Randomboiii03 commented 1 year ago

build-wheel doesn't support the complete Conda meta.yaml syntax, only the subset defined in meta-schema.yaml. So you'll have to remove the sha256 line, and in this case you can probably remove the entire source section and let it download the sdist from PyPI automatically.

I remove everything except the package section in meta.yaml, below is the result, I'm sorry for inconvenience, as for last time request, if possible can you add this library, I'm still having hard time every time I read documentations😅 I greatly appreciate and thank you very much

image

mhsmith commented 1 year ago

As the README says, the build-wheel tool is only supported on Linux, not Windows. If you don't have a Linux machine available, a cheap virtual server from somewhere like DigitalOcean will do just fine. WSL or Docker may also work, though I haven't tried them myself.

Randomboiii03 commented 1 year ago

As the README says, the build-wheel tool is only supported on Linux, not Windows. If you don't have a Linux machine available, a cheap virtual server from somewhere like DigitalOcean will do just fine. WSL or Docker may also work, though I haven't tried them myself.

hello, did I successfully added the library in the package? can you check the image below?😁

image

mhsmith commented 1 year ago

The message is telling you exactly what to check. You probably used a dash in the package name in meta.yaml, where you should have used an underscore.

Randomboiii03 commented 1 year ago

The message is telling you exactly what to check. You probably used a dash in the package name in meta.yaml, where you should have used an underscore.

I red the instructions very carefully this time😅, why does it keep creating curl_cffi-0.0.0.dist-info instead of creating curl_cffi-0.5.7.dist-info that build-wheel required, did I miss anything?

image image image image

Randomboiii03 commented 1 year ago

@mhsmith can you check if I'm missing anything? btw this is my meta.yaml, thanks😁

package:
  name: curl_cffi
  version: 0.5.7

requirements:
  host:
    - python
mhsmith commented 1 year ago

Sorry for the slow reply. I'll have a look at this tomorrow.

Randomboiii03 commented 1 year ago

Sorry for the slow reply. I'll have a look at this tomorrow.

No problem and thanks, I really need this package for my capstone project🎉

Randomboiii03 commented 1 year ago

I apologize if I am not understanding the additional instructions. I am still a novice in this field, and I am really relying on this Python library for my project. Would you be able to add more details or provide some clarification? I think some people are waiting for this library to be added, so I would be grateful for your help.🎉

mhsmith commented 1 year ago

I'm looking at this issue right now, and I'll post an update in a few hours.

mhsmith commented 1 year ago

I've just pushed some updates to build-wheel which will fix this particular error. However, as the curl_cffi README says, this package is based on the curl-impersonate library, so you would have to build that first.

The relationship between cffi-curl and curl-impersonate would be similar to the existing packages pycurl and chaquopy-curl, so I suggest you look at those recipes.

If you need any more help, please don't post screenshots of text. Instead, copy and paste the text, and surround it with triple backticks as shown here.