In High Sierra (macOS 10.13), I am unable to use Toga or Toga-demo due to a TypeError
. I was able to duplicate this on a fresh install of High Sierra in a VM; when I installed Toga and Toga-demo on a fresh install of Sierra (10.12), Toga and Toga-demo worked with no issues.
This has similar symptoms as issue https://github.com/pybee/toga/issues/154, but downgrading Rubicon has not solved the problem.
Details
Python Installation
$ uname -a
Darwin Andrews-Mac.local 17.0.0 Darwin Kernel Version 17.0.0: Thu Aug 24 21:48:19 PDT 2017; root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64
$
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin17.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$
$ CFLAGS="-I$(brew --prefix openssl)/include -O3" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install -v 3.6.3
...
Installed Python-3.6.3 to /Users/ame/.pyenv/versions/3.6.3
$
$ pyenv shell 3.6.3
$
$ python -V -V
Python 3.6.3 (default, Oct 9 2017, 17:43:29)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]
Virtualenv
$ python -m venv .venv
$
$ source .venv/bin/activate
$
$ pip install toga toga-demo
Collecting toga
Downloading toga-0.2.15-py3-none-any.whl
Collecting toga-demo
Downloading toga_demo-0.2.15-py3-none-any.whl
Collecting toga-cocoa; sys_platform == "darwin" (from toga)
Downloading toga_cocoa-0.2.15-py3-none-any.whl
Collecting toga-core>=0.2.15 (from toga-cocoa; sys_platform == "darwin"->toga)
Downloading toga_core-0.2.15-py3-none-any.whl (413kB)
100% |████████████████████████████████| 419kB 2.6MB/s
Collecting rubicon-objc>=0.2.8 (from toga-cocoa; sys_platform == "darwin"->toga)
Downloading rubicon_objc-0.2.8-py3-none-any.whl
Collecting colosseum>=0.1.6 (from toga-core>=0.2.15->toga-cocoa; sys_platform == "darwin"->toga)
Downloading colosseum-0.1.6-py3-none-any.whl
Installing collected packages: colosseum, toga-core, rubicon-objc, toga-cocoa, toga, toga-demo
Successfully installed colosseum-0.1.6 rubicon-objc-0.2.8 toga-0.2.15 toga-cocoa-0.2.15 toga-core-0.2.15 toga-demo-0.2.15
First Attempt
$ toga-demo
Traceback (most recent call last):
File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 11, in <module>
sys.exit(run())
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 5, in run
main().main_loop()
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 167, in main_loop
self._startup()
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 95, in _startup
self._impl = NSApplication.sharedApplication()
TypeError: 'ObjCInstance' object is not callable
$
$ python
Python 3.6.3 (default, Oct 9 2017, 17:43:29)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from rubicon.objc import *
>>> NSBundle = ObjCClass('NSBundle')
>>> NSBundle.mainBundle()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'ObjCInstance' object is not callable
>>> exit()
Downgrade Rubicon
Rubicon-objc==0.2.7
$ pip install rubicon-objc==0.2.7
Collecting rubicon-objc==0.2.7
Downloading rubicon_objc-0.2.7-py3-none-any.whl
Installing collected packages: rubicon-objc
Found existing installation: rubicon-objc 0.2.8
Uninstalling rubicon-objc-0.2.8:
Successfully uninstalled rubicon-objc-0.2.8
Successfully installed rubicon-objc-0.2.7
$
$ toga-demo
Traceback (most recent call last):
File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 11, in <module>
sys.exit(run())
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 5, in run
main().main_loop()
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 167, in main_loop
self._startup()
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 95, in _startup
self._impl = NSApplication.sharedApplication()
TypeError: 'ObjCInstance' object is not callable
Rubicon-objc==0.2.6
$ pip install rubicon-objc==0.2.6
Collecting rubicon-objc==0.2.6
Downloading rubicon_objc-0.2.6-py3-none-any.whl
Installing collected packages: rubicon-objc
Found existing installation: rubicon-objc 0.2.7
Uninstalling rubicon-objc-0.2.7:
Successfully uninstalled rubicon-objc-0.2.7
Successfully installed rubicon-objc-0.2.6
$
$ toga-demo
Traceback (most recent call last):
File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 7, in <module>
from toga_demo.__main__ import run
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 2, in <module>
from toga_demo.app import main
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/app.py", line 4, in <module>
import toga
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 114, in <module>
set_platform()
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 86, in set_platform
local_vars['platform'] = importlib.import_module(module_name)
File "/Users/ame/.pyenv/versions/3.6.3/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/__init__.py", line 2, in <module>
from .app import *
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 8, in <module>
from .command import Command, Group
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/command.py", line 3, in <module>
from .widgets.icon import Icon
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/widgets/icon.py", line 4, in <module>
from ..libs import NSImage
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/__init__.py", line 1, in <module>
from .appkit import *
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/appkit.py", line 232, in <module>
NSColor.declare_class_property('alternateSelectedControlColor')
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/rubicon/objc/objc.py", line 1300, in __getattr__
raise AttributeError('%s.%s %s has no attribute %s' % (type(self).__module__, type(self).__qualname__, self.objc_class.name, name))
AttributeError: rubicon.objc.objc.ObjCClass NSColor has no attribute declare_class_property
Rubicon-objc==0.2.4
$ pip install rubicon-objc==0.2.4
Collecting rubicon-objc==0.2.4
Downloading rubicon_objc-0.2.4-py3-none-any.whl
Installing collected packages: rubicon-objc
Found existing installation: rubicon-objc 0.2.6
Uninstalling rubicon-objc-0.2.6:
Successfully uninstalled rubicon-objc-0.2.6
Successfully installed rubicon-objc-0.2.4
$
$ toga-demo
Traceback (most recent call last):
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/rubicon/objc/objc.py", line 1274, in __getattr__
return self.__dict__[name]
KeyError: 'declare_class_property'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ame/workspace/org.elgert/toga/.venv/bin/toga-demo", line 7, in <module>
from toga_demo.__main__ import run
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/__main__.py", line 2, in <module>
from toga_demo.app import main
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_demo/app.py", line 4, in <module>
import toga
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 114, in <module>
set_platform()
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga/__init__.py", line 86, in set_platform
local_vars['platform'] = importlib.import_module(module_name)
File "/Users/ame/.pyenv/versions/3.6.3/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/__init__.py", line 2, in <module>
from .app import *
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/app.py", line 8, in <module>
from .command import Command, Group
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/command.py", line 3, in <module>
from .widgets.icon import Icon
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/widgets/icon.py", line 4, in <module>
from ..libs import NSImage
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/__init__.py", line 1, in <module>
from .appkit import *
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/toga_cocoa/libs/appkit.py", line 232, in <module>
NSColor.declare_class_property('alternateSelectedControlColor')
File "/Users/ame/workspace/org.elgert/toga/.venv/lib/python3.6/site-packages/rubicon/objc/objc.py", line 1277, in __getattr__
raise AttributeError('ObjCClass %s has no attribute %s' % (self.name, name))
AttributeError: ObjCClass NSColor has no attribute declare_class_property