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
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_BUILD_DEPENDS
:=bluez python3
/host python-build
/host python-installer
/host python-wheel
/host
45 HOST_BUILD_DEPENDS
:=bzip2
/host libffi
/host
47 include $(INCLUDE_DIR
)/host-build.mk
48 include $(INCLUDE_DIR
)/package.mk
50 define Package
/python3
/Default
54 TITLE
:=Python
$(PYTHON3_VERSION
)
55 URL
:=https
://www.python.org
/
58 define Package
/python3
/Default
/description
59 Python is an interpreted
, interactive
, object-oriented programming
60 language. It incorporates modules
, exceptions
, dynamic typing
, very high
61 level dynamic data types
, and classes. It supports multiple programming
62 paradigms beyond object-oriented programming
, such
as procedural and
63 functional programming. Python combines remarkable power with very clear
64 syntax. It has interfaces to many system calls and libraries
, as well
as
65 to various window systems
, and is extensible in C or C
++. It is also
66 usable
as an extension language for applications that need a
67 programmable interface. Finally
, Python is portable
: it runs on many
68 Unix variants including Linux and macOS
, and on Windows.
71 define Package
/libpython3
72 $(call Package
/python3
/Default
)
75 ABI_VERSION
:=$(PYTHON3_VERSION
)
78 define Package
/libpython3
/description
79 $(call Package
/python3
/Default
/description
)
81 This package contains only core Python library.
84 define Package
/python3-base
85 $(call Package
/python3
/Default
)
86 TITLE
+= base interpreter
90 define Package
/python3-base
/description
91 $(call Package
/python3
/Default
/description
)
93 This package contains only the interpreter and the bare minimum for the
97 define Package
/python3-light
98 $(call Package
/python3
/Default
)
99 TITLE
+= light installation
100 DEPENDS
:=+python3-base
+libbz2
+zlib
103 define Package
/python3-light
/config
104 source
"$(SOURCE)/Config-python3-light.in"
107 define Package
/python3-light
/description
108 $(call Package
/python3
/Default
/description
)
110 This package installs the base interpreter package and contains the most
111 commonly used parts of the standard library.
114 PYTHON3_LIB_FILES_DEL
:=
116 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
117 PYTHON3_PACKAGES_DEPENDS
:=
118 define Py3BasePackage
119 PYTHON3_PACKAGES
+=$(1)
121 PYTHON3_PACKAGES_DEPENDS
+=$(1)
123 PYTHON3_LIB_FILES_DEL
+=$(2)
124 define Py3Package
/$(1)/filespec
126 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
127 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
128 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
131 Py3Package
/$(1)/install?
=:
134 include .
/files
/python3-package-
*.mk
136 define Package
/python3
137 $(call Package
/python3
/Default
)
138 TITLE
+= programming language
139 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
142 define Package
/python3
/description
143 $(call Package
/python3
/Default
/description
)
145 This package installs almost
all parts of the standard Python
149 # Set READELF here so that the exact same readelf program name can be
150 # replaced in _sysconfigdata.py (in Py3Package/python3-base/install)
151 TARGET_CONFIGURE_OPTS
+= \
152 READELF
="$(TARGET_CROSS)readelf"
156 -L
$(STAGING_DIR
)/usr
/lib
-L
$(STAGING_DIR
)/lib
158 # Bypass configure tests for cross compilation
160 ac_cv_buggy_getaddrinfo
=no \
161 ac_cv_file__dev_ptc
=no \
162 ac_cv_file__dev_ptmx
=yes
164 # Do not link with libbsd for flock
165 # https://github.com/openwrt/packages/issues/21161
167 ac_cv_lib_bsd_flock
=no
169 # Disable stdlib modules
170 # Check for a better way in the future: https://github.com/python/cpython/issues/98558
172 py_cv_module__tkinter
=n
/a \
175 # Workaround for hardfloat mips
176 # https://bugs.python.org/issue46265
177 ifneq ($(findstring mips
,$(CONFIG_ARCH
)),)
178 ifeq ($(CONFIG_HAS_FPU
),y
)
180 ax_cv_check_cflags___fno_semantic_interposition
=no
185 PYTHONSTRICTEXTENSIONBUILD
=1
188 --enable-optimizations \
190 --disable-test-modules \
191 --with-build-python \
194 --without-ensurepip \
195 $(if
$(CONFIG_IPV6
),--enable-ipv6
) \
196 $(if
$(findstring mips
,$(CONFIG_ARCH
)),,--with-lto
)
198 define Build
/InstallDev
199 $(INSTALL_DIR
) $(1)/usr
/include $(1)/usr
/lib
$(1)/usr
/lib
/pkgconfig
200 $(INSTALL_DIR
) $(2)/bin
202 $(PKG_INSTALL_DIR
)/usr
/include/python
$(PYTHON3_VERSION
) \
205 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
) \
206 $(PKG_INSTALL_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION
).so
* \
209 '^_PYTHON_HOST_PLATFORM=' \
210 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
)/config-
$(PYTHON3_VERSION
)/Makefile
> \
211 $(1)/usr
/lib
/python
$(PYTHON3_VERSION
)/config-
$(PYTHON3_VERSION
)/Makefile-vars
213 $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/python
*.
pc \
214 $(1)/usr
/lib
/pkgconfig
216 $(PKG_INSTALL_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION
)-config \
219 's|^prefix_real=.*$$$$|prefix_real="$(PYTHON3_DIR)"|' \
220 $(2)/bin
/python
$(PYTHON3_VERSION
)-config
223 PYTHON3_BASE_LIB_FILES
:= \
224 /usr
/lib
/python
$(PYTHON3_VERSION
)/encodings \
225 /usr
/lib
/python
$(PYTHON3_VERSION
)/_collections_abc.py \
226 /usr
/lib
/python
$(PYTHON3_VERSION
)/_sitebuiltins.py \
227 /usr
/lib
/python
$(PYTHON3_VERSION
)/_sysconfigdata.py \
228 /usr
/lib
/python
$(PYTHON3_VERSION
)/_weakrefset.py \
229 /usr
/lib
/python
$(PYTHON3_VERSION
)/abc.py \
230 /usr
/lib
/python
$(PYTHON3_VERSION
)/codecs.py \
231 /usr
/lib
/python
$(PYTHON3_VERSION
)/genericpath.py \
232 /usr
/lib
/python
$(PYTHON3_VERSION
)/io.py \
233 /usr
/lib
/python
$(PYTHON3_VERSION
)/os.py \
234 /usr
/lib
/python
$(PYTHON3_VERSION
)/posixpath.py \
235 /usr
/lib
/python
$(PYTHON3_VERSION
)/site.py \
236 /usr
/lib
/python
$(PYTHON3_VERSION
)/sysconfig.py \
237 /usr
/lib
/python
$(PYTHON3_VERSION
)/stat.py
239 PYTHON3_LIB_FILES_DEL
+=$(PYTHON3_BASE_LIB_FILES
)
241 define Py3Package
/python3-base
/filespec
242 +|
/usr
/bin
/python
$(PYTHON3_VERSION
)
243 $(subst $(space
),$(newline
),$(foreach lib_file
,$(PYTHON3_BASE_LIB_FILES
),+|
$(lib_file
)))
246 define Py3Package
/python3-light
/filespec
247 +|
/usr
/lib
/python
$(PYTHON3_VERSION
)
248 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/distutils
/cygwinccompiler.py
249 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/distutils
/command
/wininst
*
250 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/idlelib
251 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/tkinter
252 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/turtledemo
253 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/lib-dynload
/_test
*.so
254 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/pdb.doc
255 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/test
256 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/webbrowser.py
257 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
258 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
259 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/_osx_support.py
260 $(subst $(space
),$(newline
),$(foreach lib_file
,$(PYTHON3_LIB_FILES_DEL
),-|
$(lib_file
)))
263 define Package
/libpython3
/install
264 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
265 $(INSTALL_DIR
) $(1)/usr
/lib
/python
$(PYTHON3_VERSION
)/lib-dynload
/
266 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION
).so
* $(1)/usr
/lib
/
269 define Py3Package
/python3-base
/install
270 $(INSTALL_DIR
) $(1)/usr
/bin
271 $(LN
) python
$(PYTHON3_VERSION
) $(1)/usr
/bin
/python3
272 $(LN
) python
$(PYTHON3_VERSION
) $(1)/usr
/bin
/python
273 # This depends on being called before filespec is processed
274 $(SED
) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
275 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
)/_sysconfigdata.py
278 Py3Package
/python3-light
/install:=:
279 Package
/python3
/install:=:
281 # libuuid is provided by e2fsprogs and uuid/uuid.h is moved into
282 # $(STAGING_DIR_HOST)/include/e2fsprogs
284 -I
$(STAGING_DIR_HOST
)/include/e2fsprogs
286 -I
$(STAGING_DIR_HOST
)/include/e2fsprogs
289 -Wl
$(comma
)-rpath
$(comma
)$(STAGING_DIR_HOSTPKG
)/lib
291 ifeq ($(HOST_OS
),Linux
)
293 -Wl
,--no-as-needed
-lrt
296 # Would be nice to be able to do this, but hosts are very fiddly
297 # HOST_MAKE_VARS += \
298 # PYTHONSTRICTEXTENSIONBUILD=1
300 # Bypass configure test
301 HOST_CONFIGURE_VARS
+= \
302 ac_cv_working_openssl_hashlib
=yes
304 ifeq ($(HOST_OS
),Darwin
)
305 HOST_CONFIGURE_VARS
+= \
306 ac_cv_header_libintl_h
=no
308 USE_PYTHON_CONFIG_PY
=1
311 HOST_CONFIGURE_ARGS
+= \
312 --enable-optimizations \
313 --disable-test-modules \
314 --with-ensurepip
=upgrade \
315 --with-ssl-default-suites
=openssl \
316 --with-system-expat \
319 define Host
/Configure
320 $(SED
) 's/^ENABLE_USER_SITE = None$$$$/ENABLE_USER_SITE = False/' $(HOST_BUILD_DIR
)/Lib
/site.py
321 $(call Host
/Configure
/Default
)
322 ls
$(HOST_BUILD_DIR
)/Lib
/ensurepip
/_bundled
/setuptools-
$(PYTHON3_SETUPTOOLS_VERSION
)-py3-none-any.whl
323 ls
$(HOST_BUILD_DIR
)/Lib
/ensurepip
/_bundled
/pip-
$(PYTHON3_PIP_VERSION
)-py3-none-any.whl
327 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)),,
329 $(HOST_PYTHON3_PKG_DIR
)/pkg_resources \
330 $(HOST_PYTHON3_PKG_DIR
)/setuptools \
331 $(HOST_PYTHON3_PKG_DIR
)/setuptools-
* \
332 $(HOST_PYTHON3_PKG_DIR
)/.setuptools-patched
* \
333 $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
*
335 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)),,
337 $(HOST_PYTHON3_PKG_DIR
)/pip \
338 $(HOST_PYTHON3_PKG_DIR
)/pip-
* \
339 $(HOST_PYTHON3_PKG_DIR
)/.pip-patched
* \
340 $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
*
342 $(call Host
/Install
/Default
)
343 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)),,
344 $(call HostPatchDir
,$(HOST_PYTHON3_PKG_DIR
),.
/patches-host-setuptools
,)
345 touch
$(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)
347 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)),,
348 $(call HostPatchDir
,$(HOST_PYTHON3_PKG_DIR
),.
/patches-host-pip
,)
349 touch
$(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)
353 $(eval
$(call HostBuild
))
355 $(foreach package
, $(PYTHON3_PACKAGES
), \
356 $(eval
$(call Py3Package
,$(package
))) \
357 $(eval
$(call BuildPackage
,$(package
))) \
358 $(eval
$(call BuildPackage
,$(package
)-src
)) \
361 $(eval
$(call BuildPackage
,libpython3
))
362 $(eval
$(call BuildPackage
,python3
))
364 $(eval
$(call Py3Package
,python3-base
))
365 $(eval
$(call Py3Package
,python3-light
))
367 $(eval
$(call BuildPackage
,python3-base
))
368 $(eval
$(call BuildPackage
,python3-light
))
370 $(eval
$(call BuildPackage
,python3-base-src
))
371 $(eval
$(call BuildPackage
,python3-light-src
))