summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Theodore <tonyt@logyst.com>2020-12-05 04:52:41 (GMT)
committerTony Theodore <tonyt@logyst.com>2020-12-10 01:38:39 (GMT)
commit22bde36de17ff465aa84dbb623cdd62ae326d062 (patch)
tree61cfafee7a9944624a87f42e272645ded0121533
parent8bf73adae06048fd504fa67bbb6b351bcf0d3356 (diff)
downloadmxe-22bde36de17ff465aa84dbb623cdd62ae326d062.zip
mxe-22bde36de17ff465aa84dbb623cdd62ae326d062.tar.gz
mxe-22bde36de17ff465aa84dbb623cdd62ae326d062.tar.bz2
Makefile & python-conf: improve 2/3 handling with wrapper script
- works with user's default python - can manually override PYTHON variable - installs libraries in mxe-local location (there are too many ways to manage python to document)
-rw-r--r--Makefile40
-rw-r--r--src/python-conf.mk21
2 files changed, 52 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 67ac12d..f758987 100644
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,7 @@ SHELL := bash
MXE_TMP := $(PWD)
+ORIG_PATH := $(call merge,:,$(filter-out $(PREFIX)/$(BUILD)/bin $(PREFIX)/bin,$(call split,:,$(PATH))))
BUILD_CC := $(shell (gcc --help >/dev/null 2>&1 && echo gcc) || (clang --help >/dev/null 2>&1 && echo clang))
BUILD_CXX := $(shell (g++ --help >/dev/null 2>&1 && echo g++) || (clang++ --help >/dev/null 2>&1 && echo clang++))
DATE := $(shell gdate --help >/dev/null 2>&1 && echo g)date
@@ -38,21 +39,42 @@ LIBTOOL := $(shell glibtool --help >/dev/null 2>&1 && echo g)libtool
LIBTOOLIZE := $(shell glibtoolize --help >/dev/null 2>&1 && echo g)libtoolize
OPENSSL := openssl
PATCH := $(shell gpatch --help >/dev/null 2>&1 && echo g)patch
-PYTHON2 := $(or $(shell ([ `python -c "import sys; print('{0[0]}'.format(sys.version_info))"` == 2 ] && echo python) 2>/dev/null || \
- which python2 2>/dev/null || \
- which python2.7 2>/dev/null), \
- $(warning Warning: python v2 not found (or default python changed to v3))\
- $(shell touch check-requirements-failed))
+PYTHON := $(shell PATH="$(ORIG_PATH)" which python)
+PY_XY_VER := $(shell $(PYTHON) -c "import sys; print('{0[0]}.{0[1]}'.format(sys.version_info))")
SED := $(shell gsed --help >/dev/null 2>&1 && echo g)sed
SORT := $(shell gsort --help >/dev/null 2>&1 && echo g)sort
DEFAULT_UA := $(shell wget --version | $(SED) -n 's,GNU \(Wget\) \([0-9.]*\).*,\1/\2,p')
WGET_TOOL = wget
WGET = $(WGET_TOOL) --user-agent='$(or $($(1)_UA),$(DEFAULT_UA))' -t 2 --timeout=6
-REQUIREMENTS := autoconf automake autopoint bash bison bzip2 flex \
- $(BUILD_CC) $(BUILD_CXX) gperf intltoolize $(LIBTOOL) \
- $(LIBTOOLIZE) lzip $(MAKE) $(OPENSSL) $(PATCH) $(PERL) python \
- ruby $(SED) $(SORT) unzip wget xz 7za gdk-pixbuf-csource
+REQUIREMENTS := \
+ 7za \
+ autoconf \
+ automake \
+ autopoint \
+ bash \
+ bison \
+ $(BUILD_CC) \
+ $(BUILD_CXX) \
+ bzip2 \
+ flex \
+ gdk-pixbuf-csource \
+ gperf \
+ intltoolize \
+ $(LIBTOOL) \
+ $(LIBTOOLIZE) \
+ lzip \
+ $(MAKE) \
+ $(OPENSSL) \
+ $(PATCH) \
+ perl \
+ $(PYTHON) \
+ ruby \
+ $(SED) \
+ $(SORT) \
+ unzip \
+ wget \
+ xz
PREFIX := $(PWD)/usr
LOG_DIR := $(PWD)/log
diff --git a/src/python-conf.mk b/src/python-conf.mk
new file mode 100644
index 0000000..6cd8379
--- /dev/null
+++ b/src/python-conf.mk
@@ -0,0 +1,21 @@
+# This file is part of MXE. See LICENSE.md for licensing information.
+
+PKG := python-conf
+$(PKG)_VERSION := 1
+$(PKG)_UPDATE := echo 1
+$(PKG)_TARGETS := $(BUILD)
+
+PYTHON_SETUP_INSTALL = \
+ cd '$(SOURCE_DIR)' && $(BUILD)-python$(PY_XY_VER) setup.py install \
+ --prefix='$(PREFIX)/$(TARGET)'
+
+define $(PKG)_BUILD_$(BUILD)
+ #create python wrapper in a directory which is in PATH
+ (echo '#!/bin/sh'; \
+ echo 'PYTHONPATH="$(PREFIX)/$(TARGET)/lib/python$(PY_XY_VER)/site-packages" \
+ exec $(PYTHON) "$$@"';) \
+ > '$(PREFIX)/bin/$(TARGET)-python$(PY_XY_VER)'
+ chmod 0755 '$(PREFIX)/bin/$(TARGET)-python$(PY_XY_VER)'
+
+ mkdir -p "$(PREFIX)/$(TARGET)/lib/python$(PY_XY_VER)/site-packages"
+endef