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
)
15 # XXX: reset PKG_RELEASE to 1 only if Python's pip & setuptools versions have also bumped;
16 # otherwise, keep bumping PKG_RELEASE
19 PKG_SOURCE
:=Python-
$(PKG_VERSION
).
tar.xz
20 PKG_SOURCE_URL
:=https
://www.python.org
/ftp
/python
/$(PKG_VERSION
)
21 PKG_HASH
:=71ffb26e09e78650e424929b2b457b9c912ac216576e6bd9e7d204ed03296a66
24 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
26 # This file provides the necsessary host build variables
27 include .
/files
/python-host.mk
30 include .
/files
/python-package.mk
34 HOST_BUILD_PARALLEL
:=1
36 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
37 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
39 PKG_CONFIG_DEPENDS
:=CONFIG_PACKAGE_python-setuptools CONFIG_PACKAGE_python-pip
41 PKG_BUILD_DEPENDS
:=python
/host
42 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host
44 include $(INCLUDE_DIR
)/host-build.mk
45 include $(INCLUDE_DIR
)/package.mk
47 define Package
/python
/Default
51 TITLE
:=Python
$(PYTHON_VERSION
) programming language
52 URL
:=https
://www.python.org
/
53 MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>
56 define Package
/python
/Default
/description
57 Python is a dynamic object-oriented programming language that can be used
58 for many kinds of software development. It offers strong support for
59 integration with other languages and tools
, comes with extensive standard
60 libraries
, and can be learned in a few days. Many Python programmers
61 report substantial productivity gains and feel the language encourages
62 the development of higher quality
, more maintainable code.
65 define Package
/python-pip-conf
66 $(call Package
/python
/Default
)
67 TITLE
:=Configuration file for pip
/pip3
68 URL
:=https
://pip.pypa.io
71 define Package
/python-pip-conf
/description
72 Configuration file for pip
/pip3
75 define Package
/python-base
76 $(call Package
/python
/Default
)
77 TITLE
:=Python
$(PYTHON_VERSION
) interpreter
78 DEPENDS
:=+libpthread
+zlib
81 define Package
/python-base
/description
82 This package contains only the interpreter and the bare minimum
83 for the interpreter to start.
86 define Package
/python-light
87 $(call Package
/python
/Default
)
88 TITLE
:=Python
$(PYTHON_VERSION
) light installation
89 DEPENDS
:=+python-base
+libffi
+libbz2
92 define Package
/python-light
/description
93 This package is essentially the python-base package plus
94 a few of the rarely used
(and big
) libraries stripped out
95 into separate packages.
98 PYTHON_LIB_FILES_DEL
:=
100 PYTHON_PACKAGES_DEPENDS
:=
102 PYTHON_PACKAGES
+=$(1)
104 PYTHON_PACKAGES_DEPENDS
+=$(1)
106 PYTHON_LIB_FILES_DEL
+=$(2)
107 define PyPackage
/$(1)/filespec
109 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
110 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/test
111 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/tests
116 include .
/files
/python-package-
*.mk
118 define Package
/python
119 $(call Package
/python
/Default
)
120 DEPENDS
:=+python-light
$(foreach package
,$(PYTHON_PACKAGES_DEPENDS
),+$(package
))
123 define Package
/python
/description
124 This package contains the
(almost
) full Python
install.
125 It
's python-light + all other packages.
139 ifeq ($(CONFIG_IPV6),y)
140 ENABLE_IPV6 += --enable-ipv6
144 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
145 _PYTHON_HOST_PLATFORM=linux2 \
146 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
147 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
156 --with-ensurepip=no \
158 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
160 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
161 OPT="$(TARGET_CFLAGS)"
164 $(call Build/Prepare/Default)
165 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
168 ifdef CONFIG_PACKAGE_python-setuptools
169 define Build/Compile/python-setuptools
170 $(STAGING_DIR_HOSTPKG)/bin/pip install \
172 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
173 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
175 endif # CONFIG_PACKAGE_python-setuptools
177 ifdef CONFIG_PACKAGE_python-pip
178 define Build/Compile/python-pip
179 $(STAGING_DIR_HOSTPKG)/bin/pip install \
181 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
182 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
184 endif # CONFIG_PACKAGE_python-pip
187 $(call Build/Compile/Default)
188 # Use host pip to install python-setuptools
189 $(call Build/Compile/python-setuptools)
190 $(call Build/Compile/python-pip)
193 define Build/InstallMkFiles
194 $(INSTALL_DIR) $(STAGING_DIR)/mk/
196 ./files/python-package.mk \
197 ./files/python-host.mk \
198 ./files/python-version.mk \
199 ./files/python-package-install.sh \
203 define Build/InstallDev
204 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
205 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
207 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
210 $(HOST_PYTHON_LIB_DIR) \
211 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
214 $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \
215 $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \
216 $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
217 $(1)/usr/lib/pkgconfig
219 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
220 $(1)/usr/lib/python$(PYTHON_VERSION)/
221 $(call Build/InstallMkFiles)
224 PYTHON_BASE_LIB_FILES:= \
225 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
226 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
227 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
228 /usr/lib/python$(PYTHON_VERSION)/abc.py \
229 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
230 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
231 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
232 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
233 /usr/lib/python$(PYTHON_VERSION)/os.py \
234 /usr/lib/python$(PYTHON_VERSION)/re.py \
235 /usr/lib/python$(PYTHON_VERSION)/site.py \
236 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
237 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
238 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
239 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
240 /usr/lib/python$(PYTHON_VERSION)/stat.py \
241 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
242 /usr/lib/python$(PYTHON_VERSION)/types.py \
243 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
244 /usr/lib/python$(PYTHON_VERSION)/warnings.py
246 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
248 define PyPackage/python-base/filespec
249 +|/usr/bin/python$(PYTHON_VERSION)
250 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
253 define PyPackage/python-light/filespec
254 +|/usr/lib/python$(PYTHON_VERSION)
255 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
256 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
257 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
258 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
259 -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
260 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
261 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
262 -|/usr/lib/python$(PYTHON_VERSION)/test
263 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
264 -|/usr/lib/python$(PYTHON_VERSION)/*/test
265 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
266 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
267 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
270 define PyPackage/python-base/install
271 $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
272 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
273 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
274 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
277 define PyPackage/python/filespec
281 define Package/python-pip-conf/install
282 $(INSTALL_DIR) $(1)/etc
283 $(CP) ./files/pip.conf $(1)/etc
287 -Wl,--no-as-needed -lrt \
288 $$$$(pkg-config --static --libs libcrypto libssl)
290 HOST_CONFIGURE_ARGS+= \
294 --prefix=$(HOST_PYTHON_DIR) \
295 --exec-prefix=$(HOST_PYTHON_DIR) \
296 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
297 --with-system-ffi=no \
298 --with-ensurepip=install \
302 $(call Host/Compile/Default,python Parser/pgen sharedmods)
306 $(call Build/InstallMkFiles)
307 $(MAKE) -C $(HOST_BUILD_DIR) install
308 $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/
309 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
312 $(eval $(call HostBuild))
314 $(foreach package, $(PYTHON_PACKAGES), \
315 $(eval $(call PyPackage,$(package))) \
316 $(eval $(call BuildPackage,$(package))) \
317 $(eval $(call BuildPackage,$(package)-src)) \
320 $(eval $(call PyPackage,python-base))
321 $(eval $(call PyPackage,python-light))
322 $(eval $(call PyPackage,python))
324 $(eval $(call BuildPackage,python-pip-conf))
326 $(eval $(call BuildPackage,python-base))
327 $(eval $(call BuildPackage,python-light))
328 $(eval $(call BuildPackage,python))
330 $(eval $(call BuildPackage,python-base-src))
331 $(eval $(call BuildPackage,python-light-src))
332 $(eval $(call BuildPackage,python-src))