Skip to content

Commit ff6e034

Browse files
Fix accidentally dropped support for libudev.so.0
1 parent ffbf1c9 commit ff6e034

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

setup.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
11
# -*- coding: utf-8 -*-
22

3+
import errno
4+
import subprocess
5+
36
from distutils.core import setup, Extension
47

8+
libudev_so = "libudev.so.1"
9+
10+
# Because libsuinput can be linked against both libudev.so.0 and
11+
# libudev.so.1, we try to use ldconfig to find out which one is
12+
# available. Preferably libudev.so.1.
13+
try:
14+
ldconfig_output = subprocess.check_output(["ldconfig", "-p"])
15+
for line in ldconfig_output.splitlines():
16+
17+
try:
18+
lib = line.split()[0]
19+
except IndexError:
20+
# An unexpected line, but let's proceed.
21+
continue
22+
23+
if lib == "libudev.so.0":
24+
libudev_so = lib
25+
# We are quite happy, but let's look if there's something
26+
# better.
27+
28+
if lib == "libudev.so.1":
29+
libudev_so = lib
30+
break # We are really happy, no reason to look further.
31+
except:
32+
# We don't care if something goes wrong while we scan through all
33+
# the available libraries. The whole scan operation is just
34+
# best-effort, we can always fall back to the default, hard-coded,
35+
# library.
36+
pass
37+
538
setup(name='python-uinput',
639
version='0.11.1',
740
description='Pythonic API to Linux uinput kernel module.',
@@ -36,5 +69,5 @@
3669
programmatically.
3770
""",
3871
ext_modules=[Extension('_libsuinput', ['libsuinput/src/suinput.c'],
39-
libraries=[":libudev.so.1"])]
72+
libraries=[":%s" % libudev_so])]
4073
)

0 commit comments

Comments
 (0)