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
:=8a5db99c961a7ecf27c75956189c9602c968751f11dbeae2b900dbff1c085b5e
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
) programming language
55 URL
:=https
://www.python.org
/
58 define Package
/python3
/Default
/description
59 Python is a dynamic object-oriented programming language that can be used
60 for many kinds of software development. It offers strong support for
61 integration with other languages and tools
, comes with extensive standard
62 libraries
, and can be learned in a few days. Many Python programmers
63 report substantial productivity gains and feel the language encourages
64 the development of higher quality
, more maintainable code.
67 define Package
/libpython3
68 $(call Package
/python3
/Default
)
69 TITLE
:=Python
$(PYTHON3_VERSION
) core library
71 ABI_VERSION
:=$(PYTHON3_VERSION
)
74 define Package
/libpython3
/description
75 This package contains only core Python library.
78 define Package
/python3-base
79 $(call Package
/python3
/Default
)
80 TITLE
:=Python
$(PYTHON3_VERSION
) interpreter
84 define Package
/python3-base
/description
85 This package contains only the interpreter and the bare minimum
86 for the interpreter to start.
89 define Package
/python3-light
90 $(call Package
/python3
/Default
)
91 TITLE
:=Python
$(PYTHON3_VERSION
) light installation
92 DEPENDS
:=+python3-base
+libbz2
+zlib
95 define Package
/python3-light
/config
96 source
"$(SOURCE)/Config-python3-light.in"
99 define Package
/python3-light
/description
100 This package is essentially the python3-base package plus
101 a few of the rarely used
(and big
) libraries stripped out
102 into separate packages.
105 PYTHON3_LIB_FILES_DEL
:=
107 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
108 PYTHON3_PACKAGES_DEPENDS
:=
109 define Py3BasePackage
110 PYTHON3_PACKAGES
+=$(1)
112 PYTHON3_PACKAGES_DEPENDS
+=$(1)
114 PYTHON3_LIB_FILES_DEL
+=$(2)
115 define Py3Package
/$(1)/filespec
117 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
118 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
119 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
122 Py3Package
/$(1)/install?
=:
125 include .
/files
/python3-package-
*.mk
127 define Package
/python3
128 $(call Package
/python3
/Default
)
129 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
132 define Package
/python3
/description
133 This package contains the
(almost
) full Python
install.
134 It
's python3-light + all other packages.
137 # Set READELF here so that the exact same readelf program name can be
138 # replaced in _sysconfigdata.py (in Py3Package/python3-base/install)
139 TARGET_CONFIGURE_OPTS+= \
140 READELF="$(TARGET_CROSS)readelf"
144 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
146 # Bypass configure tests for cross compilation
148 ac_cv_buggy_getaddrinfo=no \
149 ac_cv_file__dev_ptc=no \
150 ac_cv_file__dev_ptmx=yes
152 # Do not link with libbsd for flock
153 # https://github.com/openwrt/packages/issues/21161
155 ac_cv_lib_bsd_flock=no
157 # Disable stdlib modules
158 # Check for a better way in the future: https://github.com/python/cpython/issues/98558
160 py_cv_module__tkinter=n/a \
163 # Workaround for hardfloat mips
164 # https://bugs.python.org/issue46265
165 ifneq ($(findstring mips,$(CONFIG_ARCH)),)
166 ifeq ($(CONFIG_HAS_FPU),y)
168 ax_cv_check_cflags___fno_semantic_interposition=no
173 PYTHONSTRICTEXTENSIONBUILD=1
176 --enable-optimizations \
178 --disable-test-modules \
179 --with-build-python \
182 --without-ensurepip \
183 $(if $(CONFIG_IPV6),--enable-ipv6) \
184 $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto)
186 define Build/InstallDev
187 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
188 $(INSTALL_DIR) $(2)/bin
190 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
193 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
194 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
197 '^_PYTHON_HOST_PLATFORM
=' \
198 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile > \
199 $(1)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile-vars
201 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
202 $(1)/usr/lib/pkgconfig
204 $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
207 's|^prefix_real
=.
*$$$$|prefix_real
="$(PYTHON3_DIR)"|
' \
208 $(2)/bin/python$(PYTHON3_VERSION)-config
211 PYTHON3_BASE_LIB_FILES:= \
212 /usr/lib/python$(PYTHON3_VERSION)/encodings \
213 /usr/lib/python$(PYTHON3_VERSION)/_collections_abc.py \
214 /usr/lib/python$(PYTHON3_VERSION)/_sitebuiltins.py \
215 /usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
216 /usr/lib/python$(PYTHON3_VERSION)/_weakrefset.py \
217 /usr/lib/python$(PYTHON3_VERSION)/abc.py \
218 /usr/lib/python$(PYTHON3_VERSION)/codecs.py \
219 /usr/lib/python$(PYTHON3_VERSION)/genericpath.py \
220 /usr/lib/python$(PYTHON3_VERSION)/io.py \
221 /usr/lib/python$(PYTHON3_VERSION)/os.py \
222 /usr/lib/python$(PYTHON3_VERSION)/posixpath.py \
223 /usr/lib/python$(PYTHON3_VERSION)/site.py \
224 /usr/lib/python$(PYTHON3_VERSION)/sysconfig.py \
225 /usr/lib/python$(PYTHON3_VERSION)/stat.py
227 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
229 define Py3Package/python3-base/filespec
230 +|/usr/bin/python$(PYTHON3_VERSION)
231 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
234 define Py3Package/python3-light/filespec
235 +|/usr/lib/python$(PYTHON3_VERSION)
236 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/cygwinccompiler.py
237 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/command/wininst*
238 -|/usr/lib/python$(PYTHON3_VERSION)/idlelib
239 -|/usr/lib/python$(PYTHON3_VERSION)/tkinter
240 -|/usr/lib/python$(PYTHON3_VERSION)/turtledemo
241 -|/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_test*.so
242 -|/usr/lib/python$(PYTHON3_VERSION)/pdb.doc
243 -|/usr/lib/python$(PYTHON3_VERSION)/test
244 -|/usr/lib/python$(PYTHON3_VERSION)/webbrowser.py
245 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
246 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
247 -|/usr/lib/python$(PYTHON3_VERSION)/_osx_support.py
248 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
251 define Package/libpython3/install
252 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
253 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/
254 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* $(1)/usr/lib/
257 define Py3Package/python3-base/install
258 $(INSTALL_DIR) $(1)/usr/bin
259 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python3
260 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python
261 # This depends on being called before filespec is processed
262 $(SED) 's|
$(TARGET_AR
)|
ar|g
;s|
$(TARGET_CROSS
)readelf|readelf|g
;s|
$(TARGET_CC
)|gcc|g
;s|
$(TARGET_CXX
)|g
++|g
' \
263 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py
266 Py3Package/python3-light/install:=:
267 Py3Package/python3/install:=:
269 define Py3Package/python3/filespec
273 # libuuid is provided by e2fsprogs and uuid/uuid.h is moved into
274 # $(STAGING_DIR_HOST)/include/e2fsprogs
276 -I$(STAGING_DIR_HOST)/include/e2fsprogs
278 -I$(STAGING_DIR_HOST)/include/e2fsprogs
281 -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
283 ifeq ($(HOST_OS),Linux)
285 -Wl,--no-as-needed -lrt
288 # Would be nice to be able to do this, but hosts are very fiddly
289 # HOST_MAKE_VARS += \
290 # PYTHONSTRICTEXTENSIONBUILD=1
292 # Bypass configure test
293 HOST_CONFIGURE_VARS += \
294 ac_cv_working_openssl_hashlib=yes
296 ifeq ($(HOST_OS),Darwin)
297 HOST_CONFIGURE_VARS += \
298 ac_cv_header_libintl_h=no
300 USE_PYTHON_CONFIG_PY=1
303 HOST_CONFIGURE_ARGS += \
304 --enable-optimizations \
305 --disable-test-modules \
306 --with-ensurepip=upgrade \
307 --with-ssl-default-suites=openssl \
308 --with-system-expat \
311 define Host/Configure
312 $(SED) 's
/^ENABLE_USER_SITE
= None
$$$$/ENABLE_USER_SITE
= False
/' $(HOST_BUILD_DIR)/Lib/site.py
313 $(call Host/Configure/Default)
314 ls $(HOST_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
315 ls $(HOST_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
319 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
321 $(HOST_PYTHON3_PKG_DIR)/pkg_resources \
322 $(HOST_PYTHON3_PKG_DIR)/setuptools \
323 $(HOST_PYTHON3_PKG_DIR)/setuptools-* \
324 $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched* \
325 $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_*
327 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
329 $(HOST_PYTHON3_PKG_DIR)/pip \
330 $(HOST_PYTHON3_PKG_DIR)/pip-* \
331 $(HOST_PYTHON3_PKG_DIR)/.pip-patched* \
332 $(HOST_PYTHON3_PKG_DIR)/.pip_installed_*
334 $(call Host/Install/Default)
335 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
336 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-host-setuptools,)
337 touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
339 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
340 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-host-pip,)
341 touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
345 $(eval $(call HostBuild))
347 $(foreach package, $(PYTHON3_PACKAGES), \
348 $(eval $(call Py3Package,$(package))) \
349 $(eval $(call BuildPackage,$(package))) \
350 $(eval $(call BuildPackage,$(package)-src)) \
353 $(eval $(call BuildPackage,libpython3))
355 $(eval $(call Py3Package,python3-base))
356 $(eval $(call Py3Package,python3-light))
357 $(eval $(call Py3Package,python3))
359 $(eval $(call BuildPackage,python3-base))
360 $(eval $(call BuildPackage,python3-light))
361 $(eval $(call BuildPackage,python3))
363 $(eval $(call BuildPackage,python3-base-src))
364 $(eval $(call BuildPackage,python3-light-src))