From e3d66733712e161d9287ea3f0116e5b57477b0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sun, 8 Jul 2018 12:19:16 +0200 Subject: python: Import improved python bindings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit imports the python bindings from: https://github.com/poljar/python-olm The bindings are imported at commit c44b145818520d69eaaa350fb95afcb846125e0f Minor modifications were made while importing: - Removed travis config - Removed Arch Linux PKGBUILD - Removed the html docs, they can be rebuild by running make html in the docs folder - Slightly modified the README The new bindings feature some improvements over the old ones: - Python 2 and 3 support - Automatic memory management - Automatic memory clearing before it is freed - Type signatures via the python typing module - Full test coverage - Properties are utilized where it makes sense (e.g. account.id) Signed-off-by: Damir Jelić --- python/Makefile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 python/Makefile (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile new file mode 100644 index 0000000..998d307 --- /dev/null +++ b/python/Makefile @@ -0,0 +1,35 @@ +PYTHON ?= python + +all: olm + +olm: + $(PYTHON) setup.py build + +install: olm + $(PYTHON) setup.py install --skip-build -O1 --root=$(DESTDIR) + +test: develop py2develop + python3 -m pytest + python2 -m pytest + python3 -m pytest --flake8 --benchmark-disable + python3 -m pytest --isort --benchmark-disable + python3 -m pytest --cov --cov-branch --benchmark-disable + +clean: + -rm -r python_olm.egg-info/ dist/ __pycache__/ + -rm *.so _libolm.o + -rm -r packages/ + -rm -r build/ + +develop: _libolm.o +py2develop: _libolm.so + +_libolm.so: include/olm/olm.h olm_build.py + python2 olm_build.py + -rm _libolm.c + +_libolm.o: include/olm/olm.h olm_build.py + python3 olm_build.py + -rm _libolm.c + +.PHONY: all olm install clean test develop -- cgit v1.2.3 From ac071d9c0d69e4330a06f171e3bddc713ecd97d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sun, 8 Jul 2018 12:19:17 +0200 Subject: python: Enable build with the local build of the Olm C library. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds the ability to build the bindings without having a globally installed Olm C library. Provided that the C library is already built, the tests can be run now with make test. Signed-off-by: Damir Jelić --- python/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index 998d307..2ab839c 100644 --- a/python/Makefile +++ b/python/Makefile @@ -3,7 +3,7 @@ PYTHON ?= python all: olm olm: - $(PYTHON) setup.py build + DEVELOP=$(DEVELOP) $(PYTHON) setup.py build install: olm $(PYTHON) setup.py install --skip-build -O1 --root=$(DESTDIR) @@ -24,12 +24,14 @@ clean: develop: _libolm.o py2develop: _libolm.so +_libolm.so: DEVELOP ?= 1 _libolm.so: include/olm/olm.h olm_build.py - python2 olm_build.py + DEVELOP=$(DEVELOP) python2 olm_build.py -rm _libolm.c +_libolm.o: DEVELOP ?= 1 _libolm.o: include/olm/olm.h olm_build.py - python3 olm_build.py + DEVELOP=$(DEVELOP) python3 olm_build.py -rm _libolm.c .PHONY: all olm install clean test develop -- cgit v1.2.3 From d4b2cce60345662512238f5e26bd4eff2d83ba4c Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Fri, 12 Oct 2018 18:53:18 -0400 Subject: generate python/include/olm/olm.h automatically --- python/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index 2ab839c..ad2621c 100644 --- a/python/Makefile +++ b/python/Makefile @@ -2,7 +2,11 @@ PYTHON ?= python all: olm -olm: +include/olm/olm.h: ../include/olm/olm.h ../include/olm/inbound_group_session.h ../include/olm/outbound_group_session.h + mkdir -p include/olm + $(CPP) -I dummy -I ../include ../include/olm/olm.h -o include/olm/olm.h + +olm: include/olm/olm.h DEVELOP=$(DEVELOP) $(PYTHON) setup.py build install: olm -- cgit v1.2.3 From 718763f8fc8c0650fd880b32fe9bbf931d7e2183 Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Fri, 12 Oct 2018 19:06:46 -0400 Subject: build and test improvements - build both Python2 and Python3 libs by default, and add separate rules building Python2 and Python. - use the libraries as built by setuptools, rather than building again separately --- python/Makefile | 60 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index ad2621c..a19c4f8 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,41 +1,41 @@ -PYTHON ?= python - -all: olm +all: olm-python2 olm-python3 include/olm/olm.h: ../include/olm/olm.h ../include/olm/inbound_group_session.h ../include/olm/outbound_group_session.h mkdir -p include/olm $(CPP) -I dummy -I ../include ../include/olm/olm.h -o include/olm/olm.h -olm: include/olm/olm.h - DEVELOP=$(DEVELOP) $(PYTHON) setup.py build - -install: olm - $(PYTHON) setup.py install --skip-build -O1 --root=$(DESTDIR) +olm-python2: include/olm/olm.h + DEVELOP=$(DEVELOP) python2 setup.py build -test: develop py2develop - python3 -m pytest - python2 -m pytest - python3 -m pytest --flake8 --benchmark-disable - python3 -m pytest --isort --benchmark-disable - python3 -m pytest --cov --cov-branch --benchmark-disable +olm-python3: include/olm/olm.h + DEVELOP=$(DEVELOP) python3 setup.py build -clean: - -rm -r python_olm.egg-info/ dist/ __pycache__/ - -rm *.so _libolm.o - -rm -r packages/ - -rm -r build/ +install: install-python2 install-python3 -develop: _libolm.o -py2develop: _libolm.so +install-python2: olm-python2 + python2 setup.py install --skip-build -O1 --root=$(DESTDIR) -_libolm.so: DEVELOP ?= 1 -_libolm.so: include/olm/olm.h olm_build.py - DEVELOP=$(DEVELOP) python2 olm_build.py - -rm _libolm.c +install-python3: olm-python3 + python3 setup.py install --skip-build -O1 --root=$(DESTDIR) -_libolm.o: DEVELOP ?= 1 -_libolm.o: include/olm/olm.h olm_build.py - DEVELOP=$(DEVELOP) python3 olm_build.py - -rm _libolm.c +test: olm-python2 olm-python3 + rm -rf install-temp + mkdir -p install-temp/2 install-temp/3 + PYTHONPATH=install-temp/2 python2 setup.py install --skip-build --install-lib install-temp/2 --install-script install-temp/bin + PYTHONPATH=install-temp/3 python3 setup.py install --skip-build --install-lib install-temp/3 --install-script install-temp/bin + PYTHONPATH=install-temp/3 python3 -m pytest + PYTHONPATH=install-temp/2 python2 -m pytest + PYTHONPATH=install-temp/3 python3 -m pytest --flake8 --benchmark-disable + PYTHONPATH=install-temp/3 python3 -m pytest --isort --benchmark-disable + PYTHONPATH=install-temp/3 python3 -m pytest --cov --cov-branch --benchmark-disable + rm -rf install-temp -.PHONY: all olm install clean test develop +clean: + rm -rf python_olm.egg-info/ dist/ __pycache__/ + rm -rf *.so _libolm.o + rm -rf packages/ + rm -rf build/ + rm -rf install-temp/ + rm -rf include/ + +.PHONY: all olm-python2 olm-python3 install install-python2 install-python3 clean test -- cgit v1.2.3 From 5ef6a844d6fd3d58d1eb85dcd188ac6b6baa3fbe Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Tue, 16 Oct 2018 00:31:56 -0400 Subject: overwrite buffers that may contain sensitive data also reduce the amount of memory copying that we do --- python/Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'python/Makefile') diff --git a/python/Makefile b/python/Makefile index a19c4f8..5da703a 100644 --- a/python/Makefile +++ b/python/Makefile @@ -3,6 +3,8 @@ all: olm-python2 olm-python3 include/olm/olm.h: ../include/olm/olm.h ../include/olm/inbound_group_session.h ../include/olm/outbound_group_session.h mkdir -p include/olm $(CPP) -I dummy -I ../include ../include/olm/olm.h -o include/olm/olm.h +# add memset to the header so that we can use it to clear buffers + echo 'void *memset(void *s, int c, size_t n);' >> include/olm/olm.h olm-python2: include/olm/olm.h DEVELOP=$(DEVELOP) python2 setup.py build -- cgit v1.2.3