From b2b67d3220e1412467f611ec48738dc433a1976f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 2 Sep 2014 17:05:53 +0200 Subject: compile python files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- DEPENDENCIES | 1 + Makefile | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 49bdda7..e3d461b 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -6,6 +6,7 @@ RUNTIME DEPENDENCIES: BUILD DEPENDENCIES: + python3 libgamma>=0.3 make c99 diff --git a/Makefile b/Makefile index 4af3f3d..15c2b98 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,18 @@ LICENSEDIR ?= $(DATADIR)/licenses # The target and host platform PLATFORM = posix +# The major version number of the current Python installation +PY_MAJOR = 3 +# The minor version number of the current Python installation +PY_MINOR = 4 +# The version number of the current Python installation without a dot +PY_VER = $(PY_MAJOR)$(PY_MINOR) +# The version number of the current Python installation with a dot +PY_VERSION = $(PY_MAJOR).$(PY_MINOR) + +# The name of the package as it should be installed +PKGNAME = pylibgamma + # The installed pkg-config command PKGCONFIG ?= pkg-config @@ -50,8 +62,18 @@ LD_FLAGS = $$($(PKGCONFIG) --libs $(LIBS)) -lgamma -std=$(STD) \ $(OPTIMISE) -shared $(LDFLAGS) -.PHONY: all -all: $(foreach M,error facade method,bin/libgamma_native_$(M).so) +# The suffixless basename of the .py-files +PYTHON_SRC = libgamma_error libgamma_facade libgamma_method libgamma + +# The suffixless basename of the .py-files +CYTHON_SRC = libgamma_native_error libgamma_native_facade libgamma_native_method + + +.PHONY: all pyx-files py-files +all: pyc-files pyo-files so-files +pyc-files: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).pyc) +pyo-files: $(foreach M,$(PYTHON_SRC),src/__pycache__/$(M).cpython-$(PY_VER).pyo) +so-files: $(foreach M,$(CYTHON_SRC),bin/$(M).so) bin/%.so: obj/%.o @mkdir -p bin @@ -81,8 +103,14 @@ obj/libgamma_native_error.pyx: src/libgamma_native_error.pyx cp $< $@ endif +src/__pycache__/%.cpython-$(PY_VER).pyc: src/%.py + python -m compileall $< + +src/__pycache__/%.cpython-$(PY_VER).pyo: src/%.py + python -OO -m compileall $< + .PHONY: clean clean: - -rm -r obj bin + -rm -r obj bin src/__pycache__ -- cgit v1.2.3-70-g09d2