Merge pull request #396 from commodo/python-migration
python: import from old packages and update to version 3.4
This commit is contained in:
commit
85695f4561
4 changed files with 320 additions and 0 deletions
199
lang/python/Makefile
Normal file
199
lang/python/Makefile
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2006-2014 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
# The file included below defines PYTHON_VERSION
|
||||||
|
-include $(if $(DUMP),,./files/python-package.mk)
|
||||||
|
|
||||||
|
PKG_NAME:=python
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
|
||||||
|
|
||||||
|
PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
|
||||||
|
PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)
|
||||||
|
PKG_MD5SUM:=6cafc183b4106476dd73d5738d7f616a
|
||||||
|
|
||||||
|
PKG_LICENSE:=PSF
|
||||||
|
PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE
|
||||||
|
|
||||||
|
PKG_INSTALL:=1
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
HOST_BUILD_PARALLEL:=1
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
|
||||||
|
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
|
||||||
|
|
||||||
|
PKG_BUILD_DEPENDS:=python/host
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/host-build.mk
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define Package/python/Default
|
||||||
|
SUBMENU:=Python
|
||||||
|
SECTION:=lang
|
||||||
|
CATEGORY:=Languages
|
||||||
|
TITLE:=Python $(PYTHON_VERSION) programming language
|
||||||
|
URL:=http://www.python.org/
|
||||||
|
MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/python/Default/description
|
||||||
|
Python is a dynamic object-oriented programming language that can be used
|
||||||
|
for many kinds of software development. It offers strong support for
|
||||||
|
integration with other languages and tools, comes with extensive standard
|
||||||
|
libraries, and can be learned in a few days. Many Python programmers
|
||||||
|
report substantial productivity gains and feel the language encourages
|
||||||
|
the development of higher quality, more maintainable code.
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/python
|
||||||
|
$(call Package/python/Default)
|
||||||
|
DEPENDS:=+libpthread +zlib +libffi
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/python/description
|
||||||
|
$(call Package/python/Default/description)
|
||||||
|
.
|
||||||
|
This package contains only the interpreter and the bare minimum for the interpreter to start.
|
||||||
|
endef
|
||||||
|
|
||||||
|
MAKE_FLAGS:=\
|
||||||
|
$(TARGET_CONFIGURE_OPTS) \
|
||||||
|
DESTDIR="$(PKG_INSTALL_DIR)" \
|
||||||
|
CROSS_COMPILE=yes \
|
||||||
|
CFLAGS="$(TARGET_CFLAGS) -DNDEBUG -fno-inline" \
|
||||||
|
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||||
|
LD="$(TARGET_CC)"
|
||||||
|
|
||||||
|
ENABLE_IPV6:=
|
||||||
|
ifeq ($(CONFIG_IPV6),y)
|
||||||
|
ENABLE_IPV6 += --enable-ipv6
|
||||||
|
endif
|
||||||
|
|
||||||
|
#=======================================================================
|
||||||
|
# Notes: adding these so that I don't forget, and can track why stuff
|
||||||
|
# was did as was did
|
||||||
|
# - Arguments below were moved to ./files/config.site file, and disabled
|
||||||
|
# ac_cv_have_chflags=no \
|
||||||
|
# ac_cv_have_lchflags=no \
|
||||||
|
# ac_cv_py_format_size_t=no \
|
||||||
|
# ac_cv_have_long_long_format=yes \
|
||||||
|
# ac_cv_buggy_getaddrinfo=no \
|
||||||
|
# - --without-ensurepip added, because the build wants to ensure that
|
||||||
|
# it works; that's a good idea, but for now, it requires special
|
||||||
|
# setup, and we can do that later
|
||||||
|
# - --without-pymalloc added, becase in Python 3, modules are suffixed
|
||||||
|
# with m; e.g. so some paths are python3.4m instead of python3.4
|
||||||
|
# all this is detailed here:
|
||||||
|
# http://legacy.python.org/dev/peps/pep-3149/
|
||||||
|
#=======================================================================
|
||||||
|
|
||||||
|
define Build/Configure
|
||||||
|
-$(MAKE) -C $(PKG_BUILD_DIR) distclean
|
||||||
|
(cd $(PKG_BUILD_DIR); autoreconf --force --install || exit 0)
|
||||||
|
# The python executable needs to stay in the rootdir since its location will
|
||||||
|
# be used to compute the path of the config files.
|
||||||
|
$(CP) ./files/config.site $(PKG_BUILD_DIR)
|
||||||
|
$(call Build/Configure/Default, \
|
||||||
|
--sysconfdir=/etc \
|
||||||
|
--disable-shared \
|
||||||
|
--without-cxx-main \
|
||||||
|
--with-threads \
|
||||||
|
--with-system-ffi="$(STAGING_DIR)/usr" \
|
||||||
|
--without-ensurepip \
|
||||||
|
--without-pymalloc \
|
||||||
|
$(ENABLE_IPV6) \
|
||||||
|
CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
|
||||||
|
OPT="$(TARGET_CFLAGS)" \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/InstallDev
|
||||||
|
$(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
|
||||||
|
$(INSTALL_DIR) $(STAGING_DIR)/mk/
|
||||||
|
$(INSTALL_DATA) ./files/python-package.mk $(STAGING_DIR)/mk/
|
||||||
|
$(CP) \
|
||||||
|
$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
|
||||||
|
$(1)/usr/include/
|
||||||
|
$(CP) \
|
||||||
|
$(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
|
||||||
|
$(PKG_BUILD_DIR)/libpython$(PYTHON_VERSION).a \
|
||||||
|
$(1)/usr/lib/
|
||||||
|
$(CP) \
|
||||||
|
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
|
||||||
|
$(1)/usr/lib/python$(PYTHON_VERSION)/
|
||||||
|
|
||||||
|
$(CP) \
|
||||||
|
$(STAGING_DIR_HOST)/bin/python$(PYTHON_VERSION)-config \
|
||||||
|
$(2)/bin/
|
||||||
|
$(SED) 's,^#!.*,#!/usr/bin/env python$(PYTHON_VERSION),g' $(2)/bin/python$(PYTHON_VERSION)-config
|
||||||
|
|
||||||
|
(cd $(2)/bin; \
|
||||||
|
ln -sf python$(PYTHON_VERSION)-config python-config;)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define PyPackage/python/filespec
|
||||||
|
+|/usr/bin/python$(PYTHON_VERSION)
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/encodings
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/_weakrefset.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/abc.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/codecs.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/genericpath.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/io.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/os.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/posixpath.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/site.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/sysconfig.py
|
||||||
|
+|/usr/lib/python$(PYTHON_VERSION)/stat.py
|
||||||
|
endef
|
||||||
|
|
||||||
|
define PyPackage/python/install
|
||||||
|
# Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
|
||||||
|
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
|
||||||
|
ln -sf python$(PYTHON_VERSION) $(1)/usr/bin/python
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Host/Configure
|
||||||
|
-$(MAKE) -C $(HOST_BUILD_DIR) distclean
|
||||||
|
(cd $(HOST_BUILD_DIR); autoreconf --force --install || exit 0)
|
||||||
|
(cd $(HOST_BUILD_DIR); \
|
||||||
|
rm -rf config.cache; \
|
||||||
|
CONFIG_SITE= \
|
||||||
|
OPT="$(HOST_CFLAGS)" \
|
||||||
|
./configure \
|
||||||
|
--without-cxx-main \
|
||||||
|
--without-ensurepip \
|
||||||
|
--without-pymalloc \
|
||||||
|
--with-threads \
|
||||||
|
--prefix=$(STAGING_DIR_HOST); \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Host/Compile
|
||||||
|
+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
|
||||||
|
python Parser/pgen
|
||||||
|
+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
|
||||||
|
sharedmods
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Host/Install
|
||||||
|
$(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
|
||||||
|
$(MAKE) -C $(HOST_BUILD_DIR) \
|
||||||
|
install
|
||||||
|
$(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/
|
||||||
|
endef
|
||||||
|
|
||||||
|
|
||||||
|
$(eval $(call HostBuild))
|
||||||
|
|
||||||
|
$(eval $(call PyPackage,python))
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,python))
|
18
lang/python/files/config.site
Normal file
18
lang/python/files/config.site
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2007-2014 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
ac_cv_file__dev_ptmx=yes
|
||||||
|
ac_cv_file__dev_ptc=no
|
||||||
|
|
||||||
|
# FIXME: moved from Makefile here
|
||||||
|
#ac_cv_have_chflags=no \
|
||||||
|
#ac_cv_have_lchflags=no \
|
||||||
|
#ac_cv_py_format_size_t=no \
|
||||||
|
#ac_cv_have_long_long_format=yes \
|
||||||
|
#ac_cv_buggy_getaddrinfo=no \
|
||||||
|
|
78
lang/python/files/python-package.mk
Normal file
78
lang/python/files/python-package.mk
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#
|
||||||
|
# Copyright (C) 2007-2014 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
PYTHON_VERSION=3.4
|
||||||
|
PYTHON_VERSION_MICRO=1
|
||||||
|
|
||||||
|
PYTHON_DIR:=$(STAGING_DIR)/usr
|
||||||
|
PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
|
||||||
|
PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
|
||||||
|
PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
|
||||||
|
|
||||||
|
PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
|
||||||
|
|
||||||
|
PYTHON:=python$(PYTHON_VERSION)
|
||||||
|
|
||||||
|
HOST_PYTHON_BIN:=$(STAGING_DIR)/usr/bin/hostpython
|
||||||
|
|
||||||
|
define HostPython
|
||||||
|
( export PYTHONPATH="$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR)"; \
|
||||||
|
export PYTHONOPTIMIZE=""; \
|
||||||
|
export PYTHONDONTWRITEBYTECODE=1; \
|
||||||
|
$(1) \
|
||||||
|
$(HOST_PYTHON_BIN) $(2); \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define PyPackage
|
||||||
|
$(call shexport,PyPackage/$(1)/filespec)
|
||||||
|
|
||||||
|
define Package/$(1)/install
|
||||||
|
@$(SH_FUNC) getvar $$(call shvar,PyPackage/$(1)/filespec) | ( \
|
||||||
|
IFS='|'; \
|
||||||
|
while read fop fspec fperm; do \
|
||||||
|
if [ "$$$$$$$$fop" = "+" ]; then \
|
||||||
|
dpath=`dirname "$$$$$$$$fspec"`; \
|
||||||
|
if [ -n "$$$$$$$$fperm" ]; then \
|
||||||
|
dperm="-m$$$$$$$$fperm"; \
|
||||||
|
else \
|
||||||
|
dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
|
||||||
|
fi; \
|
||||||
|
mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
|
||||||
|
echo "copying: '$$$$$$$$fspec'"; \
|
||||||
|
cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
|
||||||
|
if [ -n "$$$$$$$$fperm" ]; then \
|
||||||
|
chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
|
||||||
|
fi; \
|
||||||
|
elif [ "$$$$$$$$fop" = "-" ]; then \
|
||||||
|
echo "removing: '$$$$$$$$fspec'"; \
|
||||||
|
rm -fR $$(1)$$$$$$$$fspec; \
|
||||||
|
elif [ "$$$$$$$$fop" = "=" ]; then \
|
||||||
|
echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
|
||||||
|
chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
)
|
||||||
|
$(call PyPackage/$(1)/install,$$(1))
|
||||||
|
endef
|
||||||
|
endef
|
||||||
|
|
||||||
|
# $(1) => build subdir
|
||||||
|
# $(2) => additional arguments to setup.py
|
||||||
|
# $(3) => additional variables
|
||||||
|
define Build/Compile/PyMod
|
||||||
|
$(call HostPython, \
|
||||||
|
cd $(PKG_BUILD_DIR)/$(strip $(1)); \
|
||||||
|
CFLAGS="$(TARGET_CFLAGS)" \
|
||||||
|
CPPFLAGS="$(TARGET_CPPFLAGS)" \
|
||||||
|
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||||
|
$(3) \
|
||||||
|
, \
|
||||||
|
./setup.py $(2) \
|
||||||
|
)
|
||||||
|
find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
|
||||||
|
endef
|
25
lang/python/patches/110-enable-zlib.patch
Normal file
25
lang/python/patches/110-enable-zlib.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
From 6eeab87bc852481e599325549c854b701bf2e39f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alexandru Ardelean <aa@ocedo.com>
|
||||||
|
Date: Thu, 25 Sep 2014 18:18:29 +0300
|
||||||
|
Subject: [PATCH] enable zlib
|
||||||
|
|
||||||
|
---
|
||||||
|
Modules/Setup.dist | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/Modules/Setup.dist b/Modules/Setup.dist
|
||||||
|
index 01fb85f..01ac492 100644
|
||||||
|
--- a/Modules/Setup.dist
|
||||||
|
+++ b/Modules/Setup.dist
|
||||||
|
@@ -358,7 +358,7 @@ _symtable symtablemodule.c
|
||||||
|
# Andrew Kuchling's zlib module.
|
||||||
|
# This require zlib 1.1.3 (or later).
|
||||||
|
# See http://www.gzip.org/zlib/
|
||||||
|
-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
|
||||||
|
+zlib zlibmodule.c -lz
|
||||||
|
|
||||||
|
# Interface to the Expat XML parser
|
||||||
|
#
|
||||||
|
--
|
||||||
|
1.8.4.5
|
||||||
|
|
Loading…
Reference in a new issue