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

"TypeError: 'ObjCInstance' object is not callable" on macOS High Sierra #243

Closed
elgertam opened this issue Oct 10, 2017 · 23 comments
Closed

Comments

@elgertam
Copy link

elgertam commented Oct 10, 2017

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 #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
@freakboy3742
Copy link
Member

@elgertam Thanks for the report. As you've noted, this is almost certainly a manifestation of the same problem as #154, which was in turned caused by beeware/rubicon-objc#40.

The problem is caused by subtle changes that Cocoa introduces between versions. Quoting @dgelessus from the Rubicon ticket:

The issue is that Objective-C has two syntaxes (method calling with [object name], and property access with object.name), and rubicon-objc maps both of them to Python attribute access. When there's both a property and a method with the same name, rubicon-objc prefers the property. That means that if there's a method called name, and in a future version a property called name is added, the meaning of object.name in rubicon-objc suddenly changes. However in Objective-C that change doesn't affect existing programs, because the [object name] syntax still works, even if name is also a property.

When Sierra came out, NSBundle.mainBundle() and the NSColor predefined colors were modified into properties. This was fixed in 9faf763

In this case, it looks like High Sierra has turned NSApplication.sharedApplication() into a property. The fix will be exactly the same as it was for NSBundle.mainBundle - explicitly declare the NSApplication.sharedApplication class property, then change references to be attributes, not method calls.

@dgelessus
Copy link

I might have suggested this before - to prevent this issue from reappearing every time a new macOS version comes out, should we by default require calling all methods explicitly, even if they are declared as Objective-C properties? That way the behavior would be forward-compatible. The downside is that it would require a declare_property call for each method that should be usable as a property...

@freakboy3742
Copy link
Member

@dgelessus I can see what you're proposing, but IMHO the approach we've got here is more idiomatic - both in Python and objective C. Yes, it means some headaches every time a new macOS or iOS release comes out, but they're relatively easy bugs to fix, once they're identified.

@mischievous
Copy link

So locally I have fixed the NSApplication.sharedApplication() and NSWindow.mainWindow() issues. Not sure I corrected them in the correct place. Did a search and they were fixed in a test file in rubicon so I corrected them in toga/cocoa source tree.

Now I am getting this error.
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/toga-demo", line 9, in
load_entry_point('toga-demo==0.3.0.dev1', 'console_scripts', 'toga-demo')()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/toga_demo-0.3.0.dev1-py3.4.egg/toga_demo/main.py", line 5, in run
main().main_loop()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/toga_core-0.3.0.dev1-py3.4.egg/toga/app.py", line 147, in main_loop
self._impl.main_loop()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/toga_cocoa-0.3.0.dev1-py3.4.egg/toga_cocoa/app.py", line 158, in main_loop
self.create()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/toga_cocoa-0.3.0.dev1-py3.4.egg/toga_cocoa/app.py", line 107, in create
self.interface.startup()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/toga_demo-0.3.0.dev1-py3.4.egg/toga_demo/app.py", line 20, in startup
left_table.insert(None, 'root1', 'value1')

I have interrogated left_table, and indeed it does not have an "insert" method. So any suggestions?

@dgelessus
Copy link

dgelessus commented Oct 27, 2017

@mischievous This looks like an issue in Toga itself or the demo app, not in Rubicon. Can you open an issue for this on the Toga repo? Thanks!

Ignore my comment - this is the Toga issue section. I thought I was on the Rubicon repo, sorry.

@freakboy3742
Copy link
Member

This has been corrected with Rubicon 0.2.10.

@NewNork
Copy link

NewNork commented Dec 3, 2017

I'm afraid the problem persists even after upgrading to rubicon-objc 0.2.10

self._impl = NSApplication.sharedApplication()
TypeError: 'ObjCInstance' object is not callable

Python version Python 3.6.3 :: Anaconda custom (64-bit) on High Sierra.

I'm happy to provide more useful information if you point me in a direction

@dgelessus
Copy link

@NewNork It looks like you're using a Toga version that doesn't have the fix for High Sierra. The fix was added in c66745e, but as far as I can tell there hasn't yet been a Toga release that includes this fix. You can try installing Toga directly from the repo, using python3 -m pip install git+https://github.com/pybee/toga.git. That will include unreleased changes, such as the High Sierra fix.

@jfunez
Copy link

jfunez commented Dec 4, 2017

Hi @dgelessus

Just to confirm, I have the same error, then read all the comments, and update the toga package as you mention (python3 -m pip install git+https://github.com/pybee/toga.git), but the problem still happening in High Sierra :(

here is what I do:

created virtualenv:

$ mkvirtualenv toga-demo --python=`which python3`
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/juanfunez/Envs/toga-demo/bin/python3.6
Also creating executable in /Users/juanfunez/Envs/toga-demo/bin/python
Installing setuptools, pip, wheel...done.

installed toga for the first time:

$ pip install toga-demo
Collecting toga-demo
  Downloading toga_demo-0.2.15-py3-none-any.whl
Collecting toga==0.2.15 (from toga-demo)
  Downloading toga-0.2.15-py3-none-any.whl
Collecting toga-cocoa; sys_platform == "darwin" (from toga==0.2.15->toga-demo)
  Downloading toga_cocoa-0.2.15-py3-none-any.whl
Collecting rubicon-objc>=0.2.8 (from toga-cocoa; sys_platform == "darwin"->toga==0.2.15->toga-demo)
  Downloading rubicon_objc-0.2.10-py2.py3-none-any.whl (59kB)
    100% |████████████████████████████████| 61kB 416kB/s
Collecting toga-core>=0.2.15 (from toga-cocoa; sys_platform == "darwin"->toga==0.2.15->toga-demo)
  Downloading toga_core-0.2.15-py3-none-any.whl (413kB)
    100% |████████████████████████████████| 419kB 599kB/s
Collecting colosseum>=0.1.6 (from toga-core>=0.2.15->toga-cocoa; sys_platform == "darwin"->toga==0.2.15->toga-demo)
  Downloading colosseum-0.1.6-py3-none-any.whl
Installing collected packages: rubicon-objc, colosseum, toga-core, toga-cocoa, toga, toga-demo
Successfully installed colosseum-0.1.6 rubicon-objc-0.2.10 toga-0.2.15 toga-cocoa-0.2.15 toga-core-0.2.15 toga-demo-0.2.15

Run toga for the first time:

$ toga-demo
Traceback (most recent call last):
  File "/Users/juanfunez/Envs/toga-demo/bin/toga-demo", line 11, in <module>
    sys.exit(run())
  File "/Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages/toga_demo/__main__.py", line 5, in run
    main().main_loop()
  File "/Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages/toga_cocoa/app.py", line 167, in main_loop
    self._startup()
  File "/Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages/toga_cocoa/app.py", line 95, in _startup
    self._impl = NSApplication.sharedApplication()
TypeError: 'ObjCInstance' object is not callable

check the installed package's versions in venv:

$ pip freeze
colosseum==0.1.6
rubicon-objc==0.2.10
toga==0.2.15
toga-cocoa==0.2.15
toga-core==0.2.15
toga-demo==0.2.15

Here I saw your fix, and applied:

$ python -m pip install git+https://github.com/pybee/toga.git
Collecting git+https://github.com/pybee/toga.git
  Cloning https://github.com/pybee/toga.git to /private/var/folders/vk/01h678ys2b9gxc1dsp6cjdt40000gn/T/pip-6hw4q6b3-build
Requirement already satisfied: toga-cocoa in /Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages (from toga==0.3.0.dev1)
Requirement already satisfied: toga-core>=0.2.15 in /Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages (from toga-cocoa->toga==0.3.0.dev1)
Requirement already satisfied: rubicon-objc>=0.2.8 in /Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages (from toga-cocoa->toga==0.3.0.dev1)
Requirement already satisfied: colosseum>=0.1.6 in /Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages (from toga-core>=0.2.15->toga-cocoa->toga==0.3.0.dev1)
Installing collected packages: toga
  Found existing installation: toga 0.2.15
    Uninstalling toga-0.2.15:
      Successfully uninstalled toga-0.2.15
  Running setup.py install for toga ... done
Successfully installed toga-0.3.0.dev1

run again toga-demo:

$ toga-demo
Traceback (most recent call last):
  File "/Users/juanfunez/Envs/toga-demo/bin/toga-demo", line 11, in <module>
    sys.exit(run())
  File "/Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages/toga_demo/__main__.py", line 5, in run
    main().main_loop()
  File "/Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages/toga_cocoa/app.py", line 167, in main_loop
    self._startup()
  File "/Users/juanfunez/Envs/toga-demo/lib/python3.6/site-packages/toga_cocoa/app.py", line 95, in _startup
    self._impl = NSApplication.sharedApplication()
TypeError: 'ObjCInstance' object is not callable

here is the packages versions installed right now:

$ pip freeze
colosseum==0.1.6
rubicon-objc==0.2.10
toga==0.3.0.dev1
toga-cocoa==0.2.15
toga-core==0.2.15
toga-demo==0.2.15

I missed something?

HTH

@freakboy3742
Copy link
Member

@jfunez Unfortunately, the instructions @dgelessus gave won't work - the Toga repository contains a number of sub-packages, and there's no way to install the sub-packages directly from git. If you look at your pip freeze output, you've got an updated toga - but not toga-cocoa or toga-core, which is where the important bits are.

To install the development version of Toga, you need to run:

$ git clone https:///github.com/pybee/toga.git
$ cd toga
$ pip install src/core
$ pip install src/cocoa

@clokep
Copy link
Contributor

clokep commented Dec 4, 2017

You could install them both directly via pip:

pip install git+https://github.com/pybee/toga.git#egg=version_subpkg&subdirectory=src/core
pip install git+https://github.com/pybee/toga.git#egg=version_subpkg&subdirectory=src/cocoa

It probably makes more sense to clone it like @freakboy3742 said, however.

@jfunez
Copy link

jfunez commented Dec 4, 2017

Hi @freakboy3742 @clokep

I followed your instructions of @freakboy3742, but now I'm having this error when running the demo:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/juanfunez/Temp/toga-demo/toga/demo/toga_demo/__main__.py", line 8, in <module>
    run()
  File "/Users/juanfunez/Temp/toga-demo/toga/demo/toga_demo/__main__.py", line 5, in run
    main().main_loop()
  File "/Users/juanfunez/Temp/toga-demo/toga/src/core/toga/app.py", line 153, in main_loop
    self._impl.main_loop()
  File "/Users/juanfunez/Temp/toga-demo/toga/src/cocoa/toga_cocoa/app.py", line 160, in main_loop
    self.create()
  File "/Users/juanfunez/Temp/toga-demo/toga/src/cocoa/toga_cocoa/app.py", line 109, in create
    self.interface.startup()
  File "/Users/juanfunez/Temp/toga-demo/toga/demo/toga_demo/app.py", line 19, in startup
    left_table.insert(None, 'root1', 'value1')
AttributeError: 'Table' object has no attribute 'insert'

I also executed the test and everything is fine...
I'm a noob with Toga, so maybe I missing something basic, do I?

@NewNork
Copy link

NewNork commented Dec 4, 2017

@freakboy3742 Cheers mate. That worked. Hopefully they push the changes soon.

@freakboy3742
Copy link
Member

@jfunez As you might guess when you install a version of code direct from a Git repository, you're going to find bugs sometimes :-) We're in the middle of a huge refactor, and there are still bugs in some areas of the code (the toga-demo is just one example).

You will probably have more luck looking in the examples directory of the Toga repository - those examples are more likely to be up to date.

@jfunez
Copy link

jfunez commented Dec 5, 2017

Hi @freakboy3742
With the help of @Dayof I found a setup to get the examples working \o/
The working environment is:

$ pip freeze
colosseum==0.1.6
rubicon-objc==0.2.10
toga==0.2.15
toga-cocoa==0.3.0.dev1
toga-core==0.3.0.dev1

Thanks to everyone who helped me!

@gaslitbytech
Copy link

@jfunez How should I install cocoa==0.3.0.dev1 as I get the error

Could not find a version that satisfies the requirement toga-cocoa==0.3.0.dev1

@danyeaw
Copy link
Member

danyeaw commented Dec 10, 2017

@tourdownunder

  1. Clone toga
  2. Setup virtualenv like the instructions here https://pybee.org/contributing/how/first-time/setup/
  3. pip install -e src/core src/cocoa

@gaslitbytech
Copy link

gaslitbytech commented Dec 10, 2017

thanks. i worked out i could use

pip install git+https://github.com/pybee/toga.git#subdirectory:/tree/master/src/cocoa

though then i had another issue running the app. I might try with a new virtual machine or uninstalling the old version first.

@promentol
Copy link

I am trying
pip3 install git+https://github.com/pybee/toga.git#subdirectory:/tree/master/src/cocoa

but I am receiving the following error,
Could not find a version that satisfies the requirement toga-cocoa==0.3.0.dev5

How can I fix that, which commit in current development version I need to use?

@SteffeyDev
Copy link

Checkout out 5ffd722 worked for me @promentol

@mlewis1973
Copy link

On High Sierra, I used:
pip install toga-demo==0.3.0.dev9
to get a working version.

On my MacBook running Sierra, 0.2.15 worked

@poke1024
Copy link

poke1024 commented Oct 3, 2018

Fresh pip install on macOS mojave still has this error.

This works though:

$ git clone https:///github.com/pybee/toga.git
$ cd toga
$ pip install src/core
$ pip install src/cocoa

@freakboy3742
Copy link
Member

@mlewis1973 @poke1024 This bug will likely re-emerge with every new macOS release; it has to do with the way that Objective C can change a function into a readonly property in a way that is unambiguous to the Objective C language spec, but is different to the interface that we use to access the property.

If you get this error, we need to know which API call failed.

The fix is trivial - once we know which API has changed. For example, in the move from Snow Leopard to Mavericks, the NSApplication.sharedApplication API was the source of the problem - so we had to add this declaration.

The stack trace you receive will reference the API call that failed - that's what we need to know. If you're feeling especially adventurous, you can try submitting a PR yourself, adding the declare_class_property call for the relevant API endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests