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 PYTHON3_VERSION
11 include ..
/python3-version.mk
15 PKG_VERSION
:=$(PYTHON3_VERSION
).
$(PYTHON3_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
:=397920af33efc5b97f2e0b57e91923512ef89fc5b3c1d21dbfc8c4828ce0108a
21 PKG_MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>, Jeffery To
<jeffery.to@gmail.com
>
22 PKG_LICENSE
:=Python
/2.0
23 PKG_LICENSE_FILES
:=LICENSE Doc
/copyright.rst Doc
/license.rst Modules
/_ctypes
/darwin
/LICENSE Modules
/_ctypes
/libffi_osx
/LICENSE Modules
/expat
/COPYING
24 PKG_CPE_ID
:=cpe
:/a
:python
:python
26 # This file provides the necsessary host build variables
27 include ..
/python3-host.mk
31 include ..
/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_CONFIG_DEPENDS
:= \
42 CONFIG_PACKAGE_python3-pkg-resources \
43 CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip \
44 CONFIG_PYTHON3_BLUETOOTH_SUPPORT
46 PKG_BUILD_DEPENDS
:=python3
/host
47 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host libffi
/host
49 include $(INCLUDE_DIR
)/host-build.mk
50 include $(INCLUDE_DIR
)/package.mk
52 define Package
/python3
/Default
56 TITLE
:=Python
$(PYTHON3_VERSION
) programming language
57 URL
:=https
://www.python.org
/
60 define Package
/python3
/Default
/description
61 Python is a dynamic object-oriented programming language that can be used
62 for many kinds of software development. It offers strong support for
63 integration with other languages and tools
, comes with extensive standard
64 libraries
, and can be learned in a few days. Many Python programmers
65 report substantial productivity gains and feel the language encourages
66 the development of higher quality
, more maintainable code.
69 define Package
/libpython3
70 $(call Package
/python3
/Default
)
71 TITLE
:=Python
$(PYTHON3_VERSION
) core library
72 DEPENDS
:=+libpthread
+zlib
73 ABI_VERSION
:=$(PYTHON3_VERSION
)
76 define Package
/libpython3
/description
77 This package contains only core Python library.
80 define Package
/python3-base
81 $(call Package
/python3
/Default
)
82 TITLE
:=Python
$(PYTHON3_VERSION
) interpreter
83 DEPENDS
:=+libpthread
+zlib
+libpython3
86 define Package
/python3-base
/description
87 This package contains only the interpreter and the bare minimum
88 for the interpreter to start.
91 define Package
/python3-light
92 $(call Package
/python3
/Default
)
93 TITLE
:=Python
$(PYTHON3_VERSION
) light installation
94 DEPENDS
:=+python3-base
+libffi
+libbz2
+PYTHON3_BLUETOOTH_SUPPORT
:bluez-libs
+libuuid
97 define Package
/python3-light
/config
98 source
"$(SOURCE)/Config-python3-light.in"
101 define Package
/python3-light
/description
102 This package is essentially the python3-base package plus
103 a few of the rarely used
(and big
) libraries stripped out
104 into separate packages.
107 PYTHON3_LIB_FILES_DEL
:=
109 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
110 PYTHON3_PACKAGES_DEPENDS
:=
111 define Py3BasePackage
112 PYTHON3_PACKAGES
+=$(1)
114 PYTHON3_PACKAGES_DEPENDS
+=$(1)
116 PYTHON3_LIB_FILES_DEL
+=$(2)
117 define Py3Package
/$(1)/filespec
119 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
120 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
121 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
124 Py3Package
/$(1)/install?
=:
127 include .
/files
/python3-package-
*.mk
129 define Package
/python3
130 $(call Package
/python3
/Default
)
131 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
134 define Package
/python3
/description
135 This package contains the
(almost
) full Python
install.
136 It
's python3-light + all other packages.
139 TARGET_CONFIGURE_OPTS+= \
140 READELF="$(TARGET_CROSS)readelf"
149 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
151 DISABLE_BLUETOOTH:= \
152 ac_cv_header_bluetooth_bluetooth_h=no \
153 ac_cv_header_bluetooth_h=no
156 --enable-optimizations \
160 --without-ensurepip \
162 $(if $(CONFIG_IPV6),--enable-ipv6) \
163 $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto) \
164 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
165 OPT="$(TARGET_CFLAGS)" \
166 $(if $(CONFIG_PYTHON3_BLUETOOTH_SUPPORT),,$(DISABLE_BLUETOOTH))
169 $(call Build/Prepare/Default)
170 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
173 ifdef CONFIG_PACKAGE_python3-setuptools
174 PYTHON3_SETUPTOOLS_BUILD:=1
177 ifdef CONFIG_PACKAGE_python3-pkg-resources
178 PYTHON3_SETUPTOOLS_BUILD:=1
181 ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
182 define Build/Compile/python3-setuptools
183 $(HOST_PYTHON3_PIP) \
184 --disable-pip-version-check \
185 --cache-dir "$(DL_DIR)/pip-cache" \
188 --root=$(PKG_BUILD_DIR)/install-setuptools \
190 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
191 $(call PatchDir,$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-setuptools,)
194 define Build/Compile/python3-setuptools
195 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
197 endif # CONFIG_PACKAGE_python3-setuptools
199 ifdef CONFIG_PACKAGE_python3-pip
200 define Build/Compile/python3-pip
201 $(HOST_PYTHON3_PIP) \
202 --disable-pip-version-check \
203 --cache-dir "$(DL_DIR)/pip-cache" \
206 --root=$(PKG_BUILD_DIR)/install-pip \
208 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
209 $(call PatchDir,$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-pip,)
212 define Build/Compile/python3-pip
213 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
215 endif # CONFIG_PACKAGE_python3-pip
218 $(call Build/Compile/Default)
219 # Use host pip to install python-setuptools
220 $(call Build/Compile/python3-setuptools)
221 $(call Build/Compile/python3-pip)
224 define Build/InstallDev
225 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
226 $(INSTALL_DIR) $(2)/bin
228 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
231 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
232 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
235 '^_PYTHON_HOST_PLATFORM
=' \
236 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile > \
237 $(1)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile-vars
239 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
240 $(1)/usr/lib/pkgconfig
242 $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
245 's|^prefix_real
=.
*$$$$|prefix_real
="$(PYTHON3_DIR)"|
' \
246 $(2)/bin/python$(PYTHON3_VERSION)-config
249 PYTHON3_BASE_LIB_FILES:= \
250 /usr/lib/python$(PYTHON3_VERSION)/encodings \
251 /usr/lib/python$(PYTHON3_VERSION)/_collections_abc.py \
252 /usr/lib/python$(PYTHON3_VERSION)/_sitebuiltins.py \
253 /usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
254 /usr/lib/python$(PYTHON3_VERSION)/_weakrefset.py \
255 /usr/lib/python$(PYTHON3_VERSION)/abc.py \
256 /usr/lib/python$(PYTHON3_VERSION)/codecs.py \
257 /usr/lib/python$(PYTHON3_VERSION)/genericpath.py \
258 /usr/lib/python$(PYTHON3_VERSION)/io.py \
259 /usr/lib/python$(PYTHON3_VERSION)/os.py \
260 /usr/lib/python$(PYTHON3_VERSION)/posixpath.py \
261 /usr/lib/python$(PYTHON3_VERSION)/site.py \
262 /usr/lib/python$(PYTHON3_VERSION)/sysconfig.py \
263 /usr/lib/python$(PYTHON3_VERSION)/stat.py
265 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
267 define Py3Package/python3-base/filespec
268 +|/usr/bin/python$(PYTHON3_VERSION)
269 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
272 define Py3Package/python3-light/filespec
273 +|/usr/lib/python$(PYTHON3_VERSION)
274 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/cygwinccompiler.py
275 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/command/wininst*
276 -|/usr/lib/python$(PYTHON3_VERSION)/ensurepip
277 -|/usr/lib/python$(PYTHON3_VERSION)/idlelib
278 -|/usr/lib/python$(PYTHON3_VERSION)/tkinter
279 -|/usr/lib/python$(PYTHON3_VERSION)/turtledemo
280 -|/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_test*.so
281 -|/usr/lib/python$(PYTHON3_VERSION)/pdb.doc
282 -|/usr/lib/python$(PYTHON3_VERSION)/test
283 -|/usr/lib/python$(PYTHON3_VERSION)/webbrowser.py
284 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
285 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
286 -|/usr/lib/python$(PYTHON3_VERSION)/_osx_support.py
287 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
290 define Package/libpython3/install
291 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
292 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/
293 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* $(1)/usr/lib/
296 define Py3Package/python3-base/install
297 $(INSTALL_DIR) $(1)/usr/bin
298 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python3
299 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python
300 # This depends on being called before filespec is processed
301 $(SED) 's|
$(TARGET_AR
)|
ar|g
;s|
$(TARGET_CROSS
)readelf|readelf|g
;s|
$(TARGET_CC
)|gcc|g
;s|
$(TARGET_CXX
)|g
++|g
' \
302 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py
305 Py3Package/python3-light/install:=:
306 Py3Package/python3/install:=:
308 define Py3Package/python3/filespec
313 -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
315 ifeq ($(HOST_OS),Linux)
317 -Wl,--no-as-needed -lrt
320 ifeq ($(HOST_OS),Darwin)
321 HOST_CONFIGURE_VARS += \
322 ac_cv_header_libintl_h=no
324 USE_PYTHON_CONFIG_PY=1
327 HOST_CONFIGURE_ARGS+= \
328 --enable-optimizations \
329 --with-ensurepip=upgrade \
330 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
335 define Host/Configure
336 $(SED) 's
/^ENABLE_USER_SITE
= None
$$$$/ENABLE_USER_SITE
= False
/' $(HOST_BUILD_DIR)/Lib/site.py
337 $(call Host/Configure/Default)
341 $(call Host/Compile/Default,python)
342 $(call Host/Compile/Default,sharedmods)
346 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
348 $(HOST_PYTHON3_PKG_DIR)/pkg_resources \
349 $(HOST_PYTHON3_PKG_DIR)/setuptools \
350 $(HOST_PYTHON3_PKG_DIR)/setuptools-* \
351 $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched* \
352 $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_*
354 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
356 $(HOST_PYTHON3_PKG_DIR)/pip \
357 $(HOST_PYTHON3_PKG_DIR)/pip-* \
358 $(HOST_PYTHON3_PKG_DIR)/.pip-patched* \
359 $(HOST_PYTHON3_PKG_DIR)/.pip_installed_*
361 $(call Host/Install/Default)
362 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
363 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-setuptools,)
364 touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
366 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
367 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-pip,)
368 touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
372 $(eval $(call HostBuild))
374 $(foreach package, $(PYTHON3_PACKAGES), \
375 $(eval $(call Py3Package,$(package))) \
376 $(eval $(call BuildPackage,$(package))) \
377 $(eval $(call BuildPackage,$(package)-src)) \
380 $(eval $(call BuildPackage,libpython3))
382 $(eval $(call Py3Package,python3-base))
383 $(eval $(call Py3Package,python3-light))
384 $(eval $(call Py3Package,python3))
386 $(eval $(call BuildPackage,python3-base))
387 $(eval $(call BuildPackage,python3-light))
388 $(eval $(call BuildPackage,python3))
390 $(eval $(call BuildPackage,python3-base-src))
391 $(eval $(call BuildPackage,python3-light-src))