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
10 # The file included below defines PYTHON_VERSION
11 include .
/files
/python3-version.mk
13 PYTHON_VERSION
:=$(PYTHON3_VERSION
)
14 PYTHON_VERSION_MICRO
:=$(PYTHON3_VERSION_MICRO
)
17 # XXX: reset PKG_RELEASE to 1 only if Python's pip & setuptools versions have also bumped;
18 # otherwise, keep bumping PKG_RELEASE
20 PKG_VERSION
:=$(PYTHON_VERSION
).
$(PYTHON_VERSION_MICRO
)
22 PKG_SOURCE
:=Python-
$(PKG_VERSION
).
tar.xz
23 PKG_SOURCE_URL
:=https
://www.python.org
/ftp
/python
/$(PKG_VERSION
)
24 PKG_HASH
:=9229773be41ed144370f47f0f626a1579931f5a390f1e8e3853174d52edd64a9
27 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
29 # This file provides the necsessary host build variables
30 include .
/files
/python3-host.mk
33 include .
/files
/python3-package.mk
37 HOST_BUILD_PARALLEL
:=1
39 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
40 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
42 PKG_CONFIG_DEPENDS
:=CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
44 PKG_BUILD_DEPENDS
:=python3
/host
45 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host libffi
/host
47 include $(INCLUDE_DIR
)/host-build.mk
48 include $(INCLUDE_DIR
)/package.mk
50 define Package
/python3
/Default
54 TITLE
:=Python
$(PYTHON_VERSION
) programming language
55 URL
:=https
://www.python.org
/
56 MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>
59 define Package
/python3
/Default
/description
60 Python is a dynamic object-oriented programming language that can be used
61 for many kinds of software development. It offers strong support for
62 integration with other languages and tools
, comes with extensive standard
63 libraries
, and can be learned in a few days. Many Python programmers
64 report substantial productivity gains and feel the language encourages
65 the development of higher quality
, more maintainable code.
68 define Package
/python3-base
69 $(call Package
/python3
/Default
)
70 TITLE
:=Python
$(PYTHON_VERSION
) interpreter
71 DEPENDS
:=+libpthread
+zlib
74 define Package
/python3-base
/description
75 This package contains only the interpreter and the bare minimum
76 for the interpreter to start.
79 define Package
/python3-light
80 $(call Package
/python3
/Default
)
81 TITLE
:=Python
$(PYTHON_VERSION
) light installation
82 DEPENDS
:=+python3-base
+libffi
+libbz2
85 define Package
/python3-light
/description
86 This package is essentially the python3-base package plus
87 a few of the rarely used
(and big
) libraries stripped out
88 into separate packages.
91 PYTHON3_LIB_FILES_DEL
:=
93 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
94 PYTHON3_PACKAGES_DEPENDS
:=
96 PYTHON3_PACKAGES
+=$(1)
98 PYTHON3_PACKAGES_DEPENDS
+=$(1)
100 PYTHON3_LIB_FILES_DEL
+=$(2)
101 define Py3Package
/$(1)/filespec
103 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
104 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/test
105 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/tests
110 include .
/files
/python3-package-
*.mk
112 define Package
/python3
113 $(call Package
/python3
/Default
)
114 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
117 define Package
/python3
/description
118 This package contains the
(almost
) full Python
install.
119 It
's python3-light + all other packages.
133 ifeq ($(CONFIG_IPV6),y)
134 ENABLE_IPV6 += --enable-ipv6
138 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
139 _PYTHON_HOST_PLATFORM=linux2 \
140 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
141 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
150 --with-ensurepip=no \
152 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
154 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
155 OPT="$(TARGET_CFLAGS)"
158 $(call Build/Prepare/Default)
159 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
162 ifdef CONFIG_PACKAGE_python3-setuptools
163 define Build/Compile/python3-setuptools
164 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \
166 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
167 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
169 endif # CONFIG_PACKAGE_python3-setuptools
171 ifdef CONFIG_PACKAGE_python3-pip
172 define Build/Compile/python3-pip
173 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \
175 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
176 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
178 endif # CONFIG_PACKAGE_python3-pip
181 $(call Build/Compile/Default)
182 # Use host pip to install python-setuptools
183 $(call Build/Compile/python3-setuptools)
184 $(call Build/Compile/python3-pip)
187 define Build/InstallMkFiles
188 $(INSTALL_DIR) $(STAGING_DIR)/mk/
190 ./files/python3-package.mk \
191 ./files/python3-host.mk \
192 ./files/python3-version.mk \
193 ./files/python3-package-install.sh \
197 define Build/InstallDev
198 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
199 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
201 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
204 $(HOST_PYTHON3_LIB_DIR) \
205 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
208 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
209 $(1)/usr/lib/python$(PYTHON_VERSION)/
210 $(call Build/InstallMkFiles)
213 PYTHON3_BASE_LIB_FILES:= \
214 /usr/lib/python$(PYTHON_VERSION)/encodings \
215 /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \
216 /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py \
217 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
218 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
219 /usr/lib/python$(PYTHON_VERSION)/abc.py \
220 /usr/lib/python$(PYTHON_VERSION)/codecs.py \
221 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
222 /usr/lib/python$(PYTHON_VERSION)/io.py \
223 /usr/lib/python$(PYTHON_VERSION)/os.py \
224 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
225 /usr/lib/python$(PYTHON_VERSION)/site.py \
226 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
227 /usr/lib/python$(PYTHON_VERSION)/stat.py
229 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
231 define Py3Package/python3-base/filespec
232 +|/usr/bin/python$(PYTHON_VERSION)
233 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
236 define Py3Package/python3-light/filespec
237 +|/usr/lib/python$(PYTHON_VERSION)
238 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
239 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
240 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
241 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
242 -|/usr/lib/python$(PYTHON_VERSION)/tkinter
243 -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
244 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
245 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
246 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
247 -|/usr/lib/python$(PYTHON_VERSION)/test
248 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
249 -|/usr/lib/python$(PYTHON_VERSION)/*/test
250 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
251 -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py
252 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
255 define Py3Package/python3-base/install
256 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
257 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
258 $(INSTALL_DIR) $(1)/usr/bin
259 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
260 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
263 define Py3Package/python3/filespec
268 -Wl,--no-as-needed -lrt \
269 $$$$(pkg-config --static --libs libcrypto libssl)
271 HOST_CONFIGURE_ARGS+= \
275 --prefix=$(HOST_PYTHON3_DIR) \
276 --exec-prefix=$(HOST_PYTHON3_DIR) \
277 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
278 --with-system-ffi=no \
279 --with-ensurepip=install \
283 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
284 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
288 $(call Build/InstallMkFiles)
289 $(MAKE) -C $(HOST_BUILD_DIR) install
290 $(INSTALL_DIR) $(HOST_PYTHON3_DIR)/bin/
291 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON3_DIR)/bin/pgen3
294 $(eval $(call HostBuild))
296 $(foreach package, $(PYTHON3_PACKAGES), \
297 $(eval $(call Py3Package,$(package))) \
298 $(eval $(call BuildPackage,$(package))) \
299 $(eval $(call BuildPackage,$(package)-src)) \
302 $(eval $(call Py3Package,python3-base))
303 $(eval $(call Py3Package,python3-light))
304 $(eval $(call Py3Package,python3))
306 $(eval $(call BuildPackage,python3-base))
307 $(eval $(call BuildPackage,python3-light))
308 $(eval $(call BuildPackage,python3))
310 $(eval $(call BuildPackage,python3-base-src))
311 $(eval $(call BuildPackage,python3-light-src))
312 $(eval $(call BuildPackage,python3-src))