2 # Copyright (C) 2006-2016 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR
)/rules.mk
11 include .
/files
/python-version.mk
14 PKG_VERSION
:=$(PYTHON_VERSION
).
$(PYTHON_VERSION_MICRO
)
17 PKG_SOURCE
:=Python-
$(PKG_VERSION
).
tar.xz
18 PKG_SOURCE_URL
:=https
://www.python.org
/ftp
/python
/$(PKG_VERSION
)
19 PKG_MD5SUM
:=53b43534153bb2a0363f08bae8b9d990
20 PKG_HASH
:=35d543986882f78261f97787fd3e06274bfa6df29fac9b4a94f73930ff98f731
23 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
25 # This file provides the necsessary host build variables
26 include .
/files
/python-host.mk
29 include .
/files
/python-package.mk
33 HOST_BUILD_PARALLEL
:=1
35 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
36 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
38 PKG_BUILD_DEPENDS
:=python
/host
39 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host
41 include $(INCLUDE_DIR
)/host-build.mk
42 include $(INCLUDE_DIR
)/package.mk
44 define Package
/python
/Default
48 TITLE
:=Python
$(PYTHON_VERSION
) programming language
49 URL
:=https
://www.python.org
/
50 MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>
53 define Package
/python
/Default
/description
54 Python is a dynamic object-oriented programming language that can be used
55 for many kinds of software development. It offers strong support for
56 integration with other languages and tools
, comes with extensive standard
57 libraries
, and can be learned in a few days. Many Python programmers
58 report substantial productivity gains and feel the language encourages
59 the development of higher quality
, more maintainable code.
62 define Package
/python-pip-conf
63 $(call Package
/python
/Default
)
64 TITLE
:=Configuration file for pip
/pip3
65 URL
:=https
://pip.pypa.io
68 define Package
/python-pip-conf
/description
69 Configuration file for pip
/pip3
72 define Package
/python-base
73 $(call Package
/python
/Default
)
74 TITLE
:=Python
$(PYTHON_VERSION
) interpreter
75 DEPENDS
:=+libpthread
+zlib
78 define Package
/python-base
/description
79 This package contains only the interpreter and the bare minimum
80 for the interpreter to start.
83 define Package
/python-light
84 $(call Package
/python
/Default
)
85 TITLE
:=Python
$(PYTHON_VERSION
) light installation
86 DEPENDS
:=+python-base
+libffi
+libbz2
89 define Package
/python-light
/description
90 This package is essentially the python-base package plus
91 a few of the rarely used
(and big
) libraries stripped out
92 into separate packages.
95 PYTHON_LIB_FILES_DEL
:=
97 PYTHON_PACKAGES_DEPENDS
:=
101 PYTHON_PACKAGES_DEPENDS
+=$(1)
103 PYTHON_LIB_FILES_DEL
+=$(2)
104 define PyPackage
/$(1)/filespec
106 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
107 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/test
108 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/tests
113 include .
/files
/python-package-
*.mk
115 define Package
/python
116 $(call Package
/python
/Default
)
117 DEPENDS
:=+python-light
$(foreach package
,$(PYTHON_PACKAGES_DEPENDS
),+$(package
))
120 define Package
/python
/description
121 This package contains the
(almost
) full Python
install.
122 It
's python-light + all other packages.
136 ifeq ($(CONFIG_IPV6),y)
137 ENABLE_IPV6 += --enable-ipv6
141 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
142 _PYTHON_HOST_PLATFORM=linux2 \
143 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
144 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
153 --with-ensurepip=no \
155 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
157 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
158 OPT="$(TARGET_CFLAGS)"
161 $(call Build/Prepare/Default)
162 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
165 ifdef CONFIG_PACKAGE_python-setuptools
166 define Build/Compile/python-setuptools
167 $(STAGING_DIR_HOSTPKG)/bin/pip install \
169 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
170 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
172 endif # CONFIG_PACKAGE_python-setuptools
174 ifdef CONFIG_PACKAGE_python-pip
175 define Build/Compile/python-pip
176 $(STAGING_DIR_HOSTPKG)/bin/pip install \
178 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
179 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
181 endif # CONFIG_PACKAGE_python-pip
184 $(call Build/Compile/Default)
185 # Use host pip to install python-setuptools
186 $(call Build/Compile/python-setuptools)
187 $(call Build/Compile/python-pip)
190 define Build/InstallDev
191 $(INSTALL_DIR) $(STAGING_DIR)/mk/
192 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
193 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
195 ./files/python-package.mk \
196 ./files/python-host.mk \
197 ./files/python-version.mk \
198 ./files/python-package-install.sh \
201 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
204 $(HOST_PYTHON_LIB_DIR) \
205 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
208 $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \
209 $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \
210 $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
211 $(1)/usr/lib/pkgconfig
213 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
214 $(1)/usr/lib/python$(PYTHON_VERSION)/
217 PYTHON_BASE_LIB_FILES:= \
218 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
219 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
220 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
221 /usr/lib/python$(PYTHON_VERSION)/abc.py \
222 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
223 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
224 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
225 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
226 /usr/lib/python$(PYTHON_VERSION)/os.py \
227 /usr/lib/python$(PYTHON_VERSION)/re.py \
228 /usr/lib/python$(PYTHON_VERSION)/site.py \
229 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
230 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
231 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
232 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
233 /usr/lib/python$(PYTHON_VERSION)/stat.py \
234 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
235 /usr/lib/python$(PYTHON_VERSION)/types.py \
236 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
237 /usr/lib/python$(PYTHON_VERSION)/warnings.py
239 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
241 define PyPackage/python-base/filespec
242 +|/usr/bin/python$(PYTHON_VERSION)
243 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
246 define PyPackage/python-light/filespec
247 +|/usr/lib/python$(PYTHON_VERSION)
248 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
249 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
250 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
251 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
252 -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
253 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
254 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
255 -|/usr/lib/python$(PYTHON_VERSION)/test
256 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
257 -|/usr/lib/python$(PYTHON_VERSION)/*/test
258 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
259 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
260 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
263 define PyPackage/python-base/install
264 $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
265 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
266 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
267 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
270 define PyPackage/python/filespec
274 define Package/python-pip-conf/install
275 $(INSTALL_DIR) $(1)/etc
276 $(CP) ./files/pip.conf $(1)/etc
280 $$$$(pkg-config --static --libs libcrypto libssl)
282 HOST_CONFIGURE_ARGS+= \
286 --prefix=$(HOST_PYTHON_DIR) \
287 --exec-prefix=$(HOST_PYTHON_DIR) \
288 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
289 --with-system-ffi=no \
290 --with-ensurepip=install \
294 $(MAKE) -C $(HOST_BUILD_DIR) install
295 $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/
296 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
299 $(eval $(call HostBuild))
301 $(foreach package, $(PYTHON_PACKAGES), \
302 $(eval $(call PyPackage,$(package))) \
303 $(eval $(call BuildPackage,$(package))) \
304 $(eval $(call BuildPackage,$(package)-src)) \
307 $(eval $(call PyPackage,python-base))
308 $(eval $(call PyPackage,python-light))
309 $(eval $(call PyPackage,python))
311 $(eval $(call BuildPackage,python-pip-conf))
313 $(eval $(call BuildPackage,python-base))
314 $(eval $(call BuildPackage,python-light))
315 $(eval $(call BuildPackage,python))
317 $(eval $(call BuildPackage,python-base-src))
318 $(eval $(call BuildPackage,python-light-src))
319 $(eval $(call BuildPackage,python-src))