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

[Bug] ctypes: AttributeError: module 'collections' has no attribute 'Callable' (GRASS GIS 7.8.5) #1671

Closed
neteler opened this issue Jun 21, 2021 · 2 comments · Fixed by #1672
Labels
bug Something isn't working
Milestone

Comments

@neteler
Copy link
Member

neteler commented Jun 21, 2021

Describe the bug
A clear and concise description of what the bug is.

While trying to address the current Fedora packaging issue (https://bugzilla.redhat.com/show_bug.cgi?id=1973621) I identified the following problem:

With Python 3.10 the ctypes compilation fails:

GISRC=/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/demolocation/.grassrc78 GISBASE=/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu PATH="/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/bin:/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/bin:/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/scripts:$PATH" PYTHONPATH="/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/etc/python:/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/gui/wxpython:$PYTHONPATH" LD_LIBRARY_PATH="/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/bin:/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/bin:/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/scripts:/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/lib:/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/lib:" LC_ALL=C LANG=C LANGUAGE=C ./ctypesgen.py --cpp "gcc -E   ""     -I/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/include -I/builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/include -D__GLIBC_HAVE_LONG_LONG" -lgrass_imagery.7.8   /builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/include/grass/imagery.h /builddir/build/BUILD/grass-7.8.5/dist.x86_64-redhat-linux-gnu/include/grass/defs/imagery.h -o OBJ.x86_64-redhat-linux-gnu/imagery.py
Traceback (most recent call last):
Traceback (most recent call last):
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/./ctypesgen.py", line 162, in <module>
    descriptions = ctypesgencore.parser.parse(options.headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/__init__.py", line 21, in parse
    parser = DataCollectingParser(headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/datacollectingparser.py", line 31, in __init__
    ctypesparser.CtypesParser.__init__(self, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/ctypesparser.py", line 63, in __init__
    super(CtypesParser, self).__init__(options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/cparser.py", line 90, in __init__
    self.preprocessor_parser = preprocessor.PreprocessorParser(options, self)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 137, in __init__
    self.lexer = lex.lex(cls=PreprocessorLexer,
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/lex.py", line 723, in lex
    if isinstance(t, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/./ctypesgen.py", line 162, in <module>
    descriptions = ctypesgencore.parser.parse(options.headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/__init__.py", line 21, in parse
    parser = DataCollectingParser(headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/datacollectingparser.py", line 31, in __init__
    ctypesparser.CtypesParser.__init__(self, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/ctypesparser.py", line 63, in __init__
    super(CtypesParser, self).__init__(options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/cparser.py", line 90, in __init__
    self.preprocessor_parser = preprocessor.PreprocessorParser(options, self)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 137, in __init__
    self.lexer = lex.lex(cls=PreprocessorLexer,
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/lex.py", line 723, in lex
    if isinstance(t, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
Traceback (most recent call last):
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/./ctypesgen.py", line 162, in <module>
    descriptions = ctypesgencore.parser.parse(options.headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/__init__.py", line 21, in parse
    parser = DataCollectingParser(headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/datacollectingparser.py", line 31, in __init__
    ctypesparser.CtypesParser.__init__(self, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/ctypesparser.py", line 63, in __init__
    super(CtypesParser, self).__init__(options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/cparser.py", line 90, in __init__
    self.preprocessor_parser = preprocessor.PreprocessorParser(options, self)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 137, in __init__
    self.lexer = lex.lex(cls=PreprocessorLexer,
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/lex.py", line 723, in lex
    if isinstance(t, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
Traceback (most recent call last):
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/./ctypesgen.py", line 162, in <module>
    descriptions = ctypesgencore.parser.parse(options.headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/__init__.py", line 21, in parse
    parser = DataCollectingParser(headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/datacollectingparser.py", line 31, in __init__
    ctypesparser.CtypesParser.__init__(self, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/ctypesparser.py", line 63, in __init__
make[6]: *** [Makefile:107: OBJ.x86_64-redhat-linux-gnu/gmath.py] Error 1
make[6]: *** Waiting for unfinished jobs....
    super(CtypesParser, self).__init__(options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/cparser.py", line 90, in __init__
    self.preprocessor_parser = preprocessor.PreprocessorParser(options, self)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 137, in __init__
Traceback (most recent call last):
    self.lexer = lex.lex(cls=PreprocessorLexer,
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/lex.py", line 723, in lex
    if isinstance(t, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/./ctypesgen.py", line 162, in <module>
    descriptions = ctypesgencore.parser.parse(options.headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/__init__.py", line 21, in parse
make[6]: *** [Makefile:107: OBJ.x86_64-redhat-linux-gnu/proj.py] Error 1
    parser = DataCollectingParser(headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/datacollectingparser.py", line 31, in __init__
    ctypesparser.CtypesParser.__init__(self, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/ctypesparser.py", line 63, in __init__
    super(CtypesParser, self).__init__(options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/cparser.py", line 90, in __init__
    self.preprocessor_parser = preprocessor.PreprocessorParser(options, self)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 137, in __init__
    self.lexer = lex.lex(cls=PreprocessorLexer,
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/lex.py", line 723, in lex
    if isinstance(t, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
make[6]: *** [Makefile:107: OBJ.x86_64-redhat-linux-gnu/date.py] Error 1
make[6]: *** [Makefile:107: OBJ.x86_64-redhat-linux-gnu/gis.py] Error 1
make[6]: *** [Makefile:107: OBJ.x86_64-redhat-linux-gnu/raster.py] Error 1
Traceback (most recent call last):
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/./ctypesgen.py", line 162, in <module>
    descriptions = ctypesgencore.parser.parse(options.headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/__init__.py", line 21, in parse
    parser = DataCollectingParser(headers, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/datacollectingparser.py", line 31, in __init__
    ctypesparser.CtypesParser.__init__(self, options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/ctypesparser.py", line 63, in __init__
    super(CtypesParser, self).__init__(options)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/cparser.py", line 90, in __init__
    self.preprocessor_parser = preprocessor.PreprocessorParser(options, self)
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 137, in __init__
    self.lexer = lex.lex(cls=PreprocessorLexer,
  File "/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes/ctypesgencore/parser/lex.py", line 723, in lex
    if isinstance(t, collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'
make[6]: Leaving directory '/builddir/build/BUILD/grass-7.8.5/lib/python/ctypes'
make[6]: *** [Makefile:107: OBJ.x86_64-redhat-linux-gnu/imagery.py] Error 1
make[5]: *** [Makefile:86: default] Error 2

To Reproduce

The issue happens on the Fedora build system (likely on others as well once Python 3.10 is more widely in use):

System description (please complete the following information):

  • Operating System: Fedora 35
  • GRASS GIS version 7.8.5
  • python 3.10.0~b3-1.fc35

It would be ideal to get this fixed before the G 7.8.6 release.

@neteler neteler added the bug Something isn't working label Jun 21, 2021
@neteler neteler added this to the 7.8.6 milestone Jun 21, 2021
@petrasovaa
Copy link
Contributor

From python docs:

Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.9.

So Callable is now part of collections.abc, so replacing collections.Callable with collections.abc.Callable should work. Don't have time to test now.

@neteler
Copy link
Member Author

neteler commented Jun 21, 2021

Thanks for the hint, @petrasovaa - I'll patch locally, test it and report here (i.e. open a PR if all fine).

neteler added a commit that referenced this issue Jun 21, 2021
Callable is now part of collections.abc: replacing `collections.Callable` with `collections.abc.Callable`

Fixes #1671

Co-authored-by: @petrasovaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants