Skip to content

Commit 53d484f

Browse files
committed
Added linux binaries (ubuntu 12.04 LTS 32bit).
1 parent f8d9a6b commit 53d484f

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed

cefpython/cef1/linux/compile.sh

Whitespace-only changes.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Copyright (c) 2012 CefPython Authors. All rights reserved.
2+
# License: New BSD License.
3+
# Website: http://code.google.com/p/cefpython/
4+
5+
# First, it copies all .pyx files from upper directory to setup/.
6+
# Then, fixes repeating of "include" statements in pyx files.
7+
8+
# Only the mainfile needs to have "include" statements,
9+
# but we're using PyCharm and to get rid of "unresolved references"
10+
# and other errors displayed in pycharm we are adding "include"
11+
# statements in all of the pyx files.
12+
13+
# I'm not 100% sure how includes work in Cython, but I suspect that
14+
# a few includes of the same file will include the same content more
15+
# than once, it should work, but function and variable definitions are
16+
# duplicated, it is some kind of overhead and it could lead to some
17+
# problems in the future, better to fix it now.
18+
19+
# It also checks cdef & cpdef functions whether they are not missing "except *",
20+
# it is required to add it when returning non-python type.
21+
22+
import glob
23+
import os
24+
import re
25+
import shutil
26+
27+
def ExceptAllMissing(content):
28+
29+
# This is not perfect, won't detect C++ custom types, but will find
30+
# the built-in types, templates and pointers.
31+
patterns = []
32+
patterns.append(
33+
r"\bcp?def\s+"
34+
"((int|short|long|double|char|unsigned|float|double)\s+)+"
35+
"\w+\([^)]*\)\s*(with\s+(gil|nogil))?\s*:")
36+
patterns.append(
37+
r"\bcp?def\s+"
38+
# A template ends with bracket: CefRefPtr[CefBrowser]
39+
# or a pointer ends with asterisk: CefBrowser*
40+
"[^\s]+[\]*]\s+"
41+
"\w+\([^)]*\)\s*(with\s+(gil|nogil))?\s*:")
42+
patterns.append(
43+
r"\bcp?def\s+"
44+
# A reference, eg. CefString&
45+
"[^\s]+&\s+"
46+
"\w+\([^)]*\)\s*(with\s+(gil|nogil))?\s*:")
47+
48+
for pattern in patterns:
49+
match = re.search(pattern, content)
50+
if match: break
51+
52+
if match:
53+
lineNumber = (content.count("\n", 0, match.start()) + 1)
54+
return lineNumber
55+
56+
print("\n")
57+
mainfile = "cefpython.pyx"
58+
59+
pyxfiles = glob.glob("../../../*.pyx")
60+
if not len(pyxfiles):
61+
exit(1)
62+
pyxfiles = [file for file in pyxfiles if file.find(mainfile) == -1]
63+
# Now, pyxfiles contains all pyx files except the mainfile (cefpython.pyx),
64+
# we do not fix includes in mainfile.
65+
66+
# So that this is the right directory we're in.
67+
if os.path.exists("setup"):
68+
print("Wrong directory, we should be inside setup!")
69+
exit()
70+
71+
# Remove old pyx files in setup directory.
72+
oldpyxfiles = glob.glob("./*.pyx")
73+
print("Removing old pyx files in /setup/: %s" % oldpyxfiles)
74+
for pyxfile in oldpyxfiles:
75+
if os.path.exists(pyxfile):
76+
os.remove(pyxfile)
77+
78+
# Copying pyxfiles and reading its contents.
79+
80+
print("Copying .pyx files to /setup/: %s" % pyxfiles)
81+
shutil.copy("../../../%s" % mainfile, "./%s" % mainfile)
82+
# Rest of the files will be copied in for loop below.
83+
84+
print("Fixing includes in .pyx files:")
85+
for pyxfile in pyxfiles:
86+
newfile = "./%s" % os.path.basename(pyxfile)
87+
shutil.copy(pyxfile, newfile)
88+
pyxfile = newfile
89+
with open(pyxfile, "r") as pyxfileopened:
90+
content = pyxfileopened.read()
91+
lineNumber = ExceptAllMissing(content)
92+
if lineNumber:
93+
print("WARNING: 'except *' missing in a cdef/cpdef function, "
94+
"in file %s on line %d" % (os.path.basename(pyxfile), lineNumber))
95+
exit(1)
96+
# Do not remove the newline - so that line numbers are exact with originals.
97+
(content, subs) = re.subn(r"^include[\t ]+[\"'][^\"'\n\r]+[\"'][\t ]*", "", content, flags=re.MULTILINE)
98+
if subs:
99+
print("%s includes removed in: %s" % (subs, os.path.basename(pyxfile)))
100+
# Reading and writing with the same handle using "r+" mode doesn't work,
101+
# you need to seek(0) and write the same amount of bytes that was in the
102+
# file, otherwise old data from the end of file stays.
103+
with open(pyxfile, "w") as pyxfileopened:
104+
pyxfileopened.write(content)
105+
106+
print("\n")
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
from distutils.core import setup
2+
from distutils.extension import Extension
3+
from Cython.Distutils import build_ext
4+
import sys
5+
import platform
6+
from Cython.Compiler import Options
7+
8+
# Stop on first error, otherwise hundreds of errors appear in the console.
9+
Options.fast_fail = True
10+
11+
# Written to cython_includes/compile_time_constants.pxi
12+
CEF_VERSION = 1
13+
14+
"""
15+
Building libcef_dll_wrapper
16+
---------------------------
17+
18+
libcef_dll_wrapper needs to be compiled with /MD, otherwise you get linker errors
19+
of type "already defined". When you try to compile using /MD you may get warnings:
20+
21+
warning C4275: non dll-interface class 'stdext::exception' used as base for
22+
dll-interface class 'std::bad_typeid' see declaration of 'stdext::exception'
23+
see declaration of 'std::bad_typeid'
24+
25+
Which results in build errors. To solve it you need to add command line option:
26+
27+
-D_HAS_EXCEPTIONS=1
28+
29+
Enabling C++ exceptions ("/EHsc") is not required.
30+
"""
31+
32+
# Python version string: "27" or "32".
33+
PYTHON_VERSION = str(sys.version_info.major) + str(sys.version_info.minor)
34+
35+
def CompileTimeConstants():
36+
37+
print("Generating: cython_includes/compile_time_constants.pxi")
38+
with open("./../../../cython_includes/compile_time_constants.pxi", "w") as fd:
39+
fd.write('# This file was generated by setup.py\n')
40+
# A way around Python 3.2 bug: UNAME_SYSNAME is not set.
41+
fd.write('DEF UNAME_SYSNAME = "%s"\n' % platform.uname()[0])
42+
fd.write('DEF CEF_VERSION = %s\n' % CEF_VERSION)
43+
44+
CompileTimeConstants()
45+
46+
ext_modules = [Extension(
47+
48+
"cefpython_py%s" % PYTHON_VERSION,
49+
["cefpython.pyx"],
50+
51+
language='c++',
52+
include_dirs=[r'./../', r'./../../', r'./../../../', r'./../../../cython_includes/'],
53+
54+
library_dirs=[
55+
r'./',
56+
r"c:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86/",
57+
r'./../../http_authentication/Release/',
58+
r'./../../v8function_handler/Release_py%s/' % PYTHON_VERSION,
59+
r'./../../client_handler/Release_py%s/' % PYTHON_VERSION,
60+
r'./../../../cpp_utils/Release/cpp_utils.lib',
61+
],
62+
63+
libraries=[
64+
'libcef',
65+
'libcef_dll_wrapper',
66+
'User32',
67+
'Gdi32',
68+
'http_authentication', # Build with /MD.
69+
'v8function_handler_py%s' % PYTHON_VERSION, # Build with /MD.
70+
'client_handler_py%s' % PYTHON_VERSION # Build with /MD.
71+
],
72+
73+
# /EHsc - using STL string, multimap and others that use C++ exceptions.
74+
extra_compile_args=['/EHsc'],
75+
76+
# '/ignore:4217' - silence warnings: "locally defined symbol _V8FunctionHandler_Execute
77+
# imported in function "public: virtual bool __thiscall V8FunctionHandler::Execute".
78+
# client_handler or other vcprojects include setup/cefpython.h,
79+
# this is a list of functions with "public" statement that is
80+
# accessible from c++.
81+
extra_link_args=['/ignore:4217'],
82+
83+
# Defining macros:
84+
# define_macros = [("UNICODE","1"), ("_UNICODE","1"), ]
85+
)]
86+
87+
setup(
88+
name = 'cefpython_py%s' % PYTHON_VERSION,
89+
cmdclass = {'build_ext': build_ext},
90+
ext_modules = ext_modules
91+
)

0 commit comments

Comments
 (0)