commit 4077f2e06859043c5881ee639b4649fc52dbce4e Author: Fabio Manganiello Date: Wed May 23 01:33:47 2018 +0200 First commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e35209 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +./__pycache__ +./include +./leap +./Leap.i.diff +./LeapPython.cpp +./LeapPython.h +./LeapPython.so +./Leap.py +./LeapSDK.tar.gz + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1562529 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +PREFIX := $(if $(PREFIX),$(PREFIX),/usr) +PYTHON3_VERSION := $(shell python3 --version | cut -d' ' -f 2 | cut -d. -f 1,2) +ARCH := $(shell uname -m | sed -e 's/x86_64/x64/') + +SDK_PATH=../../leap/LeapSDK + +all: + [ -f ./LeapSDK.tar.gz ] || wget -O LeapSDK.tar.gz $(SOURCE) + mkdir -p leap + tar xvf LeapSDK.tar.gz -C leap --strip-components 1 + cp -r $(SDK_PATH)/include ./include + wget http://tinyurl.com/leap-i-patch -O Leap.i.diff + patch -p0 < Leap.i.diff + swig -c++ -python -o LeapPython.cpp -interface LeapPython ./include/Leap.i + g++ -fPIC -I/usr/include/python$(PYTHON3_VERSION)m -I$(SDK_PATH)/include LeapPython.cpp $(SDK_PATH)/lib/$(ARCH)/libLeap.so -shared -o LeapPython.so + +clean: + rm -rf __pycache__ + rm -rf include + rm -rf leap + rm -f Leap.i.diff + rm -f LeapPython.cpp + rm -f LeapPython.h + rm -f LeapPython.so + rm -f Leap.py + rm -f LeapSDK.tar.gz + +install: + mkdir -p $(PREFIX)/lib/python$(PYTHON3_VERSION)/site-packages/ + install -m 0644 Leap.py $(PREFIX)/lib/python$(PYTHON3_VERSION)/site-packages/Leap.py + install -m 0755 LeapPython.so $(PREFIX)/lib/python$(PYTHON3_VERSION)/site-packages/LeapPython.so + install -m 0755 $(SDK_PATH)/lib/$(ARCH)/libLeap.so $(PREFIX)/lib/libLeap.so + +uninstall: + rm -f $(PREFIX)/lib/python$(PYTHON3_VERSION)/site-packages/Leap.py + rm -f $(PREFIX)/lib/python$(PYTHON3_VERSION)/site-packages/LeapPython.so + rm -f $(PREFIX)/lib/libLeap.so + diff --git a/README.md b/README.md new file mode 100644 index 0000000..f72fa05 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Leap Motion SDK Python 3 module builer + +The Leap Motion Python module is not [not officially compatible with Python 3](https://developer.leapmotion.com/documentation/python/devguide/Project_Setup.html#recompiling-leappython-for-python-3). + +This project aims to provide a simple and automated way to build and install your Python 3 module for the Leap Motion. + +## Dependencies + +- `swig` +- `g++` +- `libpython3-dev` (on Debian/Ubuntu) + +## Build the module + +```shell +make +``` + +## Install the module + +```shell +[sudo] make install +``` + +`PREFIX` (where both `libLeap.so` and the Python bindings will be installed) points to `/usr` by default. Change it if required: + +```shell +PREFIX=/your/local/prefix make install +``` + +## Clean the source directory + +```shell +make clean +``` + +## Uninstall the module + +```shell +[sudo] make uninstall +``` +