From d8daed6ad44b999def1cd6cdd14162491a1ef23f Mon Sep 17 00:00:00 2001 From: Abdallah Ammar Date: Tue, 27 Aug 2024 08:59:15 +0200 Subject: [PATCH] detect py version for Makefile --- src/make_ninja.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/make_ninja.py b/src/make_ninja.py index 048acf0..d22ba52 100755 --- a/src/make_ninja.py +++ b/src/make_ninja.py @@ -193,10 +193,10 @@ lib_dirs = list(filter(lambda x: os.path.isdir(x) and \ def create_makefile_in_pydir(directory): - PYTHON_VERSION = "3.9" + PYTHON_VERSION = "{}.{}".format(sys.version_info.major, sys.version_info.minor) CC = "gcc" CCFLAGS = "$(shell python$(PYTHON_VERSION)-config --includes)" - LDFLAGS = "-shared -fPIC -L$(LDIR) -Wl,-rpath=$(LDIR) $(shell python$(PYTHON_VERSION)-config --ldflags) -lpython3" + LDFLAGS = "-shared -fPIC -L$(LDIR) -Wl,-rpath=$(LDIR) $(shell python$(PYTHON_VERSION)-config --ldflags)" lib_pydir = "lib{}_wrapper.so".format(directory) c_pydir = "{}_wrapper.c".format(directory) @@ -219,7 +219,7 @@ def create_makefile_in_pydir(directory): f.write("all: $(TARGETS)\n\n") f.write("$(LDIR)/{}: {}\n".format(lib_pydir, c_pydir)) - f.write("\t$(CC) $(CCFLAGS) $(LDFLAGS) {} -o $(LDIR)/{}\n\n".format(c_pydir, lib_pydir)) + f.write("\t$(CC) $(CCFLAGS) {} -o $(LDIR)/{} $(LDFLAGS)\n\n".format(c_pydir, lib_pydir)) f.write("{}_module.o: {}_module.f90\n".format(directory, directory)) f.write("\tgfortran -c {}_module.f90 -o {}_module.o -J.\n\n".format(directory, directory))