libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
404 stars 37 forks source link

tcod 12.7.2 fails to install on arch linux #110

Closed ryanfantus closed 2 years ago

ryanfantus commented 2 years ago

Hi, trying to install tcod on arch fails parsing code from the SDL_events.h header:

❯ pip3 install tcod
Defaulting to user installation because normal site-packages is not writeable
Collecting tcod
  Using cached tcod-12.7.2.tar.gz (745 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 /home/username/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpd4j4rj66                                             
         cwd: /tmp/pip-install-n0tlarbj/tcod_ac8ff95a88d44a9ab904bce49c11a2c2                               
    Complete output (89 lines):                                                                             
    Found SDL 2.0.16.                                                                                       
    Error parsing 'SDL_events.h' code:                                                                      
    typedef union SDL_Event                                                                                 
    {                                                                                                       
        Uint32 type;                                                                                        
        SDL_CommonEvent common;                                                                             
        SDL_DisplayEvent display;                                                                           
        SDL_WindowEvent window;                                                                             
        SDL_KeyboardEvent key;                                                                              
        SDL_TextEditingEvent edit;                                                                          
        SDL_TextInputEvent text;                                                                            
        SDL_MouseMotionEvent motion;                                                                        
        SDL_MouseButtonEvent button;                                                                        
        SDL_MouseWheelEvent wheel;                                                                          
        SDL_JoyAxisEvent jaxis;                                                                             
        SDL_JoyBallEvent jball;                                                                             
        SDL_JoyHatEvent jhat;                                                                               
        SDL_JoyButtonEvent jbutton;                                                                         
        SDL_JoyDeviceEvent jdevice;                                                                         
        SDL_ControllerAxisEvent caxis;                                                                      
        SDL_ControllerButtonEvent cbutton;                                                                  
        SDL_ControllerDeviceEvent cdevice;                                                                  
        SDL_ControllerTouchpadEvent ctouchpad;                                                              
        SDL_ControllerSensorEvent csensor;                                                                  
        SDL_AudioDeviceEvent adevice;                                                                       
        SDL_SensorEvent sensor;                                                                             
        SDL_QuitEvent quit;                                                                                 
        SDL_UserEvent user;                                                                                 
        SDL_SysWMEvent syswm;                                                                               
        SDL_TouchFingerEvent tfinger;                                                                       
        SDL_MultiGestureEvent mgesture;                                                                     
        SDL_DollarGestureEvent dgesture;                                                                    
        SDL_DropEvent drop;                                                                                 

        Uint8 padding[sizeof(void *) <= 8 ? 56 : sizeof(void *) == 16 ? 64 : 3 * sizeof(void *)];           
    } SDL_Event;                                                                                            
    Traceback (most recent call last):                                                                      
      File "/home/username/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>                                                                                          
        main()                                                                                              
      File "/home/username/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main                                                                                              
        json_out['return_val'] = hook(**hook_input['kwargs'])                                               
      File "/home/username/.local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 151, in prepare_metadata_for_build_wheel                                                                  
        return hook(metadata_directory, config_settings)                                                    
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 166, in prepare_metadata_for_build_wheel                                                                    
        self.run_setup()                                                                                    
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 150, in run_setup                                                                                           
        exec(compile(code, __file__, 'exec'), locals())                                                     
      File "setup.py", line 104, in <module>                                                                
        setup(                                                                                              
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup                                                                                                 
        return distutils.core.setup(**attrs)                                                                
      File "/usr/lib/python3.9/distutils/core.py", line 108, in setup                                       
        _setup_distribution = dist = klass(attrs)                                                           
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 455, in __init__                                                                                                  
        _Distribution.__init__(self, {                                                                      
      File "/usr/lib/python3.9/distutils/dist.py", line 292, in __init__                                    
        self.finalize_options()                                                                             
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 807, in finalize_options                                                                                          
        ep(self)                                                                                            
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 814, in _finalize_setup_keywords                                                                                  
        ep.load()(self, ep.name, value)                                                                     
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 219, in cffi_modules                                                                                          
        add_cffi_module(dist, cffi_module)                                                                  
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module                                                                                        
        execfile(build_file_name, mod_vars)                                                                 
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 25, in execfile                                                                                               
        exec(code, glob, glob)                                                                              
      File "build_libtcod.py", line 306, in <module>                                                        
        parse_sdl2.add_to_ffi(ffi, SDL2_INCLUDE)                                                            
      File "/tmp/pip-install-n0tlarbj/tcod_ac8ff95a88d44a9ab904bce49c11a2c2/parse_sdl2.py", line 152, in add_to_ffi                                                                                                     
        ffi.cdef(code, **cdef_args)                                                                         
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/api.py", line 112, in cdef 
        self._cdef(csource, override=override, packed=packed, pack=pack)                                    
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/api.py", line 126, in _cdef
        self._parser.parse(csource, override=override, **options)
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/cparser.py", line 389, in parse
        self._internal_parse(csource)
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/cparser.py", line 428, in _internal_parse
        realtype, quals = self._get_type_and_quals(
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/cparser.py", line 679, in _get_type_and_quals
        tp = self._get_struct_union_enum_type('union', type, name)
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/cparser.py", line 839, in _get_struct_union_enum_type
        type, fqual = self._get_type_and_quals(decl.type,
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/cparser.py", line 613, in _get_type_and_quals
        length = self._parse_constant(
      File "/tmp/pip-build-env-ip08x7xn/overlay/lib/python3.9/site-packages/cffi/cparser.py", line 940, in _parse_constant
        raise FFIError(":%d: unsupported expression: expected a "
    cffi.FFIError: :34: unsupported expression: expected a simple numeric constant
    ----------------------------------------
HexDecimal commented 2 years ago

What is your current version of cffi and pycparser? Check with pip3 list. Tell me this especially if the following works:

Try upgrading those two and try again: pip3 install -U cffi pycparser.

Maybe that padding value is new and I now have to work around that.

ryanfantus commented 2 years ago

Hey, thanks for the quick reply!

❯ pip3 list | grep cffi
cffi                 1.14.6

❯ pip3 list | grep pycparser                           
pycparser            2.20

❯ pip3 install -U cffi pycparser
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: cffi in /usr/lib/python3.9/site-packages (1.14.6)
Requirement already satisfied: pycparser in /usr/lib/python3.9/site-packages (2.20)

Same build error sadly, when trying to pip3 install tcod

HexDecimal commented 2 years ago

Then I assume the workaround will be to use an earlier version of SDL2's headers.

I'll try to get SDL 2.0.16 working now.

HexDecimal commented 2 years ago

I reproduced and fixed the errors. Python-tcod 12.7.3 should work unless I missed something.

ryanfantus commented 2 years ago

Confirmed fixed. Wow, thanks for the quick turnaround.