From 299518f194c7144d6db273555222ecea49da0c16 Mon Sep 17 00:00:00 2001 From: Sylvain Tricot Date: Mon, 22 Feb 2021 20:28:13 +0100 Subject: [PATCH] Add rule to Makefile to build wxPython --- .gitignore | 2 +- Makefile | 52 ++++++++++++++++++++++++++--------------------- src/options.mk | 55 ++++++++++++++++++++++++++++++++++++++++++-------- src/pip.freeze | 2 -- 4 files changed, 77 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index fa61c21..1c4be1a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ htmlcov package/ src/msspec/results.txt *venv/ -**/*build/ +**/*build*/ **/*dist/ **/*.egg-info/ .ropeproject diff --git a/Makefile b/Makefile index 760ecab..c8e4e4d 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,49 @@ include src/options.mk -PYTHON = python -PYMAJ = 3 -PYMIN = 6 - -# Checking Python path and version -PYTHON_EXE := $(shell command -v $(PYTHON) 2> /dev/null) - -ifndef PYTHON_EXE - $(error Unable to find the $(PYTHON) executable!) -endif - -ifeq ($(shell $(PYTHON_EXE) -c "import sys; exit(sys.version_info >= ($(PYMAJ),$(PYMIN)))"; echo $$?),0) - $(error Python version >= $(PYMAJ).$(PYMIN) is needed!) -endif - .PHONY: pybinding install devel venv doc clean pybinding: - @+. $(VENV_PATH)/bin/activate && $(MAKE) -C src pybinding + @+$(INSIDE_VENV) $(MAKE) -C src pybinding venv: +ifeq ($(NO_VENV),0) @virtualenv --python=$(PYTHON_EXE) --prompt="(msspec-$(VERSION)) " $(VENV_PATH) - @. $(VENV_PATH)/bin/activate && pip install --upgrade pip && pip install -r src/pip.freeze + @$(INSIDE_VENV) pip install --upgrade pip && pip install -r src/pip.freeze +endif -install: venv pybinding - @+. $(VENV_PATH)/bin/activate && $(MAKE) -C src sdist - @+. $(VENV_PATH)/bin/activate && $(MAKE) -C src frontend - @+. $(VENV_PATH)/bin/activate && pip install src/dist/msspec-$(VERSION).tar.gz +install: venv pybinding wx + @+$(INSIDE_VENV) $(MAKE) -C src sdist + @+$(INSIDE_VENV) $(MAKE) -C src frontend + @+$(INSIDE_VENV) pip install src/dist/msspec-$(VERSION).tar.gz @echo "Do not forget to check that $(INSTALL_PREFIX)/bin is set in your \$$PATH" devel: VENV_PATH = ./_venv -devel: venv pybinding - @. $(VENV_PATH)/bin/activate && pip install -e src/ +devel: venv pybinding wx + @$(INSIDE_VENV) pip install -e src/ + + +wx: + @echo "Building wxPython for your `python --version` under Linux $(DISTRO_RELEASE)..." + # Create a folder to build wx into + @mkdir -p _build_wx + # download the wheel or the source if it cannot find a wheel + @$(INSIDE_VENV) cd _build_wx && pip download -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/$(DISTRO_RELEASE) wxPython + # Build the source if a tar.gz was downloaded + @$(INSIDE_VENV) cd _build_wx && \ + if [ -e wxPython*.tar.gz ]; then \ + tar -x --skip-old-files -vzf wxPython*.tar.gz; \ + cd `ls -d wxPython*/`; \ + pip install requests; \ + python build.py dox etg --nodoc sip build bdist_wheel; \ + ln -s `readlink -f dist/wxPython*.whl` ../; \ + fi; + # Install the wheel + @$(INSIDE_VENV) cd _build_wx && pip install wxPython*.whl doc: diff --git a/src/options.mk b/src/options.mk index bec887b..a3dcb85 100644 --- a/src/options.mk +++ b/src/options.mk @@ -1,6 +1,11 @@ +PYTHON = python +PYMAJ = 3 +PYMIN = 6 + FC = gfortran F2PY = f2py3 +NO_VENV = 0 DEBUG = 0 VERBOSE = 0 BUILDDIR = ./build @@ -40,27 +45,61 @@ F2PYFLAGS_DBG = --debug-capi --debug VERSION:=$(shell git describe|sed 's/-\([[:digit:]]\+\)-.*/\.post\1/') VENV_PATH := $(INSTALL_PREFIX)/src/msspec_venv_$(VERSION) -ifeq ($(VERBOSE),0) - OUPUT_REDIRECTION := 1>/dev/null 2>/dev/null - MAKEFLAGS = -s --no-print-directory + +# Checking Python path and version +PYTHON_EXE := $(shell command -v $(PYTHON) 2> /dev/null) + +ifndef PYTHON_EXE + $(error Unable to find the $(PYTHON) executable!) +endif + +ifeq ($(shell $(PYTHON_EXE) -c "import sys; exit(sys.version_info >= ($(PYMAJ),$(PYMIN)))"; echo $$?),0) + $(error Python version >= $(PYMAJ).$(PYMIN) is needed!) +endif + +# Checking your distribution type and release +LSB_RELEASE := $(shell command -v lsb_release 2> /dev/null) +DISTRO_RELEASE = + +ifdef LSB_RELEASE + DISTRO_RELEASE = $(shell echo $(shell $(LSB_RELEASE) -s -i)-$(shell $(LSB_RELEASE) -s -r) | tr [:upper:] [:lower:] ) +endif + +ifndef DISTRO_RELEASE + $(warning Unable to guess your OS name and version) +endif + +# Define the INSIDE_VENV variable +ifeq ($(NO_VENV), 1) + INSIDE_VENV = else - OUPUT_REDIRECTION:= - MAKEFLAGS += --debug=b + INSIDE_VENV = . $(VENV_PATH)/bin/activate && +endif + + + + +ifeq ($(VERBOSE),0) + OUPUT_REDIRECTION := 1>/dev/null 2>/dev/null + MAKEFLAGS = -s --no-print-directory +else + OUPUT_REDIRECTION:= + MAKEFLAGS += --debug=b endif PREFIX= SUFFIX= ifeq ($(FC),gfortran) - PREFIX = GFORTRAN + PREFIX = GFORTRAN endif ifeq ($(FC),IFORT) - PREFIX = IFORT + PREFIX = IFORT endif ifeq ($(DEBUG),1) - SUFFIX = _DBG + SUFFIX = _DBG endif FFLAGS = $($(PREFIX)_FFLAGS$(SUFFIX)) diff --git a/src/pip.freeze b/src/pip.freeze index 8502bcf..75bd840 100644 --- a/src/pip.freeze +++ b/src/pip.freeze @@ -9,5 +9,3 @@ pycairo scipy setuptools-scm terminaltables -#wxPython@https://extras.wxpython.org/wxPython4/extras/linux/gtk3/debian-10/wxPython-4.1.0-cp37-cp37m-linux_x86_64.whl -#wxPython@https://extras.wxpython.org/wxPython4/extras/linux/gtk3/debian-9/wxPython-4.0.7.post2-cp35-cp35m-linux_x86_64.whl