|
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 | + |
4 | 15 | import sys |
5 | 16 | import os |
6 | 17 | import subprocess |
7 | 18 |
|
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()") |
10 | 22 |
|
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. |
15 | 41 | del sys.path[0] |
16 | 42 | sys.path.append('') |
17 | 43 | import cefpython3 |
18 | 44 | 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) |
21 | 48 | assert not package_dir.startswith( |
22 | 49 | os.path.dirname(os.path.abspath(__file__))) |
23 | 50 |
|
24 | | - # Chmod 755 executable files |
| 51 | + # Execute permissions for subprocess.exe and cefclient.exe |
25 | 52 | subprocess_exe = os.path.join(package_dir, "subprocess") |
26 | 53 | 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) |
40 | 58 |
|
41 | 59 | class install(_install): |
42 | 60 | def run(self): |
43 | 61 | _install.run(self) |
44 | | - my_post_install() |
45 | | - |
| 62 | + post_install() |
| 63 | + |
46 | 64 | class BinaryDistribution(Distribution): |
47 | 65 | def is_pure(self): |
48 | 66 | return False |
|
57 | 75 | author='Czarek Tomczak', |
58 | 76 | author_email='czarek.tomczak@gmail.com', |
59 | 77 | url='http://code.google.com/p/cefpython/', |
60 | | - platforms=['%(PLATFORM)'], |
| 78 | + platforms=['%(PLATFORM)s'], |
61 | 79 | packages=['cefpython3', 'cefpython3.wx'], |
62 | 80 | package_data={'cefpython3': [ |
63 | 81 | 'examples/*.py', |
|
0 commit comments