Skip to content

Commit 20a670d

Browse files
CzarekCzarek
authored andcommitted
Added the package setup creator for CEF 3 on Linux.
1 parent 1645f06 commit 20a670d

8 files changed

Lines changed: 176 additions & 4 deletions

File tree

cefpython/cef1/linux/installer/__init__.py.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ else:
99
raise Exception("Unsupported python version: " + sys.version)
1010

1111
__version__ = "%(APP_VERSION)s"
12-
__author__ = "CEF Python authors"
12+
__author__ = "The CEF Python authors"

cefpython/cef1/linux/installer/create-setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def main():
4646

4747
installer_dir = os.path.dirname(os.path.abspath(__file__))
4848

49-
setup_dir = installer_dir+"/"+PACKAGE_NAME+"_"+vars["APP_VERSION"]+"_linux_"+BITS+"_setup"
49+
setup_dir = installer_dir+"/"+PACKAGE_NAME+"-"+vars["APP_VERSION"]+"-linux-"+BITS+"-setup"
5050
print("Creating setup dir: "+setup_dir)
5151
os.mkdir(setup_dir)
5252

cefpython/cef3/linux/binaries_32bit/wxpython.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset=utf-8>
5-
<title>CefSimple (utf-8: ąś)</title>
5+
<title>wxPython CEF 3 example (utf-8: ąś)</title>
66
<style>
77
body { font: 13px Segoe UI, Arial; line-height: 1.4em; }
88
pre { background: #ddd; font: 12px Consolas, Courier New; }

cefpython/cef3/linux/binaries_64bit/wxpython.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset=utf-8>
5-
<title>CefSimple (utf-8: ąś)</title>
5+
<title>wxPython CEF 3 example (utf-8: ąś)</title>
66
<style>
77
body { font: 13px Segoe UI, Arial; line-height: 1.4em; }
88
pre { background: #ddd; font: 12px Consolas, Courier New; }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
1. To install CEF Python 3 type:
2+
3+
sudo python setup.py install
4+
5+
This will install the cefpython3 package to
6+
/usr/local/lib/python2.7/dist-packages/
7+
8+
2. In the same directory that setup.py resides there is
9+
an examples/ directory, run some example scripts from there:
10+
11+
cd examples/
12+
python wxpython.py
13+
14+
Note:
15+
Examples directory can also be found in the cefpython3 package directory:
16+
/usr/local/lib/python2.7/dist-packages/cefpython3/examples/
17+
But to run examples from there you would have to chmod 0777
18+
the examples/ directory as it needs permission to create log files.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import ctypes, os
2+
libcef_so = os.path.join(os.path.dirname(os.path.abspath(__file__)), "libcef.so")
3+
ctypes.CDLL(libcef_so, ctypes.RTLD_GLOBAL)
4+
5+
import sys
6+
if 0x02070000 <= sys.hexversion < 0x03000000:
7+
from . import cefpython_py27 as cefpython
8+
else:
9+
raise Exception("Unsupported python version: " + sys.version)
10+
11+
__version__ = "%(APP_VERSION)s"
12+
__author__ = "The CEF Python authors"
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Create a setup package.
2+
3+
import sys
4+
import os
5+
import platform
6+
import argparse
7+
import re
8+
import platform
9+
import shutil
10+
import glob
11+
12+
BITS = platform.architecture()[0]
13+
assert (BITS == "32bit" or BITS == "64bit")
14+
15+
PACKAGE_NAME = "cefpython3"
16+
17+
README_TEMPLATE = os.getcwd()+r"/README.txt.template"
18+
INIT_TEMPLATE = os.getcwd()+r"/__init__.py.template"
19+
SETUP_TEMPLATE = os.getcwd()+r"/setup.py.template"
20+
21+
def main():
22+
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
23+
parser.add_argument("-v", "--version", help="cefpython version",
24+
required=True)
25+
args = parser.parse_args()
26+
assert re.search(r"^(v\d+)|(\d+\.\d+)$", args.version), (
27+
"Invalid version string")
28+
29+
vars = {}
30+
vars["APP_VERSION"] = args.version
31+
32+
print("Reading template: %s" % README_TEMPLATE)
33+
f = open(README_TEMPLATE)
34+
README_CONTENT = f.read() % vars
35+
f.close()
36+
37+
print("Reading template: %s" % INIT_TEMPLATE)
38+
f = open(INIT_TEMPLATE)
39+
INIT_CONTENT = f.read() % vars
40+
f.close()
41+
42+
print("Reading template: %s" % SETUP_TEMPLATE)
43+
f = open(SETUP_TEMPLATE)
44+
SETUP_CONTENT = f.read() % vars
45+
f.close()
46+
47+
installer_dir = os.path.dirname(os.path.abspath(__file__))
48+
49+
setup_dir = installer_dir+"/"+PACKAGE_NAME+"-"+vars["APP_VERSION"]+"-linux-"+BITS+"-setup"
50+
print("Creating setup dir: "+setup_dir)
51+
os.mkdir(setup_dir)
52+
53+
package_dir = setup_dir+"/"+PACKAGE_NAME
54+
print("Creating package dir")
55+
os.mkdir(package_dir)
56+
57+
print("Creating README.txt from template")
58+
with open(setup_dir+"/README.txt", "w") as f:
59+
f.write(README_CONTENT)
60+
61+
print("Creating setup.py from template")
62+
with open(setup_dir+"/setup.py", "w") as f:
63+
f.write(SETUP_CONTENT)
64+
65+
binaries_dir = os.path.abspath(installer_dir+"/../binaries_"+BITS+"/")
66+
print("Copying binaries to package dir")
67+
ret = os.system("cp -rf "+binaries_dir+"/* "+package_dir)
68+
assert ret == 0
69+
70+
os.chdir(package_dir)
71+
print("Removing .log files from the package dir")
72+
ret = os.system("rm *.log")
73+
# assert ret == 0 - if there are no .log files this assert would fail.
74+
os.chdir(installer_dir)
75+
76+
print("Creating __init__.py from template")
77+
with open(package_dir+"/__init__.py", "w") as f:
78+
f.write(INIT_CONTENT)
79+
80+
print("Creating examples dir in package dir")
81+
os.mkdir(package_dir+"/examples/")
82+
83+
# print("Creating wx dir in package dir")
84+
# os.mkdir(package_dir+"/wx/")
85+
86+
print("Moving example scripts from package dir to examples dir")
87+
examples = glob.glob(package_dir+"/*.py")
88+
for example in examples:
89+
# Ignore: cefpython_py27.py - dummy API script
90+
if os.path.basename(example).startswith("cefpython_"):
91+
continue
92+
# Ignore: __init__.py
93+
if os.path.basename(example).startswith("__"):
94+
continue
95+
os.rename(example, package_dir+"/examples/"+os.path.basename(example))
96+
ret = os.system("mv "+package_dir+"/*.html "+package_dir+"/examples/")
97+
assert ret == 0
98+
99+
# print("Copying wx-subpackage to wx dir in package dir")
100+
# wx_subpackage_dir = os.path.abspath(installer_dir+"/../../wx-subpackage/")
101+
# ret = os.system("cp -rf "+wx_subpackage_dir+"/* "+package_dir+"/wx/")
102+
# assert ret == 0
103+
104+
# print("Moving wx examples from wx/examples to examples/wx")
105+
# shutil.move(package_dir+"/wx/examples", package_dir+"/wx/wx/")
106+
# shutil.move(package_dir+"/wx/wx/", package_dir+"/examples/")
107+
108+
print("Copying package dir examples to setup dir")
109+
ret = os.system("cp -rf "+package_dir+"/examples/ "+setup_dir+"/examples/")
110+
assert ret == 0
111+
112+
print("Setup Package created.")
113+
114+
if __name__ == "__main__":
115+
main()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from distutils.core import setup
2+
3+
setup(
4+
name='CEF Python 3',
5+
version='%(APP_VERSION)s',
6+
description='Python bindings for the Chromium Embedded Framework',
7+
license='BSD 3-Clause',
8+
author='Czarek Tomczak',
9+
author_email='czarek.tomczak@gmail.com',
10+
url='http://code.google.com/p/cefpython/',
11+
packages=['cefpython3'],
12+
package_data={'cefpython3': [
13+
'examples/*.py',
14+
'examples/*.html',
15+
# 'examples/wx/*.py',
16+
# 'examples/wx/*.html',
17+
# 'examples/wx/*.png',
18+
'locales/*.pak',
19+
# 'wx/*.txt',
20+
# 'wx/images/*.png',
21+
'*.txt',
22+
'cefclient',
23+
'subprocess',
24+
'*.so',
25+
'*.pak',
26+
]}
27+
)

0 commit comments

Comments
 (0)