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
:=6eed8415b7516fb2f260906db5d48dd4c06acc0cb24a7d6cc15296a604dcdc48
21 PKG_MAINTAINER
:=Jeffery To
<jeffery.to@gmail.com
>
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
37 # LTO is handled here individually, see --with-lto below
38 # "no-lto" prevents CONFIG_USE_LTO to add additional and interfering flags
39 PKG_BUILD_FLAGS
:=no-lto
41 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
42 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
44 PKG_CONFIG_DEPENDS
:= \
45 CONFIG_PACKAGE_python3-pkg-resources \
46 CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
48 PKG_BUILD_DEPENDS
:=bluez python3
/host
49 HOST_BUILD_DEPENDS
:=bzip2
/host libffi
/host
51 include $(INCLUDE_DIR
)/host-build.mk
52 include $(INCLUDE_DIR
)/package.mk
54 define Package
/python3
/Default
58 TITLE
:=Python
$(PYTHON3_VERSION
) programming language
59 URL
:=https
://www.python.org
/
62 define Package
/python3
/Default
/description
63 Python is a dynamic object-oriented programming language that can be used
64 for many kinds of software development. It offers strong support for
65 integration with other languages and tools
, comes with extensive standard
66 libraries
, and can be learned in a few days. Many Python programmers
67 report substantial productivity gains and feel the language encourages
68 the development of higher quality
, more maintainable code.
71 define Package
/libpython3
72 $(call Package
/python3
/Default
)
73 TITLE
:=Python
$(PYTHON3_VERSION
) core library
74 DEPENDS
:=+libpthread
+zlib
75 ABI_VERSION
:=$(PYTHON3_VERSION
)
78 define Package
/libpython3
/description
79 This package contains only core Python library.
82 define Package
/python3-base
83 $(call Package
/python3
/Default
)
84 TITLE
:=Python
$(PYTHON3_VERSION
) interpreter
85 DEPENDS
:=+libpthread
+zlib
+libpython3
88 define Package
/python3-base
/description
89 This package contains only the interpreter and the bare minimum
90 for the interpreter to start.
93 define Package
/python3-light
94 $(call Package
/python3
/Default
)
95 TITLE
:=Python
$(PYTHON3_VERSION
) light installation
96 DEPENDS
:=+python3-base
+libffi
+libbz2
99 define Package
/python3-light
/config
100 source
"$(SOURCE)/Config-python3-light.in"
103 define Package
/python3-light
/description
104 This package is essentially the python3-base package plus
105 a few of the rarely used
(and big
) libraries stripped out
106 into separate packages.
109 PYTHON3_LIB_FILES_DEL
:=
111 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
112 PYTHON3_PACKAGES_DEPENDS
:=
113 define Py3BasePackage
114 PYTHON3_PACKAGES
+=$(1)
116 PYTHON3_PACKAGES_DEPENDS
+=$(1)
118 PYTHON3_LIB_FILES_DEL
+=$(2)
119 define Py3Package
/$(1)/filespec
121 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
122 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
123 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
126 Py3Package
/$(1)/install?
=:
129 include .
/files
/python3-package-
*.mk
131 define Package
/python3
132 $(call Package
/python3
/Default
)
133 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
136 define Package
/python3
/description
137 This package contains the
(almost
) full Python
install.
138 It
's python3-light + all other packages.
143 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
145 # Workaround for hardfloat mips
146 # https://bugs.python.org/issue46265
147 ifneq ($(findstring mips,$(CONFIG_ARCH)),)
148 ifeq ($(CONFIG_HAS_FPU),y)
150 ax_cv_check_cflags___fno_semantic_interposition=no
155 PYTHONSTRICTEXTENSIONBUILD=1
158 --enable-optimizations \
162 --without-ensurepip \
164 --disable-test-modules \
165 $(if $(CONFIG_IPV6),--enable-ipv6) \
166 $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto) \
167 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
168 OPT="$(TARGET_CFLAGS)"
171 $(call Build/Prepare/Default)
172 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
175 ifdef CONFIG_PACKAGE_python3-setuptools
176 PYTHON3_SETUPTOOLS_BUILD:=1
179 ifdef CONFIG_PACKAGE_python3-pkg-resources
180 PYTHON3_SETUPTOOLS_BUILD:=1
183 ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
184 define Build/Compile/python3-setuptools
185 $(HOST_PYTHON3_PIP_VARS) \
186 $(HOST_PYTHON3_PIP) \
190 --root=$(PKG_BUILD_DIR)/install-setuptools \
192 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
193 $(call PatchDir,$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-setuptools,)
196 define Build/Compile/python3-setuptools
197 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
199 endif # CONFIG_PACKAGE_python3-setuptools
201 ifdef CONFIG_PACKAGE_python3-pip
202 define Build/Compile/python3-pip
203 $(HOST_PYTHON3_PIP_VARS) \
204 $(HOST_PYTHON3_PIP) \
208 --root=$(PKG_BUILD_DIR)/install-pip \
210 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
211 $(call PatchDir,$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-pip,)
214 define Build/Compile/python3-pip
215 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
217 endif # CONFIG_PACKAGE_python3-pip
220 $(call Build/Compile/Default)
221 # Use host pip to install python-setuptools
222 $(call Build/Compile/python3-setuptools)
223 $(call Build/Compile/python3-pip)
226 define Build/InstallDev
227 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
228 $(INSTALL_DIR) $(2)/bin
230 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
233 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
234 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
237 '^_PYTHON_HOST_PLATFORM
=' \
238 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile > \
239 $(1)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile-vars
241 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
242 $(1)/usr/lib/pkgconfig
244 $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
247 's|^prefix_real
=.
*$$$$|prefix_real
="$(PYTHON3_DIR)"|
' \
248 $(2)/bin/python$(PYTHON3_VERSION)-config
251 PYTHON3_BASE_LIB_FILES:= \
252 /usr/lib/python$(PYTHON3_VERSION)/encodings \
253 /usr/lib/python$(PYTHON3_VERSION)/_collections_abc.py \
254 /usr/lib/python$(PYTHON3_VERSION)/_sitebuiltins.py \
255 /usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
256 /usr/lib/python$(PYTHON3_VERSION)/_weakrefset.py \
257 /usr/lib/python$(PYTHON3_VERSION)/abc.py \
258 /usr/lib/python$(PYTHON3_VERSION)/codecs.py \
259 /usr/lib/python$(PYTHON3_VERSION)/genericpath.py \
260 /usr/lib/python$(PYTHON3_VERSION)/io.py \
261 /usr/lib/python$(PYTHON3_VERSION)/os.py \
262 /usr/lib/python$(PYTHON3_VERSION)/posixpath.py \
263 /usr/lib/python$(PYTHON3_VERSION)/site.py \
264 /usr/lib/python$(PYTHON3_VERSION)/sysconfig.py \
265 /usr/lib/python$(PYTHON3_VERSION)/stat.py
267 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
269 define Py3Package/python3-base/filespec
270 +|/usr/bin/python$(PYTHON3_VERSION)
271 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
274 define Py3Package/python3-light/filespec
275 +|/usr/lib/python$(PYTHON3_VERSION)
276 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/cygwinccompiler.py
277 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/command/wininst*
278 -|/usr/lib/python$(PYTHON3_VERSION)/idlelib
279 -|/usr/lib/python$(PYTHON3_VERSION)/tkinter
280 -|/usr/lib/python$(PYTHON3_VERSION)/turtledemo
281 -|/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_test*.so
282 -|/usr/lib/python$(PYTHON3_VERSION)/pdb.doc
283 -|/usr/lib/python$(PYTHON3_VERSION)/test
284 -|/usr/lib/python$(PYTHON3_VERSION)/webbrowser.py
285 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
286 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
287 -|/usr/lib/python$(PYTHON3_VERSION)/_osx_support.py
288 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
291 define Package/libpython3/install
292 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
293 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/
294 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* $(1)/usr/lib/
297 define Py3Package/python3-base/install
298 $(INSTALL_DIR) $(1)/usr/bin
299 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python3
300 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python
301 # This depends on being called before filespec is processed
302 $(SED) 's|
$(TARGET_AR
)|
ar|g
;s|
$(TARGET_CROSS
)readelf|readelf|g
;s|
$(TARGET_CC
)|gcc|g
;s|
$(TARGET_CXX
)|g
++|g
' \
303 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py
306 Py3Package/python3-light/install:=:
307 Py3Package/python3/install:=:
309 define Py3Package/python3/filespec
314 -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
316 ifeq ($(HOST_OS),Linux)
318 -Wl,--no-as-needed -lrt
321 # Would be nice to be able to do this, but hosts are very fiddly
322 # HOST_MAKE_VARS += \
323 # PYTHONSTRICTEXTENSIONBUILD=1
325 ifeq ($(HOST_OS),Darwin)
326 HOST_CONFIGURE_VARS += \
327 ac_cv_header_libintl_h=no
329 USE_PYTHON_CONFIG_PY=1
332 HOST_CONFIGURE_ARGS+= \
333 --enable-optimizations \
334 --with-ensurepip=upgrade \
335 --with-system-expat=$(STAGING_DIR_HOST) \
336 --with-ssl-default-suites=openssl \
339 --disable-test-modules \
342 define Host/Configure
343 $(SED) 's
/^ENABLE_USER_SITE
= None
$$$$/ENABLE_USER_SITE
= False
/' $(HOST_BUILD_DIR)/Lib/site.py
344 $(call Host/Configure/Default)
348 $(call Host/Compile/Default,python)
349 $(call Host/Compile/Default,sharedmods)
353 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
355 $(HOST_PYTHON3_PKG_DIR)/pkg_resources \
356 $(HOST_PYTHON3_PKG_DIR)/setuptools \
357 $(HOST_PYTHON3_PKG_DIR)/setuptools-* \
358 $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched* \
359 $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_*
361 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
363 $(HOST_PYTHON3_PKG_DIR)/pip \
364 $(HOST_PYTHON3_PKG_DIR)/pip-* \
365 $(HOST_PYTHON3_PKG_DIR)/.pip-patched* \
366 $(HOST_PYTHON3_PKG_DIR)/.pip_installed_*
368 $(call Host/Install/Default)
369 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
370 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-setuptools,)
371 touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
373 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
374 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-pip,)
375 touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
379 $(eval $(call HostBuild))
381 $(foreach package, $(PYTHON3_PACKAGES), \
382 $(eval $(call Py3Package,$(package))) \
383 $(eval $(call BuildPackage,$(package))) \
384 $(eval $(call BuildPackage,$(package)-src)) \
387 $(eval $(call BuildPackage,libpython3))
389 $(eval $(call Py3Package,python3-base))
390 $(eval $(call Py3Package,python3-light))
391 $(eval $(call Py3Package,python3))
393 $(eval $(call BuildPackage,python3-base))
394 $(eval $(call BuildPackage,python3-light))
395 $(eval $(call BuildPackage,python3))
397 $(eval $(call BuildPackage,python3-base-src))
398 $(eval $(call BuildPackage,python3-light-src))