Skip to content

Commit

Permalink
respect CPATH/C_INCLUDE_PATH
Browse files Browse the repository at this point in the history
Flags are hard to pass when python-evdev is installed as part of another
python library. Instead evdev should check standard environment
variables that also a C compiler would use to locate a header file.

See: https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html

Update setup.py

Co-authored-by: Tobi <[email protected]>
  • Loading branch information
Mic92 and Tobi committed Dec 4, 2023
1 parent 2dd6ce6 commit bedcfbf
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@
#-----------------------------------------------------------------------------
def create_ecodes(headers=None):
if not headers:
headers = [
'/usr/include/linux/input.h',
'/usr/include/linux/input-event-codes.h',
'/usr/include/linux/uinput.h',
]
include_paths = set()
if os.environ.get("CPATH", "").strip() != "":
include_paths.update(os.environ["CPATH"].split(":"))
if os.environ.get("C_INCLUDE_PATH", "").strip() != "":
include_paths.update(os.environ["C_INCLUDE_PATH"].split(":"))
include_paths.add("/usr/include")
files = ["linux/input.h", "linux/input-event-codes.h", "linux/uinput.h"]
headers = [os.path.join(path, file) for path in include_paths for file in files]

headers = [header for header in headers if os.path.isfile(header)]
if not headers:
Expand Down

0 comments on commit bedcfbf

Please sign in to comment.