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
)
18 PKG_VERSION
:=$(PYTHON_VERSION
).
$(PYTHON_VERSION_MICRO
)
20 PKG_SOURCE
:=Python-
$(PKG_VERSION
).
tar.xz
21 PKG_SOURCE_URL
:=https
://www.python.org
/ftp
/python
/$(PKG_VERSION
)
22 PKG_HASH
:=a01810ddfcec216bcdb357a84bfaafdfaa0ca42bbdaa4cb7ff74f5a9961e4041
25 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
27 # This file provides the necsessary host build variables
28 include .
/files
/python3-host.mk
31 include .
/files
/python3-package.mk
35 HOST_BUILD_PARALLEL
:=1
37 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
38 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
40 PKG_CONFIG_DEPENDS
:=CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
42 PKG_BUILD_DEPENDS
:=python3
/host
43 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host libffi
/host
45 include $(INCLUDE_DIR
)/host-build.mk
46 include $(INCLUDE_DIR
)/package.mk
48 define Package
/python3
/Default
52 TITLE
:=Python
$(PYTHON_VERSION
) programming language
53 URL
:=https
://www.python.org
/
54 MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>
57 define Package
/python3
/Default
/description
58 Python is a dynamic object-oriented programming language that can be used
59 for many kinds of software development. It offers strong support for
60 integration with other languages and tools
, comes with extensive standard
61 libraries
, and can be learned in a few days. Many Python programmers
62 report substantial productivity gains and feel the language encourages
63 the development of higher quality
, more maintainable code.
66 define Package
/python3-base
67 $(call Package
/python3
/Default
)
68 TITLE
:=Python
$(PYTHON_VERSION
) interpreter
69 DEPENDS
:=+libpthread
+zlib
72 define Package
/python3-base
/description
73 This package contains only the interpreter and the bare minimum
74 for the interpreter to start.
77 define Package
/python3-light
78 $(call Package
/python3
/Default
)
79 TITLE
:=Python
$(PYTHON_VERSION
) light installation
80 DEPENDS
:=+python3-base
+libffi
+libbz2
83 define Package
/python3-light
/description
84 This package is essentially the python3-base package plus
85 a few of the rarely used
(and big
) libraries stripped out
86 into separate packages.
89 PYTHON3_LIB_FILES_DEL
:=
91 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
92 PYTHON3_PACKAGES_DEPENDS
:=
94 PYTHON3_PACKAGES
+=$(1)
96 PYTHON3_PACKAGES_DEPENDS
+=$(1)
98 PYTHON3_LIB_FILES_DEL
+=$(2)
99 define Py3Package
/$(1)/filespec
101 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
102 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/test
103 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/tests
108 include .
/files
/python3-package-
*.mk
110 define Package
/python3
111 $(call Package
/python3
/Default
)
112 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
115 define Package
/python3
/description
116 This package contains the
(almost
) full Python
install.
117 It
's python3-light + all other packages.
131 ifeq ($(CONFIG_IPV6),y)
132 ENABLE_IPV6 += --enable-ipv6
136 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
137 _PYTHON_HOST_PLATFORM=linux2 \
138 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
139 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
148 --with-ensurepip=no \
150 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
152 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
153 OPT="$(TARGET_CFLAGS)"
156 $(call Build/Prepare/Default)
157 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
160 ifdef CONFIG_PACKAGE_python3-setuptools
161 define Build/Compile/python3-setuptools
162 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \
164 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
165 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
167 endif # CONFIG_PACKAGE_python3-setuptools
169 ifdef CONFIG_PACKAGE_python3-pip
170 define Build/Compile/python3-pip
171 $(STAGING_DIR_HOSTPKG)/bin/pip3 install \
173 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
174 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
176 endif # CONFIG_PACKAGE_python3-pip
179 $(call Build/Compile/Default)
180 # Use host pip to install python-setuptools
181 $(call Build/Compile/python3-setuptools)
182 $(call Build/Compile/python3-pip)
185 define Build/InstallDev
186 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
187 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
189 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
192 $(HOST_PYTHON3_LIB_DIR) \
193 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
196 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
197 $(1)/usr/lib/python$(PYTHON_VERSION)/
200 PYTHON3_BASE_LIB_FILES:= \
201 /usr/lib/python$(PYTHON_VERSION)/encodings \
202 /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \
203 /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py \
204 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
205 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
206 /usr/lib/python$(PYTHON_VERSION)/abc.py \
207 /usr/lib/python$(PYTHON_VERSION)/codecs.py \
208 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
209 /usr/lib/python$(PYTHON_VERSION)/io.py \
210 /usr/lib/python$(PYTHON_VERSION)/os.py \
211 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
212 /usr/lib/python$(PYTHON_VERSION)/site.py \
213 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
214 /usr/lib/python$(PYTHON_VERSION)/stat.py
216 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
218 define Py3Package/python3-base/filespec
219 +|/usr/bin/python$(PYTHON_VERSION)
220 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
223 define Py3Package/python3-light/filespec
224 +|/usr/lib/python$(PYTHON_VERSION)
225 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
226 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
227 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
228 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
229 -|/usr/lib/python$(PYTHON_VERSION)/tkinter
230 -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
231 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
232 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
233 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
234 -|/usr/lib/python$(PYTHON_VERSION)/test
235 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
236 -|/usr/lib/python$(PYTHON_VERSION)/*/test
237 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
238 -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py
239 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
242 define Py3Package/python3-base/install
243 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
244 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
245 $(INSTALL_DIR) $(1)/usr/bin
246 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
247 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
250 define Py3Package/python3/filespec
255 -Wl,--no-as-needed -lrt \
256 $$$$(pkg-config --static --libs libcrypto libssl)
258 HOST_CONFIGURE_ARGS+= \
262 --prefix=$(HOST_PYTHON3_DIR) \
263 --exec-prefix=$(HOST_PYTHON3_DIR) \
264 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
265 --with-system-ffi=no \
266 --with-ensurepip=install \
270 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
271 +$(HOST_MAKE_VARS) $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
275 $(MAKE) -C $(HOST_BUILD_DIR) install
277 $(INSTALL_DIR) $(HOST_PYTHON3_DIR)/bin/ $(STAGING_DIR)/mk/
278 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON3_DIR)/bin/pgen3
279 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Programs/_freeze_importlib $(HOST_PYTHON3_DIR)/bin/_freeze_importlib
281 # Install these mk files in the Host/Install phase ;
282 # The Build/InstallDev rule is activated only for target builds.
283 # But if someone needs only the host Python, then
284 # these files need to be installed in this phase, and not Build/InstallDev
286 ./files/python3-package.mk \
287 ./files/python3-host.mk \
288 ./files/python3-version.mk \
289 ./files/python3-package-install.sh \
293 $(eval $(call HostBuild))
295 $(foreach package, $(PYTHON3_PACKAGES), \
296 $(eval $(call Py3Package,$(package))) \
297 $(eval $(call BuildPackage,$(package))) \
298 $(eval $(call BuildPackage,$(package)-src)) \
301 $(eval $(call Py3Package,python3-base))
302 $(eval $(call Py3Package,python3-light))
303 $(eval $(call Py3Package,python3))
305 $(eval $(call BuildPackage,python3-base))
306 $(eval $(call BuildPackage,python3-light))
307 $(eval $(call BuildPackage,python3))
309 $(eval $(call BuildPackage,python3-base-src))
310 $(eval $(call BuildPackage,python3-light-src))
311 $(eval $(call BuildPackage,python3-src))