Decompiled APC40 remote script gives metaclass error

Discuss Live-ready controllers other than Push.
Post Reply
spinlud
Posts: 105
Joined: Sat May 26, 2012 9:27 am

Decompiled APC40 remote script gives metaclass error

Post by spinlud » Fri Aug 18, 2023 10:47 am

Hi, I am trying to edit the APC40 remote script. I have decompiled the native files using https://pypi.org/project/uncompyle6/ and placed all the generated python files in Macintosh HD/Users/[username]/Music/Ableton/User Library/APC40 as described here https://help.ableton.com/hc/en-us/artic ... te-scripts.

I have also removed the native remote script folder APC40 from /Applications/Ableton Live 11 Suite.app/Contents/App-Resources/MIDI Remote Scripts to avoid any collision.

I didn't make any change to the decompiled code, but when I start Ableton I can see in the log file (/Users/[username]/Library/Preferences/Ableton/Live 11.3.4/Log.txt) the following error:

Code: Select all

metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
The error is given at this line of code in the APC40.py file:

Code: Select all

from _Framework.ControlSurface import OptimizedControlSurface
import _APC.APC as APC

class APC40(APC, OptimizedControlSurface): # <------
    # ...
It seems the classes APC and OptimizedControlSurface have incompatible types.
I have also tried to combine them in a new class and use that as metaclass, but it didn't work:

Code: Select all

# Define a new metaclass that inherits from the metaclasses of both base classes
class CombinedMeta(type(APC), type(OptimizedControlSurface)):
    pass

class APC40(APC, OptimizedControlSurface, metaclass=CombinedMeta):
    # ...
Does anyone have any idea how to make this work?

Poison2212
Posts: 2
Joined: Mon Mar 31, 2025 11:09 pm

Re: Decompiled APC40 remote script gives metaclass error

Post by Poison2212 » Wed Apr 02, 2025 1:26 am

I know this is a late reply but try changing the line

Code: Select all

import _APC.APC as APC
to

Code: Select all

from _APC.APC import APC
This helped me with the same issue

sissySpacecraft
Posts: 16
Joined: Thu Sep 24, 2015 2:41 am

Re: Decompiled APC40 remote script gives metaclass error

Post by sissySpacecraft » Tue Apr 08, 2025 1:54 am

Did Poison2212's suggestion help you? It has been a while since I saw that error too, but this is why I remember stopping development in that direction completely... (Somebody please tell me my analysis is wrong. That was going to be a cool project.)

Inside the MRS - Midi Remote Scripts folder, the underlying folder structure (for these python files) looks like this:

Code: Select all

- _Framework
-- ControlSurface
- _APC
-- APC
- APC40
-- APC40
and the metaclass-conflict error "...must be a (non-strict) subclass of the metaclasses of all its bases" means in this case, the (non-strict subclass) class APC40 cannot derive from BOTH ControlSurface AND APC bases because those base classes don't themselves have a common metaclass "everybody" derives from (because import paths pointing to ControlSurface and APC are not the same path, the paths include different "underscore directories" (_Framework and _APC)).

In my experience, this kind of error started occurring when remote scripting moved from Python 2 to Python 3 with Live 11. (late Live 10). If you still have a copy of Live 9 (or Live 10 before version 10.1.25) installed, try directly replacing the default APC40 script with your custom APC40 script in the Live 9 (or 10) MRS folder. If my analysis has any validity, you should not see that same metaclass conflict error when Live 9 compiles your (unchanged) custom APC40 code under Python 2. (because that metaclass conflict error belongs to compiling (the same code) under Python 3.)

Post Reply