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_MD5SUM
:=82b143ebbf4514d7e05876bed7a6b1f5
23 PKG_HASH
:=b0c5f904f685e32d9232f7bdcbece9819a892929063b6e385414ad2dd6a23622
26 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
28 # This file provides the necsessary host build variables
29 include .
/files
/python3-host.mk
32 include .
/files
/python3-package.mk
36 HOST_BUILD_PARALLEL
:=1
38 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
39 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
41 PKG_BUILD_DEPENDS
:=python3
/host
42 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host libffi
/host
44 include $(INCLUDE_DIR
)/host-build.mk
45 include $(INCLUDE_DIR
)/package.mk
47 define Package
/python3
/Default
51 TITLE
:=Python
$(PYTHON_VERSION
) programming language
52 URL
:=https
://www.python.org
/
53 MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>
56 define Package
/python3
/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
/python3-base
66 $(call Package
/python3
/Default
)
67 TITLE
:=Python
$(PYTHON_VERSION
) interpreter
68 DEPENDS
:=+libpthread
+zlib
71 define Package
/python3-base
/description
72 This package contains only the interpreter and the bare minimum
73 for the interpreter to start.
76 define Package
/python3-light
77 $(call Package
/python3
/Default
)
78 TITLE
:=Python
$(PYTHON_VERSION
) light installation
79 DEPENDS
:=+python3-base
+libffi
+libbz2
82 define Package
/python3-light
/description
83 This package is essentially the python3-base package plus
84 a few of the rarely used
(and big
) libraries stripped out
85 into separate packages.
88 PYTHON3_LIB_FILES_DEL
:=
90 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
91 PYTHON3_PACKAGES_DEPENDS
:=
93 PYTHON3_PACKAGES
+=$(1)
95 PYTHON3_PACKAGES_DEPENDS
+=$(1)
97 PYTHON3_LIB_FILES_DEL
+=$(2)
98 define Py3Package
/$(1)/filespec
99 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
103 include .
/files
/python3-package-
*.mk
105 define Package
/python3
106 $(call Package
/python3
/Default
)
107 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
110 define Package
/python3
/description
111 This package contains the
(almost
) full Python
install.
112 It
's python3-light + all other packages.
121 MAKE_FLAGS+=PYTHON_DECIMAL_WITH_MACHINE=ansi32
130 ifeq ($(CONFIG_IPV6),y)
131 ENABLE_IPV6 += --enable-ipv6
135 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
136 _PYTHON_HOST_PLATFORM=linux2 \
137 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
138 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
148 --with-ensurepip=no \
149 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
151 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
152 OPT="$(TARGET_CFLAGS)"
155 $(call Build/Prepare/Default)
156 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
159 define Build/InstallDev
160 $(INSTALL_DIR) $(STAGING_DIR)/mk/
161 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
162 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
164 ./files/python3-package.mk \
165 ./files/python3-host.mk \
166 ./files/python3-version.mk \
169 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
172 $(HOST_PYTHON3_LIB_DIR) \
173 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
176 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
177 $(1)/usr/lib/python$(PYTHON_VERSION)/
180 PYTHON3_BASE_LIB_FILES:= \
181 /usr/lib/python$(PYTHON_VERSION)/encodings \
182 /usr/lib/python$(PYTHON_VERSION)/_collections_abc.py \
183 /usr/lib/python$(PYTHON_VERSION)/_sitebuiltins.py \
184 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
185 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
186 /usr/lib/python$(PYTHON_VERSION)/abc.py \
187 /usr/lib/python$(PYTHON_VERSION)/codecs.py \
188 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
189 /usr/lib/python$(PYTHON_VERSION)/io.py \
190 /usr/lib/python$(PYTHON_VERSION)/os.py \
191 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
192 /usr/lib/python$(PYTHON_VERSION)/site.py \
193 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
194 /usr/lib/python$(PYTHON_VERSION)/stat.py
196 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
198 define Py3Package/python3-base/filespec
199 +|/usr/bin/python$(PYTHON_VERSION)
200 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
203 define Py3Package/python3-light/filespec
204 +|/usr/lib/python$(PYTHON_VERSION)
205 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
206 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
207 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
208 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
209 -|/usr/lib/python$(PYTHON_VERSION)/tkinter
210 -|/usr/lib/python$(PYTHON_VERSION)/turtledemo
211 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_test*.so
212 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline*.so
213 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
214 -|/usr/lib/python$(PYTHON_VERSION)/test
215 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
216 -|/usr/lib/python$(PYTHON_VERSION)/*/test
217 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
218 -|/usr/lib/python$(PYTHON_VERSION)/_osx_support.py
219 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
222 define Py3Package/python3-base/install
223 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
224 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/lib-dynload/
225 $(INSTALL_DIR) $(1)/usr/bin
226 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python3
227 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
230 define Py3Package/python3/filespec
234 HOST_CONFIGURE_ARGS+= \
238 --prefix=$(HOST_PYTHON3_DIR) \
239 --exec-prefix=$(HOST_PYTHON3_DIR) \
240 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
242 --with-ensurepip=no \
244 CFLAGS="$(HOST_CFLAGS)"
247 +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) python Parser/pgen
248 +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) sharedmods
252 $(MAKE) -C $(HOST_BUILD_DIR) install
254 $(INSTALL_DIR) $(HOST_PYTHON3_DIR)/bin/
255 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON3_DIR)/bin/pgen3
256 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Programs/_freeze_importlib $(HOST_PYTHON3_DIR)/bin/_freeze_importlib
259 $(eval $(call HostBuild))
261 $(foreach package, $(PYTHON3_PACKAGES), \
262 $(eval $(call Py3Package,$(package))) \
263 $(eval $(call BuildPackage,$(package))) \
266 $(eval $(call Py3Package,python3-base))
267 $(eval $(call Py3Package,python3-light))
268 $(eval $(call Py3Package,python3))
270 $(eval $(call BuildPackage,python3-base))
271 $(eval $(call BuildPackage,python3-light))
272 $(eval $(call BuildPackage,python3))