roadlabs / cefpython

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

Provide releases for Python 64-bit #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Downloaded the 2.7 archive & extracted
2. Opened a command prompt in the cefpython directory
3. Tried the commands 'cefsimple.py' and 'cefadvanced.py'

Here's the output for cefsimple.py:
{{{
Traceback (most recent call last):
  File "cefsimple.py", line 4, in <module>
    import cefpython
ImportError: DLL load failed: %1 is not a valid Win32 application.
}}}

And cefadvanced.py:
{{{
Traceback (most recent call last):
  File "cefadvanced.py", line 5, in <module>
    import cefpython # cefpython.pyd
ImportError: DLL load failed: %1 is not a valid Win32 application.
}}}

The python version:
Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on 
win32

The OS version:
I'm running on Windows 7(x64)

Additional info:
I tried a few things first, including installing pywin32 and wxpython(x64).

After a bit of searching on Google I think I managed to figure out the issue. 
pyd files get compiled to specific architectures. So, if the one you provide in 
the archive is targeted to x32 then a x64 version is also needed. 

I tried loading the samples after deleting cefpython.pyd and the program 
executed without triggering an error but no window was shown. No surprise there 
as the cefpython.CreateBrowser() statement never gets called.

Launching the 'cefwindow.py' command also works without issue. All it loads is 
a blank window.

Hopefully this helps...

Original issue reported on code.google.com by evanpla...@gmail.com on 14 Nov 2012 at 10:39

GoogleCodeExporter commented 9 years ago
I have never tried cython but it looks like the architecture setting is in 
cefpython.pyd.manifest then compile .bat will create a new version.

I would try it myself but I don't have a dev environment currently setup in 
windows.

Original comment by evanpla...@gmail.com on 14 Nov 2012 at 10:52

GoogleCodeExporter commented 9 years ago
I've added "32-bit" to the description of downloads on the main page. All 
current releases of cefpython are for 32-bit versions of python interpreter.

If you try to run 32-bit python module on a 64-bit version of python you will 
get a "DLL load failed" error.

It shouldn't be a problem to create 64-bit releases of cefpython, I will 
provide such for the next release. In the meantime consider using 32-bit 
python, from what I know there isn't much advantage of using 64-bit python, 
only that your application can use more than 4 GB of ram.

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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
First, thanks for the quick reply.

The only 'real' benefit to 64bit is higher memory address range, faster 
floating point processing, a larger default int range, and faster processing of 
large numbers (greater than 2^32). The downside being that memory addresses 
require twice the space.

I focus mostly on 64bit in an effort to phase out 32bit development but have no 
problems switching over to python x32 in the interim.

To keep the packaging simple wouldn't it be easier to include both x32 and x64 
versions in a single release (as opposed to using two releases) since that's 
the only architecture-specific dependency? Just my .02.

Thanks again.

Original comment by evanpla...@gmail.com on 15 Nov 2012 at 12:18

GoogleCodeExporter commented 9 years ago
Not sure if this is useful.

The python architecture can easily be detected using the 'platform' module.

Just add 'import platform' and check it using 'platform.architecture()[0]'.

platform.architecture is actually a tuple containing 2 items. The second isn't 
really relevant as it contains linkage info about the executable.

Here's the documentation:
http://docs.python.org/2/library/platform.html

One way to support both would be to add a conditional import:
{{{
if(platform.architecture()[0] == '32bit'):
  import cefpython32 as cefpython
if(platform.architecture()[0] = '64bit'):
  import cefpython64 as cefpython
else:
  raise Exception("The architecture %s is not supported" % (platform.architecture()[0]))
}}}

Original comment by evanpla...@gmail.com on 15 Nov 2012 at 2:07

GoogleCodeExporter commented 9 years ago
Hmm, that might work, we could also detect version of python in a similar way, 
that way I would have to release only 1 binary zip with 4 versions of the pyd:

cefpython_py27_32bit.pyd
cefpython_py27_64bit.pyd
cefpython_py32_32bit.pyd
cefpython_py32_64bit.pyd

Thank you for the tip.

Original comment by czarek.t...@gmail.com on 15 Nov 2012 at 3:24

GoogleCodeExporter commented 9 years ago
Here's how you check the version:

sys.version returns a tuple containing 3 items. The major version number, the 
minor version number, and the sub-minor version number.

{{{
# detect 2.7
if sys.version_info[:2] == (2, 7):

# detect 3+
if sys.version_info[:1] == (3):
}}}

It makes sense to package all variations together into one because the 
platform-specific binaries only take up ~500KB each.

On the projects I work on, I usually only release scripts so I don't have to 
deal with platform-specific issues but I realize what a pain it can be to deal 
with.

Hopefully, this saves you some time in the future.

Original comment by evanpla...@gmail.com on 15 Nov 2012 at 3:48

GoogleCodeExporter commented 9 years ago
I've already started making changes to cefpython to support 64-bit, but I have 
a bad news. CEF dlls are 32-bit, we cannot load them using 64-bit python, as 
32-bit and 64-bit dlls cannot be mixed. Version for 64-bit python would need a 
separate release, because of different CEF dlls. Chromium on windows does not 
compile to 64-bit as of the moment, mostly because V8 engine is not 64-bit 
ready on windows:

http://www.chromium.org/developers/design-documents/64-bit-support

Currently we cannot support 64-bit python. I am closing this issue. When 
chromium starts compiling to 64-bit I might reopen it.

Original comment by czarek.t...@gmail.com on 16 Nov 2012 at 2:49

GoogleCodeExporter commented 9 years ago

Original comment by czarek.t...@gmail.com on 16 Nov 2012 at 2:49

GoogleCodeExporter commented 9 years ago
Chromium supports 64-bit on Linux and OSX, for those platforms it is possible 
to make 64-bit releases of cefpython.

Original comment by czarek.t...@gmail.com on 16 Nov 2012 at 2:53