aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGus Smith <gus@normalcomputing.ai>2026-05-29 10:26:32 -0700
committerGus Smith <gus@normalcomputing.ai>2026-05-29 10:26:32 -0700
commitac29b5a73986bf6c9413751078c9a234842bcbe4 (patch)
treea59924bc1d0991fcdf5ebcd60dbe0858881bf44a
parent45dc9b808298c237af404e45111833526e8151c0 (diff)
downloaddram-bender-ac29b5a73986bf6c9413751078c9a234842bcbe4.tar.gz
Try a different approach via setup.py
-rw-r--r--sources/api/pySoftMC/Makefile16
-rw-r--r--sources/api/pySoftMC/setup.py22
2 files changed, 29 insertions, 9 deletions
diff --git a/sources/api/pySoftMC/Makefile b/sources/api/pySoftMC/Makefile
index b03b1a9..f7620f4 100644
--- a/sources/api/pySoftMC/Makefile
+++ b/sources/api/pySoftMC/Makefile
@@ -4,16 +4,14 @@ program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
program_CXX_OBJS := ${program_CXX_OBJS:.c=.o}
program_OBJS := $(program_CXX_OBJS)
-python_INCLUDE_FLAGS := $(shell python3-config --includes)
+PYTHON_INCLUDES ?= $(shell python3-config --includes)
+PYTHON_LDFLAGS ?= $(shell python3-config --ldflags --embed 2>/dev/null || python3-config --ldflags)
+PYTHON_EXT_SUFFIX ?= $(PYTHON_EXT_SUFFIX)
program_INCLUDE_DIRS := . .. ../ext/pybind11/include
-program_LIBRARY_DIRS :=
-program_LIBRARIES :=
CPPFLAGS += -g -std=c++14 -pthread -O3 -fPIC -Wall
-CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir)) $(python_INCLUDE_FLAGS) -DPYSMC
-LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
-LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
-LDFLAGS += $(shell python3-config --ldflags --embed 2>/dev/null || python3-config --ldflags)
+CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir)) $(PYTHON_INCLUDES) -DPYSMC
+LDFLAGS += $(PYTHON_LDFLAGS)
SHARED_LIB_FLAGS := -shared -fPIC
@@ -25,10 +23,10 @@ all: $(program_NAME)
@- $(RM) $(program_OBJS)
$(program_NAME): $(program_OBJS)
- $(CC) $(CPPFLAGS) ${SHARED_LIB_FLAGS} $(program_OBJS) -o $(program_NAME)$(shell python3-config --extension-suffix) $(LDFLAGS)
+ $(CC) $(CPPFLAGS) ${SHARED_LIB_FLAGS} $(program_OBJS) -o $(program_NAME)$(PYTHON_EXT_SUFFIX) $(LDFLAGS)
clean:
- @- $(RM) $(program_NAME)$(shell python3-config --extension-suffix)
+ @- $(RM) $(program_NAME)$(PYTHON_EXT_SUFFIX)
@- $(RM) $(program_OBJS)
distclean: clean
diff --git a/sources/api/pySoftMC/setup.py b/sources/api/pySoftMC/setup.py
new file mode 100644
index 0000000..c353396
--- /dev/null
+++ b/sources/api/pySoftMC/setup.py
@@ -0,0 +1,22 @@
+from setuptools import setup, Extension
+import os
+
+here = os.path.dirname(os.path.abspath(__file__))
+api_dir = os.path.join(here, "..")
+pybind11_include = os.path.join(here, "../ext/pybind11/include")
+
+ext = Extension(
+ "pySoftMC",
+ sources=[
+ os.path.join(api_dir, "board.cpp"),
+ os.path.join(api_dir, "instruction.cpp"),
+ os.path.join(api_dir, "platform.cpp"),
+ os.path.join(api_dir, "prog.cpp"),
+ os.path.join(here, "pySoftMC.cpp"),
+ ],
+ include_dirs=[here, api_dir, pybind11_include],
+ language="c++",
+ extra_compile_args=["-std=c++14", "-pthread", "-O3", "-DPYSMC"],
+)
+
+setup(name="pySoftMC", ext_modules=[ext])