Commit 9ad9a05e authored by Robert Bradshaw's avatar Robert Bradshaw

embedding example

Windows fixing needs help
parent 0bf694af
PYVERSION = 2.2
PYHOME = $(HOME)/pkg/python/$(PYVERSION)
PYARCH = $(PYHOME)/$(ARCH)
PYINCLUDE = \
-I$(PYHOME)/include/python$(PYVERSION) \
-I$(PYARCH)/include/python$(PYVERSION)
PYLIB = -L$(PYARCH)/lib/python$(PYVERSION)/config \
-lpython$(PYVERSION) \
-ldl -lpthread -lutil -lm
# Makefile for creating our standalone Cython program
PYVERSION=2.3
PYPREFIX=/usr
INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
%.c: %.pyx
../../bin/cython $<
embedded: embedded.o
gcc -o $@ $^ -lpython$(PYVERSION)
%.o: %.c
gcc -c -fPIC $(PYINCLUDE) $<
embedded.o: embedded.c
gcc -c $^ $(INCLUDES)
#%.so: %.o
# gcc -shared $< -lm -o $@
embedded.c: embedded.pyx
@python ../../cython.py --embed embedded.pyx
all: main
main: main.o embedded.o
gcc main.o embedded.o $(PYLIB) -o main
all: embedded
clean:
@echo Cleaning Demos/embed
@rm -f *~ *.o *.so core core.* embedded.h embedded.c main
embedded.h: embedded.c
main.o: embedded.h
@rm -f *~ *.o *.so core core.* *.c embedded
PYVERSION = 2.2
PYHOME = $(HOME)/pkg/python/$(PYVERSION)
PYARCH = $(PYHOME)/$(ARCH)
PYINCLUDE = \
-I$(PYHOME)/include/python$(PYVERSION) \
-I$(PYARCH)/include/python$(PYVERSION)
PYLIB = -L$(PYARCH)/lib/python$(PYVERSION)/config \
-lpython$(PYVERSION) \
-ldl -lpthread -lutil -lm
# Makefile for creating our standalone Cython program
PYVERSION=2.3
PYPREFIX=/usr
INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
%.c: %.pyx
../../bin/cython $<
embedded: embedded.o
gcc -o $@ $^ -lpython$(PYVERSION)
%.o: %.c
gcc -c -fPIC $(PYINCLUDE) $<
embedded.o: embedded.c
gcc -c $^ $(INCLUDES)
#%.so: %.o
# gcc -shared $< -lm -o $@
embedded.c: embedded.pyx
@python ../../cython.py --embed embedded.pyx
all: main
main: main.o embedded.o
gcc main.o embedded.o $(PYLIB) -o main
all: embedded
clean:
@echo Cleaning Demos/embed
@rm -f *~ *.o *.so core core.* embedded.h embedded.c main
embedded.h: embedded.c
main.o: embedded.h
@rm -f *~ *.o *.so core core.* *.c embedded
cdef public void spam():
praise()
def praise():
print "Spam, glorious spam!"
print __name__
if __name__ == "__main__":
print "Hi, I'm embedded."
else:
print "I'm being imported."
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment