Skip to content

Commit

Permalink
Add build_cpp_projects.py tool to build with Python 3 on Windows (#121)…
Browse files Browse the repository at this point in the history
…...

Currently tested with Python 3.4. There are still required changes to
automate.py tool to generate libcef_dll_wrapper libraries for all Python
2 and 3 compilers (VS2008, VS2010, VS2015).

Update build instructions for Windows.

Generate and use cefpython_fixed.h so that recompilation of C++ projects
doesn't happen each time when rebuilding the cefpython module.

Update README. Add requirements for all platforms. Fix incomplete
pip install command.
  • Loading branch information
cztomczak committed Mar 7, 2017
1 parent 1837d34 commit 5f24f50
Show file tree
Hide file tree
Showing 18 changed files with 432 additions and 305 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ bots.

### v50+ releases

1. Can be installed on all platforms using `pip install` command
1. Can be installed on all platforms using `pip install cefpython3` command
2. Downloads are available on [GitHub Releases](../../releases) pages
2. Windows support: 32-bit, Python 2.7
(requirements: Windows 7+)
3. Linux support: 64-bit, Python 2.7 / 3.4 / 3.5 / 3.6
(requirements: Debian 7+ / Ubuntu 12.04+)
4. Mac support: 64-bit, Python 2.7 / 3.4 / 3.5 / 3.6
(requirements: MacOS 10.9+)
5. Documentation is in the [docs/](docs) directory
6. API reference is in the [api/](api) directory
7. Additional documentation is in issues labelled [Knowledge Base]
Expand All @@ -51,9 +54,9 @@ bots.
1. Downloads are available on [wiki pages](../../wiki#downloads)
and on GH Releases tagged [v31.2](../../releases/tag/v31.2)
2. Supports only Python 2.7
3. Windows support: 32-bit and 64-bit
4. Linux support: 32-bit and 64-bit
5. Mac support: 32-bit and 64-bit
3. Windows support: 32-bit and 64-bit (requirements: Windows XP+)
4. Linux support: 32-bit and 64-bit (requirements: Debian 7+ / Ubuntu 12.04+)
5. Mac support: 32-bit and 64-bit (requirements: MacOS 10.7+)
6. Documentation is on [wiki pages](../../wiki)
7. API reference is available in revision [169a1b2]
(../../tree/169a1b20d3cd09879070d41aab28cfa195d2a7d5/docs/api)
Expand Down
3 changes: 3 additions & 0 deletions api/WindowUtils.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,6 @@ Linux-only. This method is utilized in the PyQt example.
Linux-only. Install xlib error handlers so that the application
won't be terminated on non-fatal errors. Must be done after
initializing GTK.

CEF Python calls this function automatically during a call to
Initialize, so there is no need to call it manually anymore.
23 changes: 16 additions & 7 deletions docs/Build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,22 @@ requirements common for all platforms.

* Install an appropriate MS compiler for a specific Python version:
https://wiki.python.org/moin/WindowsCompilers
* For Python 2.7 install "Microsoft Visual C++ Compiler for Python 2.7"
from [here](https://www.microsoft.com/en-us/download/details.aspx?id=44266)
* When using "Visual C++ compiler for Python 2.7" you have to install
"Microsoft Visual C++ 2008 Redistributable Package (x64)" from
[here](https://www.microsoft.com/en-us/download/details.aspx?id=15336)
* For Python 2.7 install "Microsoft Visual C++ Compiler for Python 2.7"
from [here](https://www.microsoft.com/en-us/download/details.aspx?id=44266)
* When using "Visual C++ compiler for Python 2.7" you have to install
"Microsoft Visual C++ 2008 Redistributable Package (x64)" from
[here](https://www.microsoft.com/en-us/download/details.aspx?id=15336)
* For Python 2.7 copy "cefpython/src/windows/py27/stdint.h" to
"%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include\"
if does not exist
* For Python 3.4 follow the instructions for installing Windows SDK 7.1.
If you encounter issue with .NET Framework 4 then make registry edits
as suggested here: [Windows SDK setup failure]
(http://stackoverflow.com/a/33260090/623622).
* For Python 3.4, if getting error:
`Cannot open include file 'ammintrin.h': No such file or directory`
then Copy that `ammitrin.h` file from for example VS 2015 installation
directory or find this file on the web. This is a Microsoft issue.
* To build CEF from sources:
* Use Win7 x64 or later. 32-bit OS'es are not supported. For more details
see [here](https://www.chromium.org/developers/how-tos/build-instructions-windows).
Expand All @@ -165,8 +176,6 @@ requirements common for all platforms.
to PATH
* You need about 16 GB of RAM during linking. If there is an error
just add additional virtual memory.
* For Python 2.7 copy "cefpython/src/windows/stdint.h" to
"%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include\"


### Linux
Expand Down
2 changes: 1 addition & 1 deletion src/client_handler/client_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma once

#if defined(_WIN32)
#include "../windows/stdint.h"
#include <stdint.h>
#endif

#include "common/cefpython_public_api.h"
Expand Down
2 changes: 1 addition & 1 deletion src/client_handler/cookie_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#if defined(_WIN32)
#include "../windows/stdint.h"
#include <stdint.h>
#endif

#include "common/cefpython_public_api.h"
Expand Down
2 changes: 1 addition & 1 deletion src/client_handler/request_context_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#if defined(_WIN32)
#include "../windows/stdint.h"
#include <stdint.h>
#endif

#include "common/cefpython_public_api.h"
Expand Down
2 changes: 1 addition & 1 deletion src/client_handler/resource_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#if defined(_WIN32)
#include "../windows/stdint.h"
#include <stdint.h>
#endif

#include "common/cefpython_public_api.h"
Expand Down
2 changes: 1 addition & 1 deletion src/client_handler/string_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#if defined(_WIN32)
#include "../windows/stdint.h"
#include <stdint.h>
#endif

#include "common/cefpython_public_api.h"
Expand Down
2 changes: 1 addition & 1 deletion src/client_handler/web_request_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#if defined(_WIN32)
#include "../windows/stdint.h"
#include <stdint.h>
#endif

#include "common/cefpython_public_api.h"
Expand Down
10 changes: 5 additions & 5 deletions src/common/cefpython_public_api.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* This is a wrapper around including cefpython.h that is generated
/* This is a wrapper around including cefpython_fixed.h that is generated
by Cython. Functions marked with the 'public' keyword are exposed
to C through that header file. */

#ifndef CEFPYTHON_PUBLIC_API_H
#define CEFPYTHON_PUBLIC_API_H

#if defined(OS_WIN)
#pragma warning(disable:4190) // cefpython.h extern C-linkage warnings
#pragma warning(disable:4190) // cefpython_fixed.h extern C-linkage warnings
#endif

#include "Python.h"

// cefpython.h declares public functions using DL_IMPORT and these
// cefpython_fixed.h declares public functions using DL_IMPORT and these
// macros are not available in Python 3.
#ifndef DL_IMPORT
#define DL_IMPORT(RTYPE) RTYPE
Expand All @@ -20,12 +20,12 @@
#define DL_EXPORT(RTYPE) RTYPE
#endif

// Includes required by "cefpython.h".
// Includes required by "cefpython_fixed.h".
#include "include/cef_client.h"
#include "include/cef_urlrequest.h"
#include "include/cef_command_line.h"
#include "util.h"

#include "../../build/build_cefpython/cefpython.h"
#include "../../build/build_cefpython/cefpython_fixed.h"

#endif // CEFPYTHON_PUBLIC_API_H
2 changes: 1 addition & 1 deletion src/compile_time_constants.pxi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file was generated by setup.py
DEF UNAME_SYSNAME = "Windows"
DEF PY_MAJOR_VERSION = 2
DEF PY_MAJOR_VERSION = 3
4 changes: 2 additions & 2 deletions src/cpp_utils/PaintBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// _WIN32 is defined on both 32bit and 64bit.
#if defined(_WIN32)
#include "windows.h"
#include "stdint_win.h"
#include <stdio.h>
#else
#include <stdint.h>
#include <string.h>
#endif

#include <stdint.h>

void FlipBufferUpsideDown(void* _dest, const void* _src, int width, int height \
) {
// In CEF the buffer passed to Browser.GetImage() & RenderHandler.OnPaint()
Expand Down
Loading

0 comments on commit 5f24f50

Please sign in to comment.