saghul / pycares

Python interface for c-ares
https://pypi.org/project/pycares/
MIT License
165 stars 73 forks source link

Failed to build on Apple's M1, arm64 architecture (osx-arm64) #133

Closed kartzke closed 3 years ago

kartzke commented 3 years ago

Hello, I'm using one of the new Apple M1 MacBooks with the ARM processor. I tried to install another package where pycares is a dependency, and I got the following error. Any suggestions for a fix? Not sure if this is the problem, but I see a lot of references to x86 and -arch x86_64, which is the Intel arch.

`Failed to build pycares Installing collected packages: pycares, async-timeout, aiohttp, aiodns, ccxt Running setup.py install for pycares ... error ERROR: Command errored out with exit status 1: command: /Users/ryan/miniforge3/envs/ft/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-1nnuf10i/pycares_9779f70fc2de401684607222c93c0ad1/setup.py'"'"'; file='"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-1nnuf10i/pycares_9779f70fc2de401684607222c93c0ad1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-record-zjqxxs6d/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ryan/miniforge3/envs/ft/include/python3.8/pycares cwd: /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-1nnuf10i/pycares_9779f70fc2de401684607222c93c0ad1/ Complete output (105 lines): running install running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.8 creating build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/errno.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/_version.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/init.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/utils.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/main.py -> build/lib.macosx-10.9-x86_64-3.8/pycares running build_ext generating cffi module 'build/temp.macosx-10.9-x86_64-3.8/_cares.c' creating build/temp.macosx-10.9-x86_64-3.8 building '_cares' extension creating build/temp.macosx-10.9-x86_64-3.8/build creating build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8 creating build/temp.macosx-10.9-x86_64-3.8/deps creating build/temp.macosx-10.9-x86_64-3.8/deps/c-ares creating build/temp.macosx-10.9-x86_64-3.8/deps/c-ares/src gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ryan/miniforge3/envs/ft/include -arch x86_64 -I/Users/ryan/miniforge3/envs/ft/include -arch x86_64 -DHAVE_CONFIG_H=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D_DARWIN_USE_64_BIT_INODE=1 -I/Users/ryan/miniforge3/envs/ft/include/python3.8 -Ideps/c-ares/src -Ideps/c-ares/src/config_darwin -c build/temp.macosx-10.9-x86_64-3.8/_cares.c -o build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8/_cares.o build/temp.macosx-10.9-x86_64-3.8/_cares.c:2682:55: error: too many arguments to function call, expected 6, have 7 return ares_parse_ptr_reply(x0, x1, x2, x3, x4, x5, x6);


    /Users/ryan/miniforge3/envs/ft/include/ares.h:653:14: note: 'ares_parse_ptr_reply' declared here
    CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
                 ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:2760:59: error: too many arguments to function call, expected 6, have 7
      { result = ares_parse_ptr_reply(x0, x1, x2, x3, x4, x5, x6); }
                 ~~~~~~~~~~~~~~~~~~~~                         ^~
    /Users/ryan/miniforge3/envs/ft/include/ares.h:653:14: note: 'ares_parse_ptr_reply' declared here
    CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
                 ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4403:14: error: no member named 'ttl' in 'struct ares_mx_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_mx_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4419:14: error: no member named 'ttl' in 'struct ares_naptr_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_naptr_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4459:14: error: no member named 'ttl' in 'struct ares_soa_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_soa_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4473:14: error: no member named 'ttl' in 'struct ares_srv_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_srv_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4486:14: error: no member named 'ttl' in 'struct ares_txt_ext'
      (void)((p->ttl) | 0);  /* check that 'struct ares_txt_ext.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4498:14: error: no member named 'ttl' in 'struct ares_txt_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_txt_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4757:12: error: no member named 'ttl' in 'ares_mx_reply'
      { "ttl", offsetof(struct ares_mx_reply, ttl),
               ^                              ~~~
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4758:48: error: no member named 'ttl' in 'struct ares_mx_reply'
               sizeof(((struct ares_mx_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4781:12: error: no member named 'ttl' in 'ares_naptr_reply'
      { "ttl", offsetof(struct ares_naptr_reply, ttl),
               ^                                 ~~~
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4782:51: error: no member named 'ttl' in 'struct ares_naptr_reply'
               sizeof(((struct ares_naptr_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4853:12: error: no member named 'ttl' in 'ares_soa_reply'
      { "ttl", offsetof(struct ares_soa_reply, ttl),
               ^                               ~~~
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4854:49: error: no member named 'ttl' in 'struct ares_soa_reply'
               sizeof(((struct ares_soa_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4871:12: error: no member named 'ttl' in 'ares_srv_reply'
      { "ttl", offsetof(struct ares_srv_reply, ttl),
               ^                               ~~~
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4872:49: error: no member named 'ttl' in 'struct ares_srv_reply'
               sizeof(((struct ares_srv_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4886:12: error: no member named 'ttl' in 'ares_txt_ext'
      { "ttl", offsetof(struct ares_txt_ext, ttl),
               ^                             ~~~
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4887:47: error: no member named 'ttl' in 'struct ares_txt_ext'
               sizeof(((struct ares_txt_ext *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4898:12: error: no member named 'ttl' in 'ares_txt_reply'
      { "ttl", offsetof(struct ares_txt_reply, ttl),
               ^                               ~~~
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/ryan/miniforge3/envs/ft/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-1nnuf10i/pycares_9779f70fc2de401684607222c93c0ad1/setup.py'"'"'; __file__='"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-1nnuf10i/pycares_9779f70fc2de401684607222c93c0ad1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-record-zjqxxs6d/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ryan/miniforge3/envs/ft/include/python3.8/pycares Check the logs for full command output.
`
ognacy commented 3 years ago

Have the same issue.

The only workaround I found was downgrading from python 3.9 to 3.8.7.

kartzke commented 3 years ago

Intersting. I set up a new conda environement with Python 3.8.6. I'm trying to pip install ccxt, of which pycares is a dependency, and it still fails. Error is pasted below. And trying pip install pycares still fails.

`pip install ccxt Collecting ccxt Downloading ccxt-1.39.61-py2.py3-none-any.whl (2.0 MB) |████████████████████████████████| 2.0 MB 1.3 MB/s Requirement already satisfied: yarl==1.1.0 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from ccxt) (1.1.0) Requirement already satisfied: requests>=2.18.4 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from ccxt) (2.25.0) Requirement already satisfied: cryptography>=2.6.1 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from ccxt) (3.2.1) Requirement already satisfied: setuptools>=38.5.1 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from ccxt) (51.0.0) Requirement already satisfied: certifi>=2018.1.18 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from ccxt) (2020.12.5) Requirement already satisfied: multidict>=4.0 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from yarl==1.1.0->ccxt) (5.1.0) Requirement already satisfied: idna>=2.0 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from yarl==1.1.0->ccxt) (2.10) Collecting aiodns<2.1,>=1.1.1 Using cached aiodns-2.0.0-py2.py3-none-any.whl (4.8 kB) Collecting aiohttp<3.8,>=3.7.2 Using cached aiohttp-3.7.3.tar.gz (1.1 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... done Requirement already satisfied: attrs>=17.3.0 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from aiohttp<3.8,>=3.7.2->ccxt) (20.3.0) Requirement already satisfied: chardet<4.0,>=2.0 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from aiohttp<3.8,>=3.7.2->ccxt) (3.0.4) Requirement already satisfied: typing-extensions>=3.6.5 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from aiohttp<3.8,>=3.7.2->ccxt) (3.7.4.3) Collecting async-timeout<4.0,>=3.0 Using cached async_timeout-3.0.1-py3-none-any.whl (8.2 kB) Requirement already satisfied: six>=1.4.1 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from cryptography>=2.6.1->ccxt) (1.15.0) Requirement already satisfied: cffi!=1.11.3,>=1.8 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from cryptography>=2.6.1->ccxt) (1.14.4) Requirement already satisfied: pycparser in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.6.1->ccxt) (2.20) Collecting pycares>=3.0.0 Using cached pycares-3.1.1.tar.gz (233 kB) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/ryan/miniforge3/envs/ft/lib/python3.8/site-packages (from requests>=2.18.4->ccxt) (1.25.11) Building wheels for collected packages: aiohttp, pycares Building wheel for aiohttp (PEP 517) ... done Created wheel for aiohttp: filename=aiohttp-3.7.3-cp38-cp38-macosx_10_9_x86_64.whl size=649022 sha256=ae97ab3d05ad949bb031d5fd00d3669b1dbb4639f2540f735413311955dc326a Stored in directory: /Users/ryan/Library/Caches/pip/wheels/ec/4c/b4/49b28ff87279c75374ed0b9bc590808ebc5859bbca0adc641c Building wheel for pycares (setup.py) ... error ERROR: Command errored out with exit status 1: command: /Users/ryan/miniforge3/envs/ft/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/setup.py'"'"'; file='"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-wheel-kt6ljdhk cwd: /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/ Complete output (105 lines): running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.8 creating build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/errno.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/_version.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/init.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/utils.py -> build/lib.macosx-10.9-x86_64-3.8/pycares copying src/pycares/main.py -> build/lib.macosx-10.9-x86_64-3.8/pycares running build_ext generating cffi module 'build/temp.macosx-10.9-x86_64-3.8/_cares.c' creating build/temp.macosx-10.9-x86_64-3.8 building '_cares' extension creating build/temp.macosx-10.9-x86_64-3.8/build creating build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8 creating build/temp.macosx-10.9-x86_64-3.8/deps creating build/temp.macosx-10.9-x86_64-3.8/deps/c-ares creating build/temp.macosx-10.9-x86_64-3.8/deps/c-ares/src gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ryan/miniforge3/envs/ft/include -arch x86_64 -I/Users/ryan/miniforge3/envs/ft/include -arch x86_64 -DHAVE_CONFIG_H=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D_DARWIN_USE_64_BIT_INODE=1 -I/Users/ryan/miniforge3/envs/ft/include/python3.8 -Ideps/c-ares/src -Ideps/c-ares/src/config_darwin -c build/temp.macosx-10.9-x86_64-3.8/_cares.c -o build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8/_cares.o build/temp.macosx-10.9-x86_64-3.8/_cares.c:2682:55: error: too many arguments to function call, expected 6, have 7 return ares_parse_ptr_reply(x0, x1, x2, x3, x4, x5, x6);


  /Users/ryan/miniforge3/envs/ft/include/ares.h:653:14: note: 'ares_parse_ptr_reply' declared here
  CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
               ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:2760:59: error: too many arguments to function call, expected 6, have 7
    { result = ares_parse_ptr_reply(x0, x1, x2, x3, x4, x5, x6); }
               ~~~~~~~~~~~~~~~~~~~~                         ^~
  /Users/ryan/miniforge3/envs/ft/include/ares.h:653:14: note: 'ares_parse_ptr_reply' declared here
  CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
               ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4403:14: error: no member named 'ttl' in 'struct ares_mx_reply'
    (void)((p->ttl) | 0);  /* check that 'struct ares_mx_reply.ttl' is an integer */
            ~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4419:14: error: no member named 'ttl' in 'struct ares_naptr_reply'
    (void)((p->ttl) | 0);  /* check that 'struct ares_naptr_reply.ttl' is an integer */
            ~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4459:14: error: no member named 'ttl' in 'struct ares_soa_reply'
    (void)((p->ttl) | 0);  /* check that 'struct ares_soa_reply.ttl' is an integer */
            ~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4473:14: error: no member named 'ttl' in 'struct ares_srv_reply'
    (void)((p->ttl) | 0);  /* check that 'struct ares_srv_reply.ttl' is an integer */
            ~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4486:14: error: no member named 'ttl' in 'struct ares_txt_ext'
    (void)((p->ttl) | 0);  /* check that 'struct ares_txt_ext.ttl' is an integer */
            ~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4498:14: error: no member named 'ttl' in 'struct ares_txt_reply'
    (void)((p->ttl) | 0);  /* check that 'struct ares_txt_reply.ttl' is an integer */
            ~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4757:12: error: no member named 'ttl' in 'ares_mx_reply'
    { "ttl", offsetof(struct ares_mx_reply, ttl),
             ^                              ~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
  #define offsetof(t, d) __builtin_offsetof(t, d)
                         ^                     ~
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4758:48: error: no member named 'ttl' in 'struct ares_mx_reply'
             sizeof(((struct ares_mx_reply *)0)->ttl),
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4781:12: error: no member named 'ttl' in 'ares_naptr_reply'
    { "ttl", offsetof(struct ares_naptr_reply, ttl),
             ^                                 ~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
  #define offsetof(t, d) __builtin_offsetof(t, d)
                         ^                     ~
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4782:51: error: no member named 'ttl' in 'struct ares_naptr_reply'
             sizeof(((struct ares_naptr_reply *)0)->ttl),
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4853:12: error: no member named 'ttl' in 'ares_soa_reply'
    { "ttl", offsetof(struct ares_soa_reply, ttl),
             ^                               ~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
  #define offsetof(t, d) __builtin_offsetof(t, d)
                         ^                     ~
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4854:49: error: no member named 'ttl' in 'struct ares_soa_reply'
             sizeof(((struct ares_soa_reply *)0)->ttl),
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4871:12: error: no member named 'ttl' in 'ares_srv_reply'
    { "ttl", offsetof(struct ares_srv_reply, ttl),
             ^                               ~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
  #define offsetof(t, d) __builtin_offsetof(t, d)
                         ^                     ~
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4872:49: error: no member named 'ttl' in 'struct ares_srv_reply'
             sizeof(((struct ares_srv_reply *)0)->ttl),
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4886:12: error: no member named 'ttl' in 'ares_txt_ext'
    { "ttl", offsetof(struct ares_txt_ext, ttl),
             ^                             ~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
  #define offsetof(t, d) __builtin_offsetof(t, d)
                         ^                     ~
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4887:47: error: no member named 'ttl' in 'struct ares_txt_ext'
             sizeof(((struct ares_txt_ext *)0)->ttl),
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
  build/temp.macosx-10.9-x86_64-3.8/_cares.c:4898:12: error: no member named 'ttl' in 'ares_txt_reply'
    { "ttl", offsetof(struct ares_txt_reply, ttl),
             ^                               ~~~
  /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
  #define offsetof(t, d) __builtin_offsetof(t, d)
                         ^                     ~
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pycares
  Running setup.py clean for pycares
Successfully built aiohttp
Failed to build pycares
Installing collected packages: pycares, async-timeout, aiohttp, aiodns, ccxt
    Running setup.py install for pycares ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/ryan/miniforge3/envs/ft/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/setup.py'"'"'; __file__='"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-record-5fnj4vnx/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ryan/miniforge3/envs/ft/include/python3.8/pycares
         cwd: /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/
    Complete output (105 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.8
    creating build/lib.macosx-10.9-x86_64-3.8/pycares
    copying src/pycares/errno.py -> build/lib.macosx-10.9-x86_64-3.8/pycares
    copying src/pycares/_version.py -> build/lib.macosx-10.9-x86_64-3.8/pycares
    copying src/pycares/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pycares
    copying src/pycares/utils.py -> build/lib.macosx-10.9-x86_64-3.8/pycares
    copying src/pycares/__main__.py -> build/lib.macosx-10.9-x86_64-3.8/pycares
    running build_ext
    generating cffi module 'build/temp.macosx-10.9-x86_64-3.8/_cares.c'
    creating build/temp.macosx-10.9-x86_64-3.8
    building '_cares' extension
    creating build/temp.macosx-10.9-x86_64-3.8/build
    creating build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/deps
    creating build/temp.macosx-10.9-x86_64-3.8/deps/c-ares
    creating build/temp.macosx-10.9-x86_64-3.8/deps/c-ares/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/ryan/miniforge3/envs/ft/include -arch x86_64 -I/Users/ryan/miniforge3/envs/ft/include -arch x86_64 -DHAVE_CONFIG_H=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D_DARWIN_USE_64_BIT_INODE=1 -I/Users/ryan/miniforge3/envs/ft/include/python3.8 -Ideps/c-ares/src -Ideps/c-ares/src/config_darwin -c build/temp.macosx-10.9-x86_64-3.8/_cares.c -o build/temp.macosx-10.9-x86_64-3.8/build/temp.macosx-10.9-x86_64-3.8/_cares.o
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:2682:55: error: too many arguments to function call, expected 6, have 7
      return ares_parse_ptr_reply(x0, x1, x2, x3, x4, x5, x6);
             ~~~~~~~~~~~~~~~~~~~~                         ^~
    /Users/ryan/miniforge3/envs/ft/include/ares.h:653:14: note: 'ares_parse_ptr_reply' declared here
    CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
                 ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:2760:59: error: too many arguments to function call, expected 6, have 7
      { result = ares_parse_ptr_reply(x0, x1, x2, x3, x4, x5, x6); }
                 ~~~~~~~~~~~~~~~~~~~~                         ^~
    /Users/ryan/miniforge3/envs/ft/include/ares.h:653:14: note: 'ares_parse_ptr_reply' declared here
    CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
                 ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4403:14: error: no member named 'ttl' in 'struct ares_mx_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_mx_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4419:14: error: no member named 'ttl' in 'struct ares_naptr_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_naptr_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4459:14: error: no member named 'ttl' in 'struct ares_soa_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_soa_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4473:14: error: no member named 'ttl' in 'struct ares_srv_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_srv_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4486:14: error: no member named 'ttl' in 'struct ares_txt_ext'
      (void)((p->ttl) | 0);  /* check that 'struct ares_txt_ext.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4498:14: error: no member named 'ttl' in 'struct ares_txt_reply'
      (void)((p->ttl) | 0);  /* check that 'struct ares_txt_reply.ttl' is an integer */
              ~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4757:12: error: no member named 'ttl' in 'ares_mx_reply'
      { "ttl", offsetof(struct ares_mx_reply, ttl),
               ^                              ~~~
    /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4758:48: error: no member named 'ttl' in 'struct ares_mx_reply'
               sizeof(((struct ares_mx_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4781:12: error: no member named 'ttl' in 'ares_naptr_reply'
      { "ttl", offsetof(struct ares_naptr_reply, ttl),
               ^                                 ~~~
    /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4782:51: error: no member named 'ttl' in 'struct ares_naptr_reply'
               sizeof(((struct ares_naptr_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4853:12: error: no member named 'ttl' in 'ares_soa_reply'
      { "ttl", offsetof(struct ares_soa_reply, ttl),
               ^                               ~~~
    /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4854:49: error: no member named 'ttl' in 'struct ares_soa_reply'
               sizeof(((struct ares_soa_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4871:12: error: no member named 'ttl' in 'ares_srv_reply'
      { "ttl", offsetof(struct ares_srv_reply, ttl),
               ^                               ~~~
    /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4872:49: error: no member named 'ttl' in 'struct ares_srv_reply'
               sizeof(((struct ares_srv_reply *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4886:12: error: no member named 'ttl' in 'ares_txt_ext'
      { "ttl", offsetof(struct ares_txt_ext, ttl),
               ^                             ~~~
    /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4887:47: error: no member named 'ttl' in 'struct ares_txt_ext'
               sizeof(((struct ares_txt_ext *)0)->ttl),
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
    build/temp.macosx-10.9-x86_64-3.8/_cares.c:4898:12: error: no member named 'ttl' in 'ares_txt_reply'
      { "ttl", offsetof(struct ares_txt_reply, ttl),
               ^                               ~~~
    /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24: note: expanded from macro 'offsetof'
    #define offsetof(t, d) __builtin_offsetof(t, d)
                           ^                     ~
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/ryan/miniforge3/envs/ft/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/setup.py'"'"'; __file__='"'"'/private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-install-zmxgd_nz/pycares_d72dd4bc9a4242f3b67778793e0a078c/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/6g/73g1_dms191f5pj1mc5n8byh0000gn/T/pip-record-5fnj4vnx/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ryan/miniforge3/envs/ft/include/python3.8/pycares Check the logs for full command output.`
ognacy commented 3 years ago

For me, it was failing nearly exactly like that for 3.9. After switching to 3.8.7 it didn't need to compile anything and it just worked.

kartzke commented 3 years ago

Cool, I'll try another environment with 3.8.7. Maybe something got fixed under that version bump. Are you installing natively, or under Rosetta 2?

ognacy commented 3 years ago

I am running under Rosetta 2.

stoklund commented 3 years ago

FWIW, I'm seeing the same error on an Intel Mac running Big Sur:

(venv) ~ % sw_vers
ProductName:    macOS
ProductVersion: 11.1
BuildVersion:   20C69
(venv) ~ % clang -v
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin20.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
(venv) ~ % pip list
Package    Version
---------- -------
cffi       1.14.4
pip        20.3.3
pycparser  2.20
setuptools 51.1.0
wheel      0.36.2
(venv) ~ % pip install pycares
Collecting pycares
  Using cached pycares-3.1.1.tar.gz (233 kB)
...
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DHAVE_CONFIG_H=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D_DARWIN_USE_64_BIT_INODE=1 -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users/jolesen/venv/include -I/usr/local/Cellar/python@3.9/3.9.1_2/Frameworks/Python.framework/Versions/3.9/include/python3.9 -Ideps/c-ares/src -Ideps/c-ares/src/config_darwin -c build/temp.macosx-11-x86_64-3.9/_cares.c -o build/temp.macosx-11-x86_64-3.9/build/temp.macosx-11-x86_64-3.9/_cares.o
  build/temp.macosx-11-x86_64-3.9/_cares.c:2682:55: error: too many arguments to function call, expected 6, have 7
    return ares_parse_ptr_reply(x0, x1, x2, x3, x4, x5, x6);
           ~~~~~~~~~~~~~~~~~~~~                         ^~
kartzke commented 3 years ago

Seems like PyCares can't build on Python 3.9. Following @ognacy advice, I was able to successfully build it on Python 3.8.7 using Rosetta2 on my M1 with Big Sur, but it should work the same on Intel macs. Try downgrading your python.

qosmio commented 3 years ago

Same issue I was having. Looks like it was a conflict with c-ares installed by brew.

brew uninstall c-ares unbound nghttp2 gnutls (those are all the dependents of c-ares I had on my install)

If something breaks I'll just reinstall them. But for now everything works.

ppkantorski commented 3 years ago

Thanks qosmio, that seems to have done the trick for me. I stuck with Python 3.8 for this reason, now it seems i can use 3.9

GalphaXie commented 3 years ago

Same issue I was having. Looks like it was a conflict with c-ares installed by brew.

brew uninstall c-ares unbound nghttp2 gnutls (those are all the dependents of c-ares I had on my install)

If something breaks I'll just reinstall them. But for now everything works.

Thanks @qosmio , I just used brew uninstall --ignore-dependencies c-ares solved it temporarily.

But, I don't know why...

Anyone has ideas? Thx a lot!

iamredbar commented 3 years ago

Thanks @qosmio , I just used brew uninstall --ignore-dependencies c-ares solved it temporarily.

But, I don't know why...

Anyone has ideas? Thx a lot!

This was also the resolution that worked for me. The only difference is that I am running Catalina 10.15.7.

Edit: this broke my npm install