Giter Site home page Giter Site logo

cffi port about pycares HOT 8 CLOSED

saghul avatar saghul commented on July 28, 2024
cffi port

from pycares.

Comments (8)

saghul avatar saghul commented on July 28, 2024

Wow, great work! Yes, I would like to integrate it, of course! I think we should do as follows:

  • Have the main pycares module, and then a _core and _cfficore modules
  • By default build the cffi core on PyPy, and the regular one elsewhere
  • If an env var is set or an option is passed to setup.py, we could build the cffi version too on CPython

How does it sound? If this something you'd like to work on? If so, feel free to send a Pull Request when you are ready for review!

from pycares.

boytm avatar boytm commented on July 28, 2024

Does _cfficore dpends on _core, or _cfficore contain C cares library iteself ? Use simple python init.py to wrap standard _core module?

from pycares.

saghul avatar saghul commented on July 28, 2024

So, I think _core would be the current pycares, that is, embedding c-ares. Then _cfficore would be what you wrote, and in __init__.py we'd try-import one or the other.

from pycares.

boytm avatar boytm commented on July 28, 2024

On python, should build two or only build one? If only build one, I think no need to rename current pycares.pyd to _core.pyd .
If build both on python , should usage cffi version like below ?
import pycares.cffi as pycares
And normal usage is
import pycares

from pycares.

saghul avatar saghul commented on July 28, 2024

We would build one or the other, depending on the environment. The reason to use _core and _cfficore is so users can import pycares and not care about it.

Here is a similar approach: https://github.com/saghul/python-fibers in one case I use a C extension, on the other a PyPy builtin.

from pycares.

saghul avatar saghul commented on July 28, 2024

Done in #29.

from pycares.

thestick613 avatar thestick613 commented on July 28, 2024

This doesn't work as expected. I get this error for pip install pycares from a pypy virtualenv:

      File "/usr/lib/pypy/lib_pypy/cffi/setuptools_ext.py", line 128, in run
        ext.sources[0] = make_mod(self.build_temp, pre_run)
      File "/usr/lib/pypy/lib_pypy/cffi/setuptools_ext.py", line 114, in make_mod
        updated = recompiler.make_c_source(ffi, module_name, source, c_file)
      File "/usr/lib/pypy/lib_pypy/cffi/recompiler.py", line 1365, in make_c_source
        verbose)
      File "/usr/lib/pypy/lib_pypy/cffi/recompiler.py", line 1340, in _make_c_or_py_source
        recompiler.collect_step_tables()
      File "/usr/lib/pypy/lib_pypy/cffi/recompiler.py", line 233, in collect_step_tables
        self._generate("ctx")
      File "/usr/lib/pypy/lib_pypy/cffi/recompiler.py", line 218, in _generate
        method(tp, realname)
      File "/usr/lib/pypy/lib_pypy/cffi/recompiler.py", line 962, in _generate_cpy_struct_ctx
        self._struct_ctx(tp, *self._struct_names(tp))
      File "/usr/lib/pypy/lib_pypy/cffi/recompiler.py", line 866, in _struct_ctx
        "field '%s.%s'" % (tp.name, fldname))
      File "/usr/lib/pypy/lib_pypy/cffi/recompiler.py", line 921, in _check_not_opaque
        "%s is of an opaque type (not declared in cdef())" % location)
    TypeError: struct sockaddr_in6: field 'sockaddr_in6.sin6_addr' is of an opaque type (not declared in cdef())
    Complete output from command /root/venv_smtpout_pypy30/bin/pypy -c "import setuptools, tokenize;__file__='/root/venv_smtpout_pypy30/build/pycares/setup.py';exec(compile(getattr(tokenize, 'open',:
    running install

I don't get this when i'm running boytm's fork from github.

from pycares.

saghul avatar saghul commented on July 28, 2024

Can you please open a new issue? Please mention what platform you're running, since the CFFI port works fine in the CI, but might still need some tweaking. Thanks!

from pycares.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.