Browse Source

Merge pull request #396 from commodo/python-migration

python: import from old packages and update to version 3.4
sbyx 10 years ago
parent
commit
85695f4561

+ 199
- 0
lang/python/Makefile View File

@@ -0,0 +1,199 @@
1
+#
2
+# Copyright (C) 2006-2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+# The file included below defines PYTHON_VERSION
11
+-include $(if $(DUMP),,./files/python-package.mk)
12
+
13
+PKG_NAME:=python
14
+PKG_RELEASE:=1
15
+PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
16
+
17
+PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
18
+PKG_SOURCE_URL:=http://www.python.org/ftp/python/$(PKG_VERSION)
19
+PKG_MD5SUM:=6cafc183b4106476dd73d5738d7f616a
20
+
21
+PKG_LICENSE:=PSF
22
+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
23
+
24
+PKG_INSTALL:=1
25
+PKG_BUILD_PARALLEL:=1
26
+HOST_BUILD_PARALLEL:=1
27
+
28
+PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
29
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
30
+
31
+PKG_BUILD_DEPENDS:=python/host
32
+
33
+include $(INCLUDE_DIR)/host-build.mk
34
+include $(INCLUDE_DIR)/package.mk
35
+
36
+define Package/python/Default
37
+  SUBMENU:=Python
38
+  SECTION:=lang
39
+  CATEGORY:=Languages
40
+  TITLE:=Python $(PYTHON_VERSION) programming language
41
+  URL:=http://www.python.org/
42
+  MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
43
+endef
44
+
45
+define Package/python/Default/description
46
+ Python is a dynamic object-oriented programming language that can be used
47
+ for many kinds of software development. It offers strong support for
48
+ integration with other languages and tools, comes with extensive standard
49
+ libraries, and can be learned in a few days. Many Python programmers
50
+ report substantial productivity gains and feel the language encourages
51
+ the development of higher quality, more maintainable code.
52
+endef
53
+
54
+define Package/python
55
+$(call Package/python/Default)
56
+  DEPENDS:=+libpthread +zlib +libffi
57
+endef
58
+
59
+define Package/python/description
60
+$(call Package/python/Default/description)
61
+  .
62
+  This package contains only the interpreter and the bare minimum for the interpreter to start.
63
+endef
64
+
65
+MAKE_FLAGS:=\
66
+	$(TARGET_CONFIGURE_OPTS) \
67
+	DESTDIR="$(PKG_INSTALL_DIR)" \
68
+	CROSS_COMPILE=yes \
69
+	CFLAGS="$(TARGET_CFLAGS) -DNDEBUG -fno-inline" \
70
+	LDFLAGS="$(TARGET_LDFLAGS)" \
71
+	LD="$(TARGET_CC)"
72
+
73
+ENABLE_IPV6:=
74
+ifeq ($(CONFIG_IPV6),y)
75
+	ENABLE_IPV6 += --enable-ipv6
76
+endif
77
+
78
+#=======================================================================
79
+# Notes: adding these so that I don't forget, and can track why stuff
80
+#        was did as was did
81
+# - Arguments below were moved to ./files/config.site file, and disabled
82
+#          ac_cv_have_chflags=no \
83
+#          ac_cv_have_lchflags=no \
84
+#          ac_cv_py_format_size_t=no \
85
+#          ac_cv_have_long_long_format=yes \
86
+#          ac_cv_buggy_getaddrinfo=no \
87
+# - --without-ensurepip added, because the build wants to ensure that
88
+#   it works; that's a good idea, but for now, it requires special 
89
+#   setup, and we can do that later
90
+# - --without-pymalloc added, becase in Python 3, modules are suffixed
91
+#   with m; e.g. so some paths are python3.4m instead of python3.4 
92
+#   all this is detailed here:
93
+#     http://legacy.python.org/dev/peps/pep-3149/
94
+#=======================================================================
95
+
96
+define Build/Configure
97
+	-$(MAKE) -C $(PKG_BUILD_DIR) distclean
98
+	(cd $(PKG_BUILD_DIR); autoreconf --force --install || exit 0)
99
+	# The python executable needs to stay in the rootdir since its location will
100
+	# be used to compute the path of the config files.
101
+	$(CP) ./files/config.site $(PKG_BUILD_DIR)
102
+	$(call Build/Configure/Default, \
103
+		--sysconfdir=/etc \
104
+		--disable-shared \
105
+		--without-cxx-main \
106
+		--with-threads \
107
+		--with-system-ffi="$(STAGING_DIR)/usr" \
108
+		--without-ensurepip \
109
+		--without-pymalloc \
110
+		$(ENABLE_IPV6) \
111
+		CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
112
+		OPT="$(TARGET_CFLAGS)" \
113
+	)
114
+endef
115
+
116
+define Build/InstallDev
117
+	$(INSTALL_DIR) $(2)/bin $(1)/usr/bin $(1)/usr/include $(1)/usr/lib
118
+	$(INSTALL_DIR) $(STAGING_DIR)/mk/
119
+	$(INSTALL_DATA) ./files/python-package.mk $(STAGING_DIR)/mk/
120
+	$(CP) \
121
+		$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
122
+		$(1)/usr/include/
123
+	$(CP) \
124
+		$(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
125
+		$(PKG_BUILD_DIR)/libpython$(PYTHON_VERSION).a \
126
+		$(1)/usr/lib/
127
+	$(CP) \
128
+		$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
129
+		$(1)/usr/lib/python$(PYTHON_VERSION)/
130
+
131
+	$(CP) \
132
+		$(STAGING_DIR_HOST)/bin/python$(PYTHON_VERSION)-config \
133
+		$(2)/bin/
134
+	$(SED) 's,^#!.*,#!/usr/bin/env python$(PYTHON_VERSION),g' $(2)/bin/python$(PYTHON_VERSION)-config
135
+
136
+	(cd $(2)/bin; \
137
+	ln -sf python$(PYTHON_VERSION)-config python-config;)
138
+endef
139
+
140
+define PyPackage/python/filespec
141
++|/usr/bin/python$(PYTHON_VERSION)
142
++|/usr/lib/python$(PYTHON_VERSION)/encodings
143
++|/usr/lib/python$(PYTHON_VERSION)/_collections_abc.py
144
++|/usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py
145
++|/usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py
146
++|/usr/lib/python$(PYTHON_VERSION)/_weakrefset.py
147
++|/usr/lib/python$(PYTHON_VERSION)/abc.py
148
++|/usr/lib/python$(PYTHON_VERSION)/codecs.py
149
++|/usr/lib/python$(PYTHON_VERSION)/genericpath.py
150
++|/usr/lib/python$(PYTHON_VERSION)/io.py
151
++|/usr/lib/python$(PYTHON_VERSION)/os.py
152
++|/usr/lib/python$(PYTHON_VERSION)/posixpath.py
153
++|/usr/lib/python$(PYTHON_VERSION)/site.py
154
++|/usr/lib/python$(PYTHON_VERSION)/sysconfig.py
155
++|/usr/lib/python$(PYTHON_VERSION)/stat.py
156
+endef
157
+
158
+define PyPackage/python/install
159
+	# Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
160
+	$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
161
+	ln -sf python$(PYTHON_VERSION) $(1)/usr/bin/python
162
+endef
163
+
164
+define Host/Configure
165
+	-$(MAKE) -C $(HOST_BUILD_DIR) distclean
166
+	(cd $(HOST_BUILD_DIR); autoreconf --force --install || exit 0)
167
+	(cd $(HOST_BUILD_DIR); \
168
+		rm -rf config.cache; \
169
+		CONFIG_SITE= \
170
+		OPT="$(HOST_CFLAGS)" \
171
+		./configure \
172
+			--without-cxx-main \
173
+			--without-ensurepip \
174
+			--without-pymalloc \
175
+			--with-threads \
176
+			--prefix=$(STAGING_DIR_HOST); \
177
+	)
178
+endef
179
+
180
+define Host/Compile
181
+	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
182
+		python Parser/pgen
183
+	+$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
184
+		sharedmods
185
+endef
186
+
187
+define Host/Install
188
+	$(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
189
+	$(MAKE) -C $(HOST_BUILD_DIR) \
190
+		install
191
+	$(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(STAGING_DIR_HOST)/bin/
192
+endef
193
+
194
+
195
+$(eval $(call HostBuild))
196
+
197
+$(eval $(call PyPackage,python))
198
+
199
+$(eval $(call BuildPackage,python))

+ 18
- 0
lang/python/files/config.site View File

@@ -0,0 +1,18 @@
1
+#! /bin/sh
2
+#
3
+# Copyright (C) 2007-2014 OpenWrt.org
4
+#
5
+# This is free software, licensed under the GNU General Public License v2.
6
+# See /LICENSE for more information.
7
+#
8
+
9
+ac_cv_file__dev_ptmx=yes
10
+ac_cv_file__dev_ptc=no
11
+
12
+# FIXME: moved from Makefile here
13
+#ac_cv_have_chflags=no \
14
+#ac_cv_have_lchflags=no \
15
+#ac_cv_py_format_size_t=no \
16
+#ac_cv_have_long_long_format=yes \
17
+#ac_cv_buggy_getaddrinfo=no \
18
+

+ 78
- 0
lang/python/files/python-package.mk View File

@@ -0,0 +1,78 @@
1
+#
2
+# Copyright (C) 2007-2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+PYTHON_VERSION=3.4
9
+PYTHON_VERSION_MICRO=1
10
+
11
+PYTHON_DIR:=$(STAGING_DIR)/usr
12
+PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
13
+PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
14
+PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
15
+
16
+PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
17
+
18
+PYTHON:=python$(PYTHON_VERSION)
19
+
20
+HOST_PYTHON_BIN:=$(STAGING_DIR)/usr/bin/hostpython
21
+
22
+define HostPython
23
+	(	export PYTHONPATH="$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR)"; \
24
+		export PYTHONOPTIMIZE=""; \
25
+		export PYTHONDONTWRITEBYTECODE=1; \
26
+		$(1) \
27
+		$(HOST_PYTHON_BIN) $(2); \
28
+	)
29
+endef
30
+
31
+define PyPackage
32
+  $(call shexport,PyPackage/$(1)/filespec)
33
+
34
+  define Package/$(1)/install
35
+	@$(SH_FUNC) getvar $$(call shvar,PyPackage/$(1)/filespec) | ( \
36
+		IFS='|'; \
37
+		while read fop fspec fperm; do \
38
+		  if [ "$$$$$$$$fop" = "+" ]; then \
39
+			dpath=`dirname "$$$$$$$$fspec"`; \
40
+			if [ -n "$$$$$$$$fperm" ]; then \
41
+			  dperm="-m$$$$$$$$fperm"; \
42
+			else \
43
+			  dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
44
+			fi; \
45
+			mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
46
+			echo "copying: '$$$$$$$$fspec'"; \
47
+			cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
48
+			if [ -n "$$$$$$$$fperm" ]; then \
49
+			  chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
50
+			fi; \
51
+		  elif [ "$$$$$$$$fop" = "-" ]; then \
52
+			echo "removing: '$$$$$$$$fspec'"; \
53
+			rm -fR $$(1)$$$$$$$$fspec; \
54
+		  elif [ "$$$$$$$$fop" = "=" ]; then \
55
+			echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
56
+			chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
57
+		  fi; \
58
+		done; \
59
+	)
60
+	$(call PyPackage/$(1)/install,$$(1))
61
+  endef
62
+endef
63
+
64
+# $(1) => build subdir
65
+# $(2) => additional arguments to setup.py
66
+# $(3) => additional variables
67
+define Build/Compile/PyMod
68
+	$(call HostPython, \
69
+		cd $(PKG_BUILD_DIR)/$(strip $(1)); \
70
+		CFLAGS="$(TARGET_CFLAGS)" \
71
+		CPPFLAGS="$(TARGET_CPPFLAGS)" \
72
+		LDFLAGS="$(TARGET_LDFLAGS)" \
73
+		$(3) \
74
+		, \
75
+		./setup.py $(2) \
76
+	)
77
+	find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
78
+endef

+ 25
- 0
lang/python/patches/110-enable-zlib.patch View File

@@ -0,0 +1,25 @@
1
+From 6eeab87bc852481e599325549c854b701bf2e39f Mon Sep 17 00:00:00 2001
2
+From: Alexandru Ardelean <aa@ocedo.com>
3
+Date: Thu, 25 Sep 2014 18:18:29 +0300
4
+Subject: [PATCH] enable zlib
5
+
6
+---
7
+ Modules/Setup.dist | 2 +-
8
+ 1 file changed, 1 insertion(+), 1 deletion(-)
9
+
10
+diff --git a/Modules/Setup.dist b/Modules/Setup.dist
11
+index 01fb85f..01ac492 100644
12
+--- a/Modules/Setup.dist
13
++++ b/Modules/Setup.dist
14
+@@ -358,7 +358,7 @@ _symtable symtablemodule.c
15
+ # Andrew Kuchling's zlib module.
16
+ # This require zlib 1.1.3 (or later).
17
+ # See http://www.gzip.org/zlib/
18
+-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
19
++zlib zlibmodule.c -lz
20
+ 
21
+ # Interface to the Expat XML parser
22
+ #
23
+-- 
24
+1.8.4.5
25
+