Commits

Anonymous committed d263592

Add makefile and setup.py, now users can use following command to build python module:
"sudo ./setup.py install"

Comments (0)

Files changed (2)

+top_srcdir = `pwd`
+
+SUBDIRS = $(top_srcdir)/src
+
+all: build
+
+dist:
+	@echo "Creating dist..."
+	@python setup.py sdist
+
+bdist:
+	@echo "Creating bdist..."
+	@python setup.py bdist
+
+build:
+	@echo "Running build..."
+	@python setup.py build
+	@echo "Build finished, invoke 'make install' to install."
+
+install:
+	@echo "Installing..."
+	@python setup.py install 
+
+clean:
+	@echo "Cleaning up in $(top_srcdir)/ ..."
+	@rm -f *.cache *.core *~ MANIFEST
+	@rm -rf build dist
+
+	@for dir in $(SUBDIRS); do \
+		if test -f $$dir/Makefile; then \
+			make -C $$dir clean; \
+		else \
+			cd $$dir; \
+			echo "Cleaning up in $$dir..."; \
+			rm -f *~ *.cache *.core; \
+		fi \
+	done
+
+srcclean:
+	@echo "Cleaning up in $(top_srcdir)/ ..."
+	@rm -f *.cache *.core *~ MANIFEST
+	@rm -rf build dist
+
+	@for dir in $(SUBDIRS); do \
+		if test -f $$dir/Makefile; then \
+			make -C $$dir srcclean; \
+		else \
+			cd $$dir; \
+			echo "Cleaning up in $$dir..."; \
+			rm -f *~ *.cache *.core; \
+		fi \
+	done
+
+release: clean dist
+
+#!/usr/bin/env python
+
+from distutils.core import setup, Extension
+import os, glob
+
+
+def get_c_files ():
+    """Gets the list of files to use for building the module."""
+    files = glob.glob (os.path.join ("src", "*.c"))
+    return files
+
+if __name__ == "__main__":
+
+    extphysics = Extension ("physics", sources = get_c_files (),
+                            include_dirs = [ "include" ])
+
+    setupdata = {
+        "name" : "physics",
+        "version" : "0.0.1",
+        "description" : "blabla",
+        "license": "LGPL",
+        "packages" : [ "physics" ],
+        "package_dir" : { "physics" : "src" },
+        "ext_modules" : [ extphysics ],
+        }
+    setup (**setupdata)