Răsfoiți Sursa

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.
Benno Evers 5 ani în urmă
părinte
comite
bf2be71082
1 a modificat fișierele cu 5 adăugiri și 2 ștergeri
  1. 5 2
      Makefile

+ 5 - 2
Makefile

@@ -2,11 +2,14 @@
 CXXFLAGS += -std=c++11 -Wno-conversion
 
 # Default to using system's default version of python
-PYTHON_BIN     ?= python
+PYTHON_BIN     ?= python3
 PYTHON_CONFIG  := $(PYTHON_BIN)-config
 PYTHON_INCLUDE ?= $(shell $(PYTHON_CONFIG) --includes)
 EXTRA_FLAGS    := $(PYTHON_INCLUDE)
-LDFLAGS        += $(shell $(PYTHON_CONFIG) --libs)
+# NOTE: Since python3.8, the correct invocation is `python3-config --libs --embed`. 
+# So of course the proper way to get python libs for embedding now is to
+# invoke that, check if it crashes, and fall back to just `--libs` if it does.
+LDFLAGS        += $(shell if $(PYTHON_CONFIG) --libs --embed >/dev/null; then $(PYTHON_CONFIG) --libs --embed; else $(PYTHON_CONFIG) --libs; fi)
 
 # Either finds numpy or set -DWITHOUT_NUMPY
 EXTRA_FLAGS     += $(shell $(PYTHON_BIN) $(CURDIR)/numpy_flags.py)