Skip to content

Commit 028a36b

Browse files
committed
Improvements to Linux and Windows installers. Issue 145, Issue 105,
Issue 99. setup.py will use either distutils or setuptools depending on which one is available. setuptools is not distributed by default. Post install instructions will now create a symbolic link to libudev.so.0 on the fly. Loading libffmpegsumo.so in the browser process may cause issues. It is designated only for the renderer subprocess.
1 parent 35430f4 commit 028a36b

File tree

7 files changed

+99
-102
lines changed

7 files changed

+99
-102
lines changed

cefpython/cef3/linux/installer/README.txt.template

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,16 @@
55
This will install the cefpython3 package to
66
/usr/local/lib/python2.7/dist-packages/
77

8-
2. It may also be required to install "libnss3" and "libnspr4" dependencies:
9-
10-
sudo apt-get install libnss3-1d libnspr4-0d
11-
12-
3. On Ubuntu 12 everything should work out of the box. But on Ubuntu 13,
13-
Ubuntu 14, Fedora 20 and possibly some other OS'es there may be issues
14-
with wrong version of libudev library. For example to fix it on Ubuntu
15-
64bit it is required to create a symbolic link "libudev.so.0" to
16-
the "libudev.so.1" library with this command:
17-
18-
cd /lib/x86_64-linux-gnu/
19-
sudo ln -sf libudev.so.1 libudev.so.0
20-
21-
The path to libudev.so.1 may be different on other OS'es, see:
22-
* Ubuntu, Xubuntu, Mint - /lib/x86_64-linux-gnu/
23-
* SUSE, Fedora - /usr/lib64/
24-
* Arch, Fedora 32bit - /usr/lib/
25-
* Ubuntu 32bit - /lib/i386-linux-gnu/
26-
27-
4. In the same directory that setup.py resides there is
28-
an examples/ directory, run some example scripts from there:
8+
2. In the same directory that setup.py resides there is
9+
an examples/ directory. Run some examples from there:
2910

3011
cd examples/
12+
python pygtk_.py
13+
python pyqt.py
3114
python wxpython.py
3215
python kivy_.py
3316

3417
cd wx/
3518
python sample1.py
3619
python sample2.py
3720
python sample3.py
38-
39-
Note:
40-
Examples directory can also be found in the cefpython3 package directory:
41-
/usr/local/lib/python2.7/dist-packages/cefpython3/examples/
42-
But to run examples from there you would have to chmod 0777
43-
the examples/ directory as it needs permission to create log files.

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

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
import ctypes, os
22

3-
# If this is a debian package then package_dir is a symlink:
4-
# /usr/lib/pymodules/python2.7/cefpython3/
5-
# The real directory in which cefpython files are located is:
6-
# /usr/share/pyshared/cefpython3/
7-
8-
# Package dir will be /usr/lib/pymodules/python2.7/cefpython3/
9-
# when using the debian package. For the distutils setup it
10-
# will be /usr/local/lib/python2.7/dist-packages/cefpython3/.
11-
package_dir = os.path.dirname(os.path.abspath(__file__))
3+
# If this is a debian package then package_dir returns:
4+
# /usr/lib/pymodules/python2.7/cefpython3
5+
# The above path consists of symbolic links to the real directory:
6+
# /usr/share/pyshared/cefpython3
127

13-
# This loads the libcef.so library for the python process.
14-
libcef_so = os.path.join(package_dir, "libcef.so")
15-
ctypes.CDLL(libcef_so, ctypes.RTLD_GLOBAL)
8+
# If package was installed using PIP or setup.py then package
9+
# dir is here:
10+
# /usr/local/lib/python2.7/dist-packages/cefpython3/
11+
12+
package_dir = os.path.dirname(os.path.abspath(__file__))
1613

17-
# Other .so libraries may also be required.
18-
# Loading the libffmpegsumo.so library is probably redundant to
19-
# load for the python process, as it shows from testing. It is
20-
# only loaded by the subprocess executable with the use of the
21-
# LD_LIBRARY_PATH env variable. But just to be sure let's load
22-
# it as well for future proof.
23-
libffmpegsumo_so = os.path.join(package_dir, "libffmpegsumo.so")
24-
ctypes.CDLL(libffmpegsumo_so, ctypes.RTLD_GLOBAL)
25-
26-
# This will allow the subprocess executable to load the libcef.so
27-
# and libffmpeg.so libraries.
14+
# This loads the libcef.so library for the subprocess executable.
2815
os.environ["LD_LIBRARY_PATH"] = package_dir
2916

3017
# This env variable will be returned by cefpython.GetModuleDirectory().
3118
os.environ["CEFPYTHON3_PATH"] = package_dir
3219

20+
# This loads the libcef.so library for the main python executable.
21+
# The libffmpegsumo.so library does not need to be loaded here,
22+
# it may cause issues to load it here in the browser process.
23+
libcef_so = os.path.join(package_dir, "libcef.so")
24+
ctypes.CDLL(libcef_so, ctypes.RTLD_GLOBAL)
25+
3326
import sys
3427
if 0x02070000 <= sys.hexversion < 0x03000000:
3528
from . import cefpython_py27 as cefpython
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[bdist_wheel]
2-
python-tag=cp%(PY_VERSION_DIGITS_ONLY)
2+
python-tag=cp%(PY_VERSION_DIGITS_ONLY)s

cefpython/cef3/linux/installer/setup.py.template

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,66 @@
1-
from setuptools import setup
2-
from setuptools.command.install import install as _install
3-
from setuptools.dist import Distribution
1+
try:
2+
# The setuptools package is not installed by default
3+
# on a clean Ubuntu. Might be also a case on Windows.
4+
# Python Eggs and Wheels can be created only with setuptools.
5+
from setuptools import setup
6+
from setuptools.command.install import install as _install
7+
from setuptools.dist import Distribution
8+
print("[setup.py] Using setuptools")
9+
except:
10+
from distutils.core import setup
11+
from distutils.command.install import install as _install
12+
from distutils.dist import Distribution
13+
print("[setup.py] Using distutils")
14+
415
import sys
516
import os
617
import subprocess
718

8-
def my_post_install():
9-
""" Chmod +x the subprocess and cefclient executables. """
19+
def post_install():
20+
""" Post install tasks """
21+
print("[setup.py] post_install()")
1022

11-
print("my_post_install()")
12-
13-
# Do not import from the local "cefpython3" directory.
14-
# Import the cefpython3 module from dist-packages/ directory.
23+
# Check if libudev.so.0 exists and if not, create
24+
# a symbolic link to libudev.so.1. See issues 145
25+
# and 105 in the CEFPython Issue Tracker.
26+
# -- Sequence of these dirs does matter, on first
27+
# -- match searching should be stopped.
28+
libdirs = ["/lib/x86_64-linux-gnu", "/usr/lib64",
29+
"/lib/i386-linux-gnu", "/usr/lib"]
30+
for libdir in libdirs:
31+
if os.path.exists(libdir+"/libudev.so.1") \
32+
and not os.path.exists(libdir+"/libudev.so.0"):
33+
libudev1 = "%s/libudev.so.1" % libdir
34+
libudev0 = "%s/libudev.so.0" % libdir
35+
print("[setup.py] ln -sf %s %s" % (libudev1, libudev0))
36+
subprocess.call("ln -sf %s %s" % (libudev1, libudev0), shell=True)
37+
break
38+
39+
# Find package directory.
40+
# Do not import from local cefpython3/ directory.
1541
del sys.path[0]
1642
sys.path.append('')
1743
import cefpython3
1844
package_dir = os.path.dirname(cefpython3.__file__)
19-
20-
# Make sure this is not a local package imported.
45+
46+
# Make sure this is not a local package imported
47+
print("[setup.py] package_dir = %s" % package_dir)
2148
assert not package_dir.startswith(
2249
os.path.dirname(os.path.abspath(__file__)))
2350

24-
# Chmod 755 executable files
51+
# Execute permissions for subprocess.exe and cefclient.exe
2552
subprocess_exe = os.path.join(package_dir, "subprocess")
2653
cefclient_exe = os.path.join(package_dir, "cefclient")
27-
print("chmod 755 "+subprocess_exe)
28-
subprocess.call("chmod 755 "+subprocess_exe, shell=True)
29-
print("chmod 755 "+cefclient_exe)
30-
subprocess.call("chmod 755 "+cefclient_exe, shell=True)
31-
32-
# Also chmod 777 the examples directory as "debug.log" file
33-
# is created when running examples.
34-
examples = os.path.join(package_dir, "examples")
35-
examples_wx = os.path.join(examples, "wx")
36-
print("chmod 777 "+examples)
37-
subprocess.call("chmod 777 "+examples, shell=True)
38-
print("chmod 777 "+examples_wx)
39-
subprocess.call("chmod 777 "+examples_wx, shell=True)
54+
print("[setup.py] chmod +x " + subprocess_exe)
55+
subprocess.call("chmod +x "+subprocess_exe, shell=True)
56+
print("[setup.py] chmod +x " + cefclient_exe)
57+
subprocess.call("chmod +x "+cefclient_exe, shell=True)
4058

4159
class install(_install):
4260
def run(self):
4361
_install.run(self)
44-
my_post_install()
45-
62+
post_install()
63+
4664
class BinaryDistribution(Distribution):
4765
def is_pure(self):
4866
return False
@@ -57,7 +75,7 @@ setup(
5775
author='Czarek Tomczak',
5876
author_email='czarek.tomczak@gmail.com',
5977
url='http://code.google.com/p/cefpython/',
60-
platforms=['%(PLATFORM)'],
78+
platforms=['%(PLATFORM)s'],
6179
packages=['cefpython3', 'cefpython3.wx'],
6280
package_data={'cefpython3': [
6381
'examples/*.py',
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
1. To install CEF Python 3 type:
22

3-
python setup.py install
3+
python setup.py install
44

55
2. In the same directory that setup.py resides there is
66
an examples/ directory, run some example scripts from there:
77

8-
cd examples/
9-
python wxpython.py
10-
python pyqt.py
11-
python pyside.py
12-
python pygtk_.py
13-
python pywin32.py
8+
cd examples/
9+
python wxpython.py
10+
python pyqt.py
11+
python pyside.py
12+
python pygtk_.py
13+
python pywin32.py
1414

15-
cd wx/
16-
python sample1.py
17-
python sample2.py
18-
python sample3.py
19-
20-
Note:
21-
Examples directory can also be found in the cefpython3 package directory:
22-
C:/python27/lib/site-packages/cefpython3/examples/
15+
cd wx/
16+
python sample1.py
17+
python sample2.py
18+
python sample3.py
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[bdist_wheel]
2-
python-tag=cp%(PY_VERSION_DIGITS_ONLY)
2+
python-tag=cp%(PY_VERSION_DIGITS_ONLY)s

cefpython/cef3/windows/installer/setup.py.template

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1-
from setuptools import setup
2-
from setuptools.command.install import install as _install
3-
from setuptools.dist import Distribution
1+
try:
2+
# The setuptools package is not installed by default
3+
# on a clean Ubuntu. Might be also a case on Windows.
4+
# Python Eggs and Wheels can be created only with setuptools.
5+
from setuptools import setup
6+
from setuptools.command.install import install as _install
7+
from setuptools.dist import Distribution
8+
print("[setup.py] Using setuptools")
9+
except:
10+
from distutils.core import setup
11+
from distutils.command.install import install as _install
12+
from distutils.dist import Distribution
13+
print("[setup.py] Using distutils")
14+
415
import sys
516
import os
617
import subprocess
718

8-
def my_post_install():
9-
print("my_post_install(): nothing to do")
19+
def post_install():
20+
""" Post install tasks """
21+
print("[setup.py] post_install()")
22+
# Nothing extra is required to do on Windows.
1023

1124
class install(_install):
1225
def run(self):
1326
_install.run(self)
14-
my_post_install()
27+
post_install()
1528

1629
class BinaryDistribution(Distribution):
1730
def is_pure(self):
@@ -27,7 +40,7 @@ setup(
2740
author='Czarek Tomczak',
2841
author_email='czarek.tomczak@gmail.com',
2942
url='http://code.google.com/p/cefpython/',
30-
platforms=['%(PLATFORM)'],
43+
platforms=['%(PLATFORM)s'],
3144
packages=['cefpython3', 'cefpython3.wx'],
3245
package_data={'cefpython3': [
3346
'examples/*.py',

0 commit comments

Comments
 (0)