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_HASH
:=35d543986882f78261f97787fd3e06274bfa6df29fac9b4a94f73930ff98f731
22 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
24 # This file provides the necsessary host build variables
25 include .
/files
/python-host.mk
28 include .
/files
/python-package.mk
32 HOST_BUILD_PARALLEL
:=1
34 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
35 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
37 PKG_CONFIG_DEPENDS
:=CONFIG_PACKAGE_python-setuptools CONFIG_PACKAGE_python-pip
39 PKG_BUILD_DEPENDS
:=python
/host
40 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host
42 include $(INCLUDE_DIR
)/host-build.mk
43 include $(INCLUDE_DIR
)/package.mk
45 define Package
/python
/Default
49 TITLE
:=Python
$(PYTHON_VERSION
) programming language
50 URL
:=https
://www.python.org
/
51 MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>
54 define Package
/python
/Default
/description
55 Python is a dynamic object-oriented programming language that can be used
56 for many kinds of software development. It offers strong support for
57 integration with other languages and tools
, comes with extensive standard
58 libraries
, and can be learned in a few days. Many Python programmers
59 report substantial productivity gains and feel the language encourages
60 the development of higher quality
, more maintainable code.
63 define Package
/python-pip-conf
64 $(call Package
/python
/Default
)
65 TITLE
:=Configuration file for pip
/pip3
66 URL
:=https
://pip.pypa.io
69 define Package
/python-pip-conf
/description
70 Configuration file for pip
/pip3
73 define Package
/python-base
74 $(call Package
/python
/Default
)
75 TITLE
:=Python
$(PYTHON_VERSION
) interpreter
76 DEPENDS
:=+libpthread
+zlib
79 define Package
/python-base
/description
80 This package contains only the interpreter and the bare minimum
81 for the interpreter to start.
84 define Package
/python-light
85 $(call Package
/python
/Default
)
86 TITLE
:=Python
$(PYTHON_VERSION
) light installation
87 DEPENDS
:=+python-base
+libffi
+libbz2
90 define Package
/python-light
/description
91 This package is essentially the python-base package plus
92 a few of the rarely used
(and big
) libraries stripped out
93 into separate packages.
96 PYTHON_LIB_FILES_DEL
:=
98 PYTHON_PACKAGES_DEPENDS
:=
100 PYTHON_PACKAGES
+=$(1)
102 PYTHON_PACKAGES_DEPENDS
+=$(1)
104 PYTHON_LIB_FILES_DEL
+=$(2)
105 define PyPackage
/$(1)/filespec
107 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
108 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/test
109 -|
/usr
/lib
/python
$(PYTHON_VERSION
)/*/tests
114 include .
/files
/python-package-
*.mk
116 define Package
/python
117 $(call Package
/python
/Default
)
118 DEPENDS
:=+python-light
$(foreach package
,$(PYTHON_PACKAGES_DEPENDS
),+$(package
))
121 define Package
/python
/description
122 This package contains the
(almost
) full Python
install.
123 It
's python-light + all other packages.
137 ifeq ($(CONFIG_IPV6),y)
138 ENABLE_IPV6 += --enable-ipv6
142 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
143 _PYTHON_HOST_PLATFORM=linux2 \
144 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
145 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
154 --with-ensurepip=no \
156 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
158 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
159 OPT="$(TARGET_CFLAGS)"
162 $(call Build/Prepare/Default)
163 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
166 ifdef CONFIG_PACKAGE_python-setuptools
167 define Build/Compile/python-setuptools
168 $(STAGING_DIR_HOSTPKG)/bin/pip install \
170 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
171 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
173 endif # CONFIG_PACKAGE_python-setuptools
175 ifdef CONFIG_PACKAGE_python-pip
176 define Build/Compile/python-pip
177 $(STAGING_DIR_HOSTPKG)/bin/pip install \
179 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
180 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
182 endif # CONFIG_PACKAGE_python-pip
185 $(call Build/Compile/Default)
186 # Use host pip to install python-setuptools
187 $(call Build/Compile/python-setuptools)
188 $(call Build/Compile/python-pip)
191 define Build/InstallDev
192 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
193 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
195 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
198 $(HOST_PYTHON_LIB_DIR) \
199 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
202 $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \
203 $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \
204 $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
205 $(1)/usr/lib/pkgconfig
207 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
208 $(1)/usr/lib/python$(PYTHON_VERSION)/
211 PYTHON_BASE_LIB_FILES:= \
212 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
213 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
214 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
215 /usr/lib/python$(PYTHON_VERSION)/abc.py \
216 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
217 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
218 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
219 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
220 /usr/lib/python$(PYTHON_VERSION)/os.py \
221 /usr/lib/python$(PYTHON_VERSION)/re.py \
222 /usr/lib/python$(PYTHON_VERSION)/site.py \
223 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
224 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
225 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
226 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
227 /usr/lib/python$(PYTHON_VERSION)/stat.py \
228 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
229 /usr/lib/python$(PYTHON_VERSION)/types.py \
230 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
231 /usr/lib/python$(PYTHON_VERSION)/warnings.py
233 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
235 define PyPackage/python-base/filespec
236 +|/usr/bin/python$(PYTHON_VERSION)
237 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
240 define PyPackage/python-light/filespec
241 +|/usr/lib/python$(PYTHON_VERSION)
242 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
243 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
244 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
245 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
246 -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
247 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
248 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
249 -|/usr/lib/python$(PYTHON_VERSION)/test
250 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
251 -|/usr/lib/python$(PYTHON_VERSION)/*/test
252 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
253 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
254 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
257 define PyPackage/python-base/install
258 $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
259 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
260 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
261 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
264 define PyPackage/python/filespec
268 define Package/python-pip-conf/install
269 $(INSTALL_DIR) $(1)/etc
270 $(CP) ./files/pip.conf $(1)/etc
274 -Wl,--no-as-needed -lrt \
275 $$$$(pkg-config --static --libs libcrypto libssl)
277 HOST_CONFIGURE_ARGS+= \
281 --prefix=$(HOST_PYTHON_DIR) \
282 --exec-prefix=$(HOST_PYTHON_DIR) \
283 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
284 --with-system-ffi=no \
285 --with-ensurepip=install \
289 $(MAKE) -C $(HOST_BUILD_DIR) install
290 $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/ $(STAGING_DIR)/mk/
291 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
292 # Install these mk files in the Host/Install phase ;
293 # The Build/InstallDev rule is activated only for target builds.
294 # But if someone needs only the host Python, then
295 # these files need to be installed in this phase, and not Build/InstallDev
297 ./files/python-package.mk \
298 ./files/python-host.mk \
299 ./files/python-version.mk \
300 ./files/python-package-install.sh \
304 $(eval $(call HostBuild))
306 $(foreach package, $(PYTHON_PACKAGES), \
307 $(eval $(call PyPackage,$(package))) \
308 $(eval $(call BuildPackage,$(package))) \
309 $(eval $(call BuildPackage,$(package)-src)) \
312 $(eval $(call PyPackage,python-base))
313 $(eval $(call PyPackage,python-light))
314 $(eval $(call PyPackage,python))
316 $(eval $(call BuildPackage,python-pip-conf))
318 $(eval $(call BuildPackage,python-base))
319 $(eval $(call BuildPackage,python-light))
320 $(eval $(call BuildPackage,python))
322 $(eval $(call BuildPackage,python-base-src))
323 $(eval $(call BuildPackage,python-light-src))
324 $(eval $(call BuildPackage,python-src))