kryskool / cefpython

Automatically exported from code.google.com/p/cefpython
0 stars 1 forks source link

Adapt for OSX #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Feature Request: Build API for OSX

Original issue reported on code.google.com by rattray....@gmail.com on 24 Oct 2012 at 12:46

GoogleCodeExporter commented 9 years ago
I currently only know Python but if there is anything I can do to help in this 
effort please let me know. 

Original comment by rattray....@gmail.com on 24 Oct 2012 at 12:47

GoogleCodeExporter commented 9 years ago
I do have a fair amount of experience working with PyObjC if that helps. 

Original comment by rattray....@gmail.com on 24 Oct 2012 at 12:49

GoogleCodeExporter commented 9 years ago
It is required to know a bit of C++, Cython and Objective-C to create an OSX 
port. It should be an easier task then the linux port as there are ready 
binaries:

http://code.google.com/p/chromiumembedded/downloads/detail?name=cef_binary_1.118
0.832_macosx.zip

I am not yet sure about the objective-C stuff, how to do this in Cython, I am 
now looking at macosx binary /cefclient/cefclient_mac.mm and have no idea of 
how to port this objective-c code to c/c++ in Cython.

The other problem is that I don't own any Mac. Here in Poland a Mac is a rare 
thing, I ever saw one a few years ago, only because my friend was a Ruby On 
Rails fanatic and bought one. Though I'm flying to Canada to my uncle in a few 
days, he's a computer hobbyist, maybe he owns a mac thing, I will be staying 
there for a while.

Original comment by czarek.t...@gmail.com on 24 Oct 2012 at 6:29

GoogleCodeExporter commented 9 years ago
I've been googling for "cython cocoa" and found only this tip useful:

https://groups.google.com/d/msg/cython-users/Je1o6zQkPuY/s4on7ar7yoQJ

Original comment by czarek.t...@gmail.com on 24 Oct 2012 at 8:11

GoogleCodeExporter commented 9 years ago
My feeling is that PyObjC is the right tool for the job. It's supposed to be a 
bidirectional bridge, so you can call Python from ObjC and vice versa, but I've 
only ever written Python that called ObjC. I'm not 100% sure what a project 
like this entails, though, so I can't say for sure if this will do everything 
needed. 

Have a great trip to Canada! Beautiful country. 

I once went to an Apple store and asked how I could get an older operating 
system (10.6, Snow Leoapard -- not that old, still in widespread use) and the 
salesperson told me I should just torrent it and use a Virtual Machine; Apple 
doesn't sell the Snow Leopard OS anymore. So you might have some luck that way?

Are there any resources you might recommend for me to wrap my head around how 
projects like this work? I tried browsing the source but didn't really know 
where to start. 

Thanks!

Original comment by rattray....@gmail.com on 24 Oct 2012 at 1:37

GoogleCodeExporter commented 9 years ago
I've looked over pyobjc examples and every time I see a setup.py, I hope it is 
possible to run pyobjc as pure python without compilation, then it might work.

>how projects like this work?

My way of doing this is a lot of googling, struggling with documentation, 
finding good examples, learning by trial and error. I've started with baby 
steps and it just growed. Try doing some simple thing, one thing at a time.

Original comment by czarek.t...@gmail.com on 24 Oct 2012 at 2:19

GoogleCodeExporter commented 9 years ago
Yes, I run PyObjc without compilation as "pure" python (links down to PyObjC, 
of course, which runs ObjC)

Haha thanks, that does indeed seem to be the way to learn this kind of thing. 

Original comment by rattray....@gmail.com on 24 Oct 2012 at 2:22

GoogleCodeExporter commented 9 years ago
Cython can be sometimes hard to debug after some big refactoring, compiler 
errors are obfuscated, so better to avoid this, I try to compile it often.

Original comment by czarek.t...@gmail.com on 24 Oct 2012 at 2:25

GoogleCodeExporter commented 9 years ago
Some guys let me know they ported cefpython to CEF 3 (single process mode), 
they also have a Mac version. I've looked over the sources, the problem with 
OSX specific code can be solved by using wxPython or Tkinter to create windows, 
then there isn't much code to write for OSX, there is one .mm file with only 3 
functions:

void CefWindowInfo_SetAsChild(CefWindowInfo *_self, CefWindowHandle parent);
void MacInit();
void MacShutdown();

There are some other minor differences, the conversion between python string <> 
cef string in functions PyStringToCefString and CefStringToPyString needs to be 
done in a different way, by using PyUnicode_DecodeUTF32 / PyUnicode_DecodeUTF16 
as char size on mac is 4 bytes.

Another issue is Auth Dialog for http authentication, how do we create that 
dialog? Using wxPython (that would need a delegate) or do we call OSX-specific 
functions?

I still don't have a mac so this issue will have to wait.

Original comment by czarek.t...@gmail.com on 14 Nov 2012 at 3:37

GoogleCodeExporter commented 9 years ago
Wow, that doesn't look bad at all, I hope. 
As for the Auth Dialog, I'm not sure. I currently use PyQt for my desktop GUIs. 
I know it isn't hard to make a dialog in PyObjC; if the auth dialog is minor, 
it probably isn't more than 20 lines of code (I don't know anything about the 
http auth though). I know small dialogues on wxPython are very trivial; I've 
heard awful things about tkinter in general but never worked with it myself. 

I don't know enough about how cef / cefpython work to answer well though (for 
example, is cefpython basically just a better webview embedded in another 
(wxpython/pyqt/tkinter) app?. If you're not familiar with desktop gui's, I can 
send you some of my code for my main pyqt desktop gui, which also wraps a 
webview. 

Original comment by rattray....@gmail.com on 14 Nov 2012 at 4:20

GoogleCodeExporter commented 9 years ago
Cefpython is just a webview, you pass a window handle to CreateBrowser() and 
that's all cef needs to know. 

I think that we can create the http auth dialog using tkinter, as I remember 
from the Issue 1 discussion it comes by default with any python so there are no 
dependencies, after googling "tkinter dialog example" I have this:

http://www.pythonware.com/library/tkinter/introduction/dialog-windows.htm

> Figure 10-1. running the dialog2.py script

This is exactly what we need, 2 inputs and OK/Cancel, that should work.

Original comment by czarek.t...@gmail.com on 14 Nov 2012 at 10:49

GoogleCodeExporter commented 9 years ago
The http auth window needs to be modal, googling "tkinter modal dialog" shows 
some solutions. Maybe we could even get rid of that c++ code for the windows 
platform, I've created an issue for that: Issue 26.

Original comment by czarek.t...@gmail.com on 14 Nov 2012 at 11:05

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
What is the status of the Mac port?

Original comment by alexodon...@gmail.com on 4 Mar 2013 at 3:09

GoogleCodeExporter commented 9 years ago
I haven't yet started working on it, I still don't own any Mac machine,
there were only general improvements in the code to prepare for Linux 
and OSX ports.

Original comment by czarek.t...@gmail.com on 4 Mar 2013 at 3:25

GoogleCodeExporter commented 9 years ago
Is there any chance you could invite the developers who worked on one to come 
and post their code? Even as a one off code drop, it would give others (such as 
myself) a nice point to work from.

Original comment by alexodon...@gmail.com on 4 Mar 2013 at 3:30

GoogleCodeExporter commented 9 years ago
Alex, The Mac code I was shared with cannot be made public, though I could
share with you portions of the code that are Mac-specific, first I would
need to find and extract it. I am here to help you with my advice on the
cefpython code, but I would need some declaration from your side that you
will share the code back with the community.

Original comment by czarek.t...@gmail.com on 4 Mar 2013 at 4:07

GoogleCodeExporter commented 9 years ago
CEF 1 does not support Retina displays, but CEF 3 does, see this topic:
http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10620
I think that we should port only CEF 3 to Mac.

Original comment by czarek.t...@gmail.com on 2 May 2013 at 1:36

GoogleCodeExporter commented 9 years ago

Original comment by czarek.t...@gmail.com on 13 Jun 2013 at 7:29

GoogleCodeExporter commented 9 years ago
Hi, if you could share the mac code you have I would be willing to take a look 
and contribute back to cefpython. 

I completely agree with only port CEF3 to mac.

Original comment by mike.leo...@fivium.co.uk on 4 Sep 2013 at 1:10

GoogleCodeExporter commented 9 years ago
After a second thought, I don't think using the code I was referring to is
a good idea, it's not open sourced, so we better don't look at it. 

I have a general idea of what to do, so if you're stuck or need help with
anything, just ask, here or on the CEF Python Forum.

Original comment by czarek.t...@gmail.com on 4 Sep 2013 at 7:54

GoogleCodeExporter commented 9 years ago
Just wanted to say that i LOVE this project and am excited to use the mac 
build!  

Original comment by m...@netops.animationmentor.com on 8 Nov 2013 at 5:40

GoogleCodeExporter commented 9 years ago
That said, what is the status of the mac port now?  I too would love to 
contribute my time if you can give me some suggestions for where to start.

Original comment by m...@netops.animationmentor.com on 8 Nov 2013 at 6:24

GoogleCodeExporter commented 9 years ago
Hi Czarek, currently fetching chromium src on OSX.  You said above that you 
have a general idea of what to do, may I hear your thoughts?

Original comment by mikemah...@gmail.com on 6 Dec 2013 at 12:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
#24 mikemahony
If you have any specific questions, I'm glad to answer these.

Original comment by czarek.t...@gmail.com on 16 Jan 2014 at 10:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi, has any got this working?

Original comment by philip142au@gmail.com on 19 Jun 2014 at 3:40

GoogleCodeExporter commented 9 years ago
if anyone could port to mac, sincerely appreciate it!

Original comment by pianoboysai on 30 Aug 2014 at 5:00

GoogleCodeExporter commented 9 years ago
Hello Czarek,

+1 I also looking for (and trying for a couple hour) Mac OSX port, could you 
please let me know when will be public release?

Best regards.

Original comment by suriy...@gmail.com on 7 Sep 2014 at 4:40

GoogleCodeExporter commented 9 years ago

Original comment by czarek.t...@gmail.com on 7 Sep 2014 at 7:11

GoogleCodeExporter commented 9 years ago
The cefpython module compiles fine on Mac. See revision 32846e1f20e1. Created 
the BuildOnMac wiki page. Still to do: a wxpython.py example.

Original comment by czarek.t...@gmail.com on 9 Jan 2015 at 11:52

GoogleCodeExporter commented 9 years ago
Added the wxpython.py example in revision e07d0bd04ab4.

There are two problems to be fixed on Mac (Issue 156):
1. Mouse context menu is currently disabled, as it crashes app
2. <select> controls crash app too

Everything else works fine.

Original comment by czarek.t...@gmail.com on 10 Jan 2015 at 5:37

GoogleCodeExporter commented 9 years ago
Currently CEF builds on Mac are with tcmalloc memory allocator and this 
requires for the cefpython library to be imported very first in a program 
before any others like wx. Issue 155 is to provide CEF builds for Mac with 
tcmalloc disabled.

Original comment by czarek.t...@gmail.com on 10 Jan 2015 at 5:46

GoogleCodeExporter commented 9 years ago
There are several differences in the wxpython.py example across different 
platforms. Created Issue 159 that tries to list these differences. The goal is 
to provide a single wxpython.py that runs on all platforms.

Original comment by czarek.t...@gmail.com on 11 Jan 2015 at 5:27

GoogleCodeExporter commented 9 years ago
Errors when accessing mouse context menu and <select> controls were fixed, see 
Issue 156 for details.

There is still an another minor issue to be fixed: Copy/Paste keyboard 
shortcuts don't work. See Issue 161 for details.

Next tasks on the list:
 * Build with CEF 64-bit binaries
 * Provide Python Wheel binary packages on PyPI for both 32bit and 64bit

Original comment by czarek.t...@gmail.com on 11 Jan 2015 at 7:04

GoogleCodeExporter commented 9 years ago
Porting to Mac is complete. Package can be installed using the pip package 
manager:

  pip install cefpython3

The python wheel package that installs contains fat binaries and can run on 
both 32bit and 64bit.

See also the Download wiki page for Mac and the examples section: 
https://code.google.com/p/cefpython/wiki/Download_CEF3_Mac

64bit builds fixed in revision b37e9b39a133.
Installer scripts added in revision 15dc5746e099.

Original comment by czarek.t...@gmail.com on 13 Jan 2015 at 7:57