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

embedding example

Windows fixing needs help
parent 0bf694af
PYVERSION = 2.2 # Makefile for creating our standalone Cython program
PYHOME = $(HOME)/pkg/python/$(PYVERSION) PYVERSION=2.3
PYARCH = $(PYHOME)/$(ARCH) PYPREFIX=/usr
PYINCLUDE = \ INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
-I$(PYHOME)/include/python$(PYVERSION) \
-I$(PYARCH)/include/python$(PYVERSION) embedded: embedded.o
PYLIB = -L$(PYARCH)/lib/python$(PYVERSION)/config \ gcc -o $@ $^ -lpython$(PYVERSION)
-lpython$(PYVERSION) \
-ldl -lpthread -lutil -lm
%.c: %.pyx embedded.o: embedded.c
../../bin/cython $< gcc -c $^ $(INCLUDES)
%.o: %.c embedded.c: embedded.pyx
gcc -c -fPIC $(PYINCLUDE) $< @python ../../cython.py --embed embedded.pyx
#%.so: %.o all: embedded
# gcc -shared $< -lm -o $@
all: main
main: main.o embedded.o
gcc main.o embedded.o $(PYLIB) -o main
clean: clean:
@echo Cleaning Demos/embed @echo Cleaning Demos/embed
@rm -f *~ *.o *.so core core.* embedded.h embedded.c main @rm -f *~ *.o *.so core core.* *.c embedded
embedded.h: embedded.c
main.o: embedded.h
PYVERSION = 2.2 # Makefile for creating our standalone Cython program
PYHOME = $(HOME)/pkg/python/$(PYVERSION) PYVERSION=2.3
PYARCH = $(PYHOME)/$(ARCH) PYPREFIX=/usr
PYINCLUDE = \ INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
-I$(PYHOME)/include/python$(PYVERSION) \
-I$(PYARCH)/include/python$(PYVERSION) embedded: embedded.o
PYLIB = -L$(PYARCH)/lib/python$(PYVERSION)/config \ gcc -o $@ $^ -lpython$(PYVERSION)
-lpython$(PYVERSION) \
-ldl -lpthread -lutil -lm
%.c: %.pyx embedded.o: embedded.c
../../bin/cython $< gcc -c $^ $(INCLUDES)
%.o: %.c embedded.c: embedded.pyx
gcc -c -fPIC $(PYINCLUDE) $< @python ../../cython.py --embed embedded.pyx
#%.so: %.o all: embedded
# gcc -shared $< -lm -o $@
all: main
main: main.o embedded.o
gcc main.o embedded.o $(PYLIB) -o main
clean: clean:
@echo Cleaning Demos/embed @echo Cleaning Demos/embed
@rm -f *~ *.o *.so core core.* embedded.h embedded.c main @rm -f *~ *.o *.so core core.* *.c embedded
embedded.h: embedded.c
main.o: embedded.h
cdef public void spam():
praise()
def praise(): print __name__
print "Spam, glorious spam!"
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