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_CONFIG_DEPENDS
:=CONFIG_PACKAGE_python-setuptools CONFIG_PACKAGE_python-pip
40 PKG_BUILD_DEPENDS
:=python
/host
41 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host
43 include $(INCLUDE_DIR
)/host-build.mk
44 include $(INCLUDE_DIR
)/package.mk
46 define Package
/python
/Default
50 TITLE
:=Python
$(PYTHON_VERSION
) programming language
51 URL
:=https
://www.python.org
/
52 MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>
55 define Package
/python
/Default
/description
56 Python is a dynamic object-oriented programming language that can be used
57 for many kinds of software development. It offers strong support for
58 integration with other languages and tools
, comes with extensive standard
59 libraries
, and can be learned in a few days. Many Python programmers
60 report substantial productivity gains and feel the language encourages
61 the development of higher quality
, more maintainable code.
64 define Package
/python-pip-conf
65 $(call Package
/python
/Default
)
66 TITLE
:=Configuration file for pip
/pip3
67 URL
:=https
://pip.pypa.io
70 define Package
/python-pip-conf
/description
71 Configuration file for pip
/pip3
74 define Package
/python-base
75 $(call Package
/python
/Default
)
76 TITLE
:=Python
$(PYTHON_VERSION
) interpreter
77 DEPENDS
:=+libpthread
+zlib
80 define Package
/python-base
/description
81 This package contains only the interpreter and the bare minimum
82 for the interpreter to start.
85 define Package
/python-light
86 $(call Package
/python
/Default
)
87 TITLE
:=Python
$(PYTHON_VERSION
) light installation
88 DEPENDS
:=+python-base
+libffi
+libbz2
91 define Package
/python-light
/description
92 This package is essentially the python-base package plus
93 a few of the rarely used
(and big
) libraries stripped out
94 into separate packages.
97 PYTHON_LIB_FILES_DEL
:=
99 PYTHON_PACKAGES_DEPENDS
:=
101 PYTHON_PACKAGES
+=$(1)
103 PYTHON_PACKAGES_DEPENDS
+=$(1)
105 PYTHON_LIB_FILES_DEL
+=$(2)
106 define PyPackage
/$(1)/filespec
108 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
109 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/test
110 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/tests
115 include .
/files
/python-package-
*.mk
117 define Package
/python
118 $(call Package
/python
/Default
)
119 DEPENDS
:=+python-light
$(foreach package
,$(PYTHON_PACKAGES_DEPENDS
),+$(package
))
122 define Package
/python
/description
123 This package contains the
(almost
) full Python
install.
124 It
's python-light + all other packages.
138 ifeq ($(CONFIG_IPV6),y)
139 ENABLE_IPV6 += --enable-ipv6
143 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
144 _PYTHON_HOST_PLATFORM=linux2 \
145 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
146 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
155 --with-ensurepip=no \
157 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
159 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
160 OPT="$(TARGET_CFLAGS)"
163 $(call Build/Prepare/Default)
164 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
167 ifdef CONFIG_PACKAGE_python-setuptools
168 define Build/Compile/python-setuptools
169 $(STAGING_DIR_HOSTPKG)/bin/pip install \
171 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
172 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
174 endif # CONFIG_PACKAGE_python-setuptools
176 ifdef CONFIG_PACKAGE_python-pip
177 define Build/Compile/python-pip
178 $(STAGING_DIR_HOSTPKG)/bin/pip install \
180 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
181 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
183 endif # CONFIG_PACKAGE_python-pip
186 $(call Build/Compile/Default)
187 # Use host pip to install python-setuptools
188 $(call Build/Compile/python-setuptools)
189 $(call Build/Compile/python-pip)
192 define Build/InstallDev
193 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
194 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
196 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
199 $(HOST_PYTHON_LIB_DIR) \
200 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
203 $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \
204 $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \
205 $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
206 $(1)/usr/lib/pkgconfig
208 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
209 $(1)/usr/lib/python$(PYTHON_VERSION)/
212 PYTHON_BASE_LIB_FILES:= \
213 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
214 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
215 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
216 /usr/lib/python$(PYTHON_VERSION)/abc.py \
217 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
218 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
219 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
220 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
221 /usr/lib/python$(PYTHON_VERSION)/os.py \
222 /usr/lib/python$(PYTHON_VERSION)/re.py \
223 /usr/lib/python$(PYTHON_VERSION)/site.py \
224 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
225 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
226 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
227 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
228 /usr/lib/python$(PYTHON_VERSION)/stat.py \
229 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
230 /usr/lib/python$(PYTHON_VERSION)/types.py \
231 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
232 /usr/lib/python$(PYTHON_VERSION)/warnings.py
234 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
236 define PyPackage/python-base/filespec
237 +|/usr/bin/python$(PYTHON_VERSION)
238 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
241 define PyPackage/python-light/filespec
242 +|/usr/lib/python$(PYTHON_VERSION)
243 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
244 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
245 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
246 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
247 -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
248 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
249 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
250 -|/usr/lib/python$(PYTHON_VERSION)/test
251 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
252 -|/usr/lib/python$(PYTHON_VERSION)/*/test
253 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
254 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
255 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
258 define PyPackage/python-base/install
259 $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
260 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
261 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
262 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
265 define PyPackage/python/filespec
269 define Package/python-pip-conf/install
270 $(INSTALL_DIR) $(1)/etc
271 $(CP) ./files/pip.conf $(1)/etc
275 -Wl,--no-as-needed -lrt \
276 $$$$(pkg-config --static --libs libcrypto libssl)
278 HOST_CONFIGURE_ARGS+= \
282 --prefix=$(HOST_PYTHON_DIR) \
283 --exec-prefix=$(HOST_PYTHON_DIR) \
284 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
285 --with-system-ffi=no \
286 --with-ensurepip=install \
290 $(MAKE) -C $(HOST_BUILD_DIR) install
291 $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/ $(STAGING_DIR)/mk/
292 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
293 # Install these mk files in the Host/Install phase ;
294 # The Build/InstallDev rule is activated only for target builds.
295 # But if someone needs only the host Python, then
296 # these files need to be installed in this phase, and not Build/InstallDev
298 ./files/python-package.mk \
299 ./files/python-host.mk \
300 ./files/python-version.mk \
301 ./files/python-package-install.sh \
305 $(eval $(call HostBuild))
307 $(foreach package, $(PYTHON_PACKAGES), \
308 $(eval $(call PyPackage,$(package))) \
309 $(eval $(call BuildPackage,$(package))) \
310 $(eval $(call BuildPackage,$(package)-src)) \
313 $(eval $(call PyPackage,python-base))
314 $(eval $(call PyPackage,python-light))
315 $(eval $(call PyPackage,python))
317 $(eval $(call BuildPackage,python-pip-conf))
319 $(eval $(call BuildPackage,python-base))
320 $(eval $(call BuildPackage,python-light))
321 $(eval $(call BuildPackage,python))
323 $(eval $(call BuildPackage,python-base-src))
324 $(eval $(call BuildPackage,python-light-src))
325 $(eval $(call BuildPackage,python-src))