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
:=2f0e409df2ab57aa9fc4cbddfb976af44e4e55bf6f619eee6bc5c2297264a7f6
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
35 HOST_BUILD_PARALLEL
:=1
36 # LTO is handled here individually, see --with-lto below
37 # "no-lto" prevents CONFIG_USE_LTO to add additional and interfering flags
38 PKG_BUILD_FLAGS
:=no-lto
40 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
41 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
43 PKG_BUILD_DEPENDS
:=bluez python3
/host python-build
/host python-installer
/host python-wheel
/host
44 HOST_BUILD_DEPENDS
:=bzip2
/host libffi
/host
46 include $(INCLUDE_DIR
)/host-build.mk
47 include $(INCLUDE_DIR
)/package.mk
49 define Package
/python3
/Default
53 TITLE
:=Python
$(PYTHON3_VERSION
)
54 URL
:=https
://www.python.org
/
57 define Package
/python3
/Default
/description
58 Python is an interpreted
, interactive
, object-oriented programming
59 language. It incorporates modules
, exceptions
, dynamic typing
, very high
60 level dynamic data types
, and classes. It supports multiple programming
61 paradigms beyond object-oriented programming
, such
as procedural and
62 functional programming. Python combines remarkable power with very clear
63 syntax. It has interfaces to many system calls and libraries
, as well
as
64 to various window systems
, and is extensible in C or C
++. It is also
65 usable
as an extension language for applications that need a
66 programmable interface. Finally
, Python is portable
: it runs on many
67 Unix variants including Linux and macOS
, and on Windows.
70 define Package
/libpython3
71 $(call Package
/python3
/Default
)
74 ABI_VERSION
:=$(PYTHON3_VERSION
)
77 define Package
/libpython3
/description
78 $(call Package
/python3
/Default
/description
)
80 This package contains only core Python library.
83 define Package
/python3-base
84 $(call Package
/python3
/Default
)
85 TITLE
+= base interpreter
89 define Package
/python3-base
/description
90 $(call Package
/python3
/Default
/description
)
92 This package contains only the interpreter and the bare minimum for the
96 define Package
/python3-light
97 $(call Package
/python3
/Default
)
98 TITLE
+= light installation
99 DEPENDS
:=+python3-base
+libbz2
+zlib
102 define Package
/python3-light
/config
103 source
"$(SOURCE)/Config-python3-light.in"
106 define Package
/python3-light
/description
107 $(call Package
/python3
/Default
/description
)
109 This package installs the base interpreter package and contains the most
110 commonly used parts of the standard library.
113 PYTHON3_LIB_FILES_DEL
:=
115 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
)-*.so
116 PYTHON3_PACKAGES_DEPENDS
:=
117 define Py3BasePackage
118 PYTHON3_PACKAGES
+=$(1)
120 PYTHON3_PACKAGES_DEPENDS
+=$(1)
122 PYTHON3_LIB_FILES_DEL
+=$(2)
124 Py3Package
/$(1)/filespec
=
126 define Py3Package
/$(1)/filespec
127 $(foreach lib_file
,$(2),
132 Py3Package
/$(1)/install?
=:
135 include .
/files
/python3-package-
*.mk
137 define Package
/python3
138 $(call Package
/python3
/Default
)
139 TITLE
+= programming language
140 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
143 define Package
/python3
/description
144 $(call Package
/python3
/Default
/description
)
146 This package installs almost
all parts of the standard Python
150 # Set READELF here so that the exact same readelf program name can be
151 # replaced in _sysconfigdata_*.py (in Build/Install)
152 TARGET_CONFIGURE_OPTS
+= \
153 READELF
="$(TARGET_CROSS)readelf"
157 -L
$(STAGING_DIR
)/usr
/lib
-L
$(STAGING_DIR
)/lib
159 # Bypass configure tests for cross compilation
161 ac_cv_buggy_getaddrinfo
=no \
162 ac_cv_file__dev_ptc
=no \
163 ac_cv_file__dev_ptmx
=yes
165 # Do not link with libbsd for flock
166 # https://github.com/openwrt/packages/issues/21161
168 ac_cv_lib_bsd_flock
=no
170 # Disable stdlib modules
171 # Check for a better way in the future: https://github.com/python/cpython/issues/98558
173 py_cv_module__tkinter
=n
/a \
176 # Workaround for hardfloat mips
177 # https://bugs.python.org/issue46265
178 ifneq ($(findstring mips
,$(CONFIG_ARCH
)),)
179 ifeq ($(CONFIG_HAS_FPU
),y
)
181 ax_cv_check_cflags___fno_semantic_interposition
=no
186 PYTHONSTRICTEXTENSIONBUILD
=1
189 --enable-optimizations \
191 --disable-test-modules \
192 --with-build-python \
195 --without-ensurepip \
196 $(if
$(CONFIG_IPV6
),--enable-ipv6
) \
197 $(if
$(findstring mips
,$(CONFIG_ARCH
)),,--with-lto
)
200 $(call Build
/Install
/Default
,)
202 $(SED
) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
203 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
)/_sysconfigdata_
*.py \
204 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
)/config-
$(PYTHON3_VERSION
)-*/Makefile
207 define Build
/InstallDev
208 $(INSTALL_DIR
) $(1)/usr
/include
210 $(PKG_INSTALL_DIR
)/usr
/include/python
$(PYTHON3_VERSION
) \
213 $(INSTALL_DIR
) $(1)/usr
/lib
215 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
) \
216 $(PKG_INSTALL_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION
).so
* \
219 $(INSTALL_DIR
) $(1)/usr
/lib
/python
$(PYTHON3_VERSION
)/openwrt
221 '^(_PYTHON_HOST_PLATFORM|ABIFLAGS|MACHDEP|MULTIARCH)=' \
222 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
)/config-
$(PYTHON3_VERSION
)-*/Makefile
> \
223 $(1)/usr
/lib
/python
$(PYTHON3_VERSION
)/openwrt
/Makefile-vars
225 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
227 $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/python
*.
pc \
228 $(1)/usr
/lib
/pkgconfig
230 $(INSTALL_DIR
) $(2)/bin
232 $(PKG_INSTALL_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION
)-config \
235 's|^prefix_real=.*$$$$|prefix_real="$(PYTHON3_DIR)"|' \
236 $(2)/bin
/python
$(PYTHON3_VERSION
)-config
239 PYTHON3_BASE_LIB_FILES
:= \
240 /usr
/lib
/python
$(PYTHON3_VERSION
)/encodings \
241 /usr
/lib
/python
$(PYTHON3_VERSION
)/_collections_abc.py \
242 /usr
/lib
/python
$(PYTHON3_VERSION
)/_sitebuiltins.py \
243 /usr
/lib
/python
$(PYTHON3_VERSION
)/_sysconfigdata_
*.py \
244 /usr
/lib
/python
$(PYTHON3_VERSION
)/_weakrefset.py \
245 /usr
/lib
/python
$(PYTHON3_VERSION
)/abc.py \
246 /usr
/lib
/python
$(PYTHON3_VERSION
)/codecs.py \
247 /usr
/lib
/python
$(PYTHON3_VERSION
)/genericpath.py \
248 /usr
/lib
/python
$(PYTHON3_VERSION
)/io.py \
249 /usr
/lib
/python
$(PYTHON3_VERSION
)/os.py \
250 /usr
/lib
/python
$(PYTHON3_VERSION
)/posixpath.py \
251 /usr
/lib
/python
$(PYTHON3_VERSION
)/site.py \
252 /usr
/lib
/python
$(PYTHON3_VERSION
)/sysconfig.py \
253 /usr
/lib
/python
$(PYTHON3_VERSION
)/stat.py
255 PYTHON3_LIB_FILES_DEL
+=$(PYTHON3_BASE_LIB_FILES
)
257 define Py3Package
/python3-base
/filespec
258 +|
/usr
/bin
/python
$(PYTHON3_VERSION
)
259 $(foreach lib_file
,$(PYTHON3_BASE_LIB_FILES
),
264 define Py3Package
/python3-light
/filespec
265 +|
/usr
/lib
/python
$(PYTHON3_VERSION
)
266 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/distutils
/cygwinccompiler.py
267 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/idlelib
268 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/tkinter
269 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/turtledemo
270 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/webbrowser.py
271 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/_osx_support.py
272 $(foreach lib_file
,$(filter /usr
/lib
/python
$(PYTHON3_VERSION
)/%,$(PYTHON3_LIB_FILES_DEL
)),
277 define Package
/libpython3
/install
278 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
279 $(INSTALL_DIR
) $(1)/usr
/lib
/python
$(PYTHON3_VERSION
)/lib-dynload
/
280 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION
).so
* $(1)/usr
/lib
/
283 define Py3Package
/python3-base
/install
284 $(INSTALL_DIR
) $(1)/usr
/bin
285 $(LN
) python
$(PYTHON3_VERSION
) $(1)/usr
/bin
/python3
286 $(LN
) python
$(PYTHON3_VERSION
) $(1)/usr
/bin
/python
289 Py3Package
/python3-light
/install:=:
290 Package
/python3
/install:=:
292 # libuuid is provided by e2fsprogs and uuid/uuid.h is moved into
293 # $(STAGING_DIR_HOST)/include/e2fsprogs
295 -I
$(STAGING_DIR_HOST
)/include/e2fsprogs
297 -I
$(STAGING_DIR_HOST
)/include/e2fsprogs
300 -Wl
$(comma
)-rpath
$(comma
)$(STAGING_DIR_HOSTPKG
)/lib
302 ifeq ($(HOST_OS
),Linux
)
304 -Wl
,--no-as-needed
-lrt
307 # Would be nice to be able to do this, but hosts are very fiddly
308 # HOST_MAKE_VARS += \
309 # PYTHONSTRICTEXTENSIONBUILD=1
311 # Bypass configure test
312 HOST_CONFIGURE_VARS
+= \
313 ac_cv_working_openssl_hashlib
=yes
315 ifeq ($(HOST_OS
),Darwin
)
316 HOST_CONFIGURE_VARS
+= \
317 ac_cv_header_libintl_h
=no
319 USE_PYTHON_CONFIG_PY
=1
322 HOST_CONFIGURE_ARGS
+= \
323 --enable-optimizations \
324 --disable-test-modules \
325 --with-ensurepip
=upgrade \
326 --with-ssl-default-suites
=openssl \
327 --with-system-expat \
330 define Host
/Configure
331 $(SED
) 's/^ENABLE_USER_SITE = None$$$$/ENABLE_USER_SITE = False/' $(HOST_BUILD_DIR
)/Lib
/site.py
332 $(call Host
/Configure
/Default
)
333 ls
$(HOST_BUILD_DIR
)/Lib
/ensurepip
/_bundled
/setuptools-
$(PYTHON3_SETUPTOOLS_VERSION
)-py3-none-any.whl
334 ls
$(HOST_BUILD_DIR
)/Lib
/ensurepip
/_bundled
/pip-
$(PYTHON3_PIP_VERSION
)-py3-none-any.whl
338 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)),,
340 $(HOST_PYTHON3_PKG_DIR
)/pkg_resources \
341 $(HOST_PYTHON3_PKG_DIR
)/setuptools \
342 $(HOST_PYTHON3_PKG_DIR
)/setuptools-
* \
343 $(HOST_PYTHON3_PKG_DIR
)/.setuptools-patched
* \
344 $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
*
346 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)),,
348 $(HOST_PYTHON3_PKG_DIR
)/pip \
349 $(HOST_PYTHON3_PKG_DIR
)/pip-
* \
350 $(HOST_PYTHON3_PKG_DIR
)/.pip-patched
* \
351 $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
*
353 $(call Host
/Install
/Default
)
354 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)),,
355 $(call HostPatchDir
,$(HOST_PYTHON3_PKG_DIR
),.
/patches-host-setuptools
,)
356 touch
$(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)
358 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)),,
359 $(call HostPatchDir
,$(HOST_PYTHON3_PKG_DIR
),.
/patches-host-pip
,)
360 touch
$(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)
364 $(eval
$(call HostBuild
))
366 $(foreach package
, $(PYTHON3_PACKAGES
), \
367 $(eval
$(call Py3Package
,$(package
))) \
368 $(eval
$(call BuildPackage
,$(package
))) \
369 $(eval
$(call BuildPackage
,$(package
)-src
)) \
372 $(eval
$(call BuildPackage
,libpython3
))
373 $(eval
$(call BuildPackage
,python3
))
375 $(eval
$(call Py3Package
,python3-base
))
376 $(eval
$(call Py3Package
,python3-light
))
378 $(eval
$(call BuildPackage
,python3-base
))
379 $(eval
$(call BuildPackage
,python3-light
))
381 $(eval
$(call BuildPackage
,python3-base-src
))
382 $(eval
$(call BuildPackage
,python3-light-src
))