Skip to content

Commit

Permalink
Makefile: try to find the python wrapper on our own
Browse files Browse the repository at this point in the history
Not all distributions ship a version-agnostic python wrapper any more,
making a simple 'make' fail and require the user to provide the proper
python interpreter through the PYTHON make variable.

Instead try to find a matching python wrapper automatically by probing
the ones we do support.

Signed-off-by: Mathias Krause <[email protected]>
  • Loading branch information
minipli-oss committed Aug 28, 2023
1 parent f597ad1 commit 51af605
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ endif
LD := ld

NM := nm
PYTHON := python
PYTHON := $(shell tools/ci/get-python.sh)
SHELL := bash
RM := rm
LN := ln
Expand Down
20 changes: 20 additions & 0 deletions tools/ci/get-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
#
# Not all systems ship a 'python' wrapper, try version specific ones if we
# fail to find the version-agnostic one.
#
# Copyright (c) 2022 Open Source Security, Inc.

try_python() {
if $1 -c 'exit' 2>/dev/null; then
echo "$1"
exit 0
fi
}

try_python python
try_python python3
try_python python2

echo "error: python interpreter not found!" >&2
exit 1

0 comments on commit 51af605

Please sign in to comment.