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 python-build
/host python-installer
/host python-wheel
/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.
141 # Set READELF here so that the exact same readelf program name can be
142 # replaced in _sysconfigdata.py (in Py3Package/python3-base/install)
143 TARGET_CONFIGURE_OPTS+= \
144 READELF="$(TARGET_CROSS)readelf"
148 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
150 # Workaround for hardfloat mips
151 # https://bugs.python.org/issue46265
152 ifneq ($(findstring mips,$(CONFIG_ARCH)),)
153 ifeq ($(CONFIG_HAS_FPU),y)
155 ax_cv_check_cflags___fno_semantic_interposition=no
160 PYTHONSTRICTEXTENSIONBUILD=1
163 --enable-optimizations \
167 --without-ensurepip \
168 --disable-test-modules \
169 $(if $(CONFIG_IPV6),--enable-ipv6) \
170 $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto) \
171 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
172 OPT="$(TARGET_CFLAGS)"
175 $(call Build/Prepare/Default)
176 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
179 ifdef CONFIG_PACKAGE_python3-setuptools
180 PYTHON3_SETUPTOOLS_BUILD:=1
183 ifdef CONFIG_PACKAGE_python3-pkg-resources
184 PYTHON3_SETUPTOOLS_BUILD:=1
187 ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
188 define Build/Compile/python3-setuptools
189 $(HOST_PYTHON3_PIP_VARS) \
190 $(HOST_PYTHON3_PIP) \
194 --root=$(PKG_BUILD_DIR)/install-setuptools \
196 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
197 $(call PatchDir,$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-setuptools,)
200 define Build/Compile/python3-setuptools
201 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
203 endif # CONFIG_PACKAGE_python3-setuptools
205 ifdef CONFIG_PACKAGE_python3-pip
206 define Build/Compile/python3-pip
207 $(HOST_PYTHON3_PIP_VARS) \
208 $(HOST_PYTHON3_PIP) \
212 --root=$(PKG_BUILD_DIR)/install-pip \
214 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
215 $(call PatchDir,$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-pip,)
218 define Build/Compile/python3-pip
219 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
221 endif # CONFIG_PACKAGE_python3-pip
224 $(call Build/Compile/Default)
225 # Use host pip to install python-setuptools
226 $(call Build/Compile/python3-setuptools)
227 $(call Build/Compile/python3-pip)
230 define Build/InstallDev
231 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
232 $(INSTALL_DIR) $(2)/bin
234 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
237 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
238 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
241 '^_PYTHON_HOST_PLATFORM
=' \
242 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile > \
243 $(1)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile-vars
245 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
246 $(1)/usr/lib/pkgconfig
248 $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
251 's|^prefix_real
=.
*$$$$|prefix_real
="$(PYTHON3_DIR)"|
' \
252 $(2)/bin/python$(PYTHON3_VERSION)-config
255 PYTHON3_BASE_LIB_FILES:= \
256 /usr/lib/python$(PYTHON3_VERSION)/encodings \
257 /usr/lib/python$(PYTHON3_VERSION)/_collections_abc.py \
258 /usr/lib/python$(PYTHON3_VERSION)/_sitebuiltins.py \
259 /usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
260 /usr/lib/python$(PYTHON3_VERSION)/_weakrefset.py \
261 /usr/lib/python$(PYTHON3_VERSION)/abc.py \
262 /usr/lib/python$(PYTHON3_VERSION)/codecs.py \
263 /usr/lib/python$(PYTHON3_VERSION)/genericpath.py \
264 /usr/lib/python$(PYTHON3_VERSION)/io.py \
265 /usr/lib/python$(PYTHON3_VERSION)/os.py \
266 /usr/lib/python$(PYTHON3_VERSION)/posixpath.py \
267 /usr/lib/python$(PYTHON3_VERSION)/site.py \
268 /usr/lib/python$(PYTHON3_VERSION)/sysconfig.py \
269 /usr/lib/python$(PYTHON3_VERSION)/stat.py
271 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
273 define Py3Package/python3-base/filespec
274 +|/usr/bin/python$(PYTHON3_VERSION)
275 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
278 define Py3Package/python3-light/filespec
279 +|/usr/lib/python$(PYTHON3_VERSION)
280 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/cygwinccompiler.py
281 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/command/wininst*
282 -|/usr/lib/python$(PYTHON3_VERSION)/idlelib
283 -|/usr/lib/python$(PYTHON3_VERSION)/tkinter
284 -|/usr/lib/python$(PYTHON3_VERSION)/turtledemo
285 -|/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_test*.so
286 -|/usr/lib/python$(PYTHON3_VERSION)/pdb.doc
287 -|/usr/lib/python$(PYTHON3_VERSION)/test
288 -|/usr/lib/python$(PYTHON3_VERSION)/webbrowser.py
289 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
290 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
291 -|/usr/lib/python$(PYTHON3_VERSION)/_osx_support.py
292 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
295 define Package/libpython3/install
296 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
297 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/
298 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* $(1)/usr/lib/
301 define Py3Package/python3-base/install
302 $(INSTALL_DIR) $(1)/usr/bin
303 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python3
304 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python
305 # This depends on being called before filespec is processed
306 $(SED) 's|
$(TARGET_AR
)|
ar|g
;s|
$(TARGET_CROSS
)readelf|readelf|g
;s|
$(TARGET_CC
)|gcc|g
;s|
$(TARGET_CXX
)|g
++|g
' \
307 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py
310 Py3Package/python3-light/install:=:
311 Py3Package/python3/install:=:
313 define Py3Package/python3/filespec
318 -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
320 ifeq ($(HOST_OS),Linux)
322 -Wl,--no-as-needed -lrt
325 # Would be nice to be able to do this, but hosts are very fiddly
326 # HOST_MAKE_VARS += \
327 # PYTHONSTRICTEXTENSIONBUILD=1
329 ifeq ($(HOST_OS),Darwin)
330 HOST_CONFIGURE_VARS += \
331 ac_cv_header_libintl_h=no
333 USE_PYTHON_CONFIG_PY=1
336 HOST_CONFIGURE_ARGS+= \
337 --enable-optimizations \
338 --with-ensurepip=upgrade \
339 --with-system-expat=$(STAGING_DIR_HOST) \
340 --with-ssl-default-suites=openssl \
342 --disable-test-modules \
345 define Host/Configure
346 $(SED) 's
/^ENABLE_USER_SITE
= None
$$$$/ENABLE_USER_SITE
= False
/' $(HOST_BUILD_DIR)/Lib/site.py
347 $(call Host/Configure/Default)
351 $(call Host/Compile/Default,python)
352 $(call Host/Compile/Default,sharedmods)
356 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
358 $(HOST_PYTHON3_PKG_DIR)/pkg_resources \
359 $(HOST_PYTHON3_PKG_DIR)/setuptools \
360 $(HOST_PYTHON3_PKG_DIR)/setuptools-* \
361 $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched* \
362 $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_*
364 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
366 $(HOST_PYTHON3_PKG_DIR)/pip \
367 $(HOST_PYTHON3_PKG_DIR)/pip-* \
368 $(HOST_PYTHON3_PKG_DIR)/.pip-patched* \
369 $(HOST_PYTHON3_PKG_DIR)/.pip_installed_*
371 $(call Host/Install/Default)
372 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
373 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-setuptools,)
374 touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
376 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
377 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-pip,)
378 touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
382 $(eval $(call HostBuild))
384 $(foreach package, $(PYTHON3_PACKAGES), \
385 $(eval $(call Py3Package,$(package))) \
386 $(eval $(call BuildPackage,$(package))) \
387 $(eval $(call BuildPackage,$(package)-src)) \
390 $(eval $(call BuildPackage,libpython3))
392 $(eval $(call Py3Package,python3-base))
393 $(eval $(call Py3Package,python3-light))
394 $(eval $(call Py3Package,python3))
396 $(eval $(call BuildPackage,python3-base))
397 $(eval $(call BuildPackage,python3-light))
398 $(eval $(call BuildPackage,python3))
400 $(eval $(call BuildPackage,python3-base-src))
401 $(eval $(call BuildPackage,python3-light-src))