Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf2be71

Browse files
committed
Update python-config invocation in Makefile
Since the new Ubuntu 20.04 LTS version is shipping python3.8 as the default python, update the Makefile to use that as default and more importantly fix the python-config invocation to work with all python versions.
1 parent ecf3a8d commit bf2be71

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
CXXFLAGS += -std=c++11 -Wno-conversion
33

44
# Default to using system's default version of python
5-
PYTHON_BIN ?= python
5+
PYTHON_BIN ?= python3
66
PYTHON_CONFIG := $(PYTHON_BIN)-config
77
PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes)
88
EXTRA_FLAGS := $(PYTHON_INCLUDE)
9-
LDFLAGS += $(shell $(PYTHON_CONFIG) --libs)
9+
# NOTE: Since python3.8, the correct invocation is `python3-config --libs --embed`.
10+
# So of course the proper way to get python libs for embedding now is to
11+
# invoke that, check if it crashes, and fall back to just `--libs` if it does.
12+
LDFLAGS += $(shell if $(PYTHON_CONFIG) --libs --embed >/dev/null; then $(PYTHON_CONFIG) --libs --embed; else $(PYTHON_CONFIG) --libs; fi)
1013

1114
# Either finds numpy or set -DWITHOUT_NUMPY
1215
EXTRA_FLAGS += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py)

0 commit comments

Comments
 (0)