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
:=80bf925f571da436b35210886cf79f6eb5fa5d6c571316b73568343451f77a19
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
38 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
39 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
41 PKG_CONFIG_DEPENDS
:= \
42 CONFIG_PACKAGE_python3-pkg-resources \
43 CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
45 PKG_BUILD_DEPENDS
:=bluez python3
/host
46 HOST_BUILD_DEPENDS
:=bzip2
/host libffi
/host
48 include $(INCLUDE_DIR
)/host-build.mk
49 include $(INCLUDE_DIR
)/package.mk
51 define Package
/python3
/Default
55 TITLE
:=Python
$(PYTHON3_VERSION
) programming language
56 URL
:=https
://www.python.org
/
59 define Package
/python3
/Default
/description
60 Python is a dynamic object-oriented programming language that can be used
61 for many kinds of software development. It offers strong support for
62 integration with other languages and tools
, comes with extensive standard
63 libraries
, and can be learned in a few days. Many Python programmers
64 report substantial productivity gains and feel the language encourages
65 the development of higher quality
, more maintainable code.
68 define Package
/libpython3
69 $(call Package
/python3
/Default
)
70 TITLE
:=Python
$(PYTHON3_VERSION
) core library
71 DEPENDS
:=+libpthread
+zlib
72 ABI_VERSION
:=$(PYTHON3_VERSION
)
75 define Package
/libpython3
/description
76 This package contains only core Python library.
79 define Package
/python3-base
80 $(call Package
/python3
/Default
)
81 TITLE
:=Python
$(PYTHON3_VERSION
) interpreter
82 DEPENDS
:=+libpthread
+zlib
+libpython3
85 define Package
/python3-base
/description
86 This package contains only the interpreter and the bare minimum
87 for the interpreter to start.
90 define Package
/python3-light
91 $(call Package
/python3
/Default
)
92 TITLE
:=Python
$(PYTHON3_VERSION
) light installation
93 DEPENDS
:=+python3-base
+libffi
+libbz2
96 define Package
/python3-light
/config
97 source
"$(SOURCE)/Config-python3-light.in"
100 define Package
/python3-light
/description
101 This package is essentially the python3-base package plus
102 a few of the rarely used
(and big
) libraries stripped out
103 into separate packages.
106 PYTHON3_LIB_FILES_DEL
:=
108 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
109 PYTHON3_PACKAGES_DEPENDS
:=
110 define Py3BasePackage
111 PYTHON3_PACKAGES
+=$(1)
113 PYTHON3_PACKAGES_DEPENDS
+=$(1)
115 PYTHON3_LIB_FILES_DEL
+=$(2)
116 define Py3Package
/$(1)/filespec
118 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
119 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
120 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
123 Py3Package
/$(1)/install?
=:
126 include .
/files
/python3-package-
*.mk
128 define Package
/python3
129 $(call Package
/python3
/Default
)
130 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
133 define Package
/python3
/description
134 This package contains the
(almost
) full Python
install.
135 It
's python3-light + all other packages.
140 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
142 # Workaround for hardfloat mips
143 # https://bugs.python.org/issue46265
144 ifneq ($(findstring mips,$(CONFIG_ARCH)),)
145 ifeq ($(CONFIG_HAS_FPU),y)
147 ax_cv_check_cflags___fno_semantic_interposition=no
152 PYTHONSTRICTEXTENSIONBUILD=1
155 --enable-optimizations \
159 --without-ensurepip \
161 --disable-test-modules \
162 $(if $(CONFIG_IPV6),--enable-ipv6) \
163 $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto) \
164 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
165 OPT="$(TARGET_CFLAGS)"
168 $(call Build/Prepare/Default)
169 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
172 ifdef CONFIG_PACKAGE_python3-setuptools
173 PYTHON3_SETUPTOOLS_BUILD:=1
176 ifdef CONFIG_PACKAGE_python3-pkg-resources
177 PYTHON3_SETUPTOOLS_BUILD:=1
180 ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
181 define Build/Compile/python3-setuptools
182 $(HOST_PYTHON3_PIP) \
183 --disable-pip-version-check \
184 --cache-dir "$(DL_DIR)/pip-cache" \
187 --root=$(PKG_BUILD_DIR)/install-setuptools \
189 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
190 $(call PatchDir,$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-setuptools,)
193 define Build/Compile/python3-setuptools
194 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
196 endif # CONFIG_PACKAGE_python3-setuptools
198 ifdef CONFIG_PACKAGE_python3-pip
199 define Build/Compile/python3-pip
200 $(HOST_PYTHON3_PIP) \
201 --disable-pip-version-check \
202 --cache-dir "$(DL_DIR)/pip-cache" \
205 --root=$(PKG_BUILD_DIR)/install-pip \
207 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
208 $(call PatchDir,$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-pip,)
211 define Build/Compile/python3-pip
212 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
214 endif # CONFIG_PACKAGE_python3-pip
217 $(call Build/Compile/Default)
218 # Use host pip to install python-setuptools
219 $(call Build/Compile/python3-setuptools)
220 $(call Build/Compile/python3-pip)
223 define Build/InstallDev
224 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
225 $(INSTALL_DIR) $(2)/bin
227 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
230 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
231 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
234 '^_PYTHON_HOST_PLATFORM
=' \
235 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile > \
236 $(1)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile-vars
238 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
239 $(1)/usr/lib/pkgconfig
241 $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
244 's|^prefix_real
=.
*$$$$|prefix_real
="$(PYTHON3_DIR)"|
' \
245 $(2)/bin/python$(PYTHON3_VERSION)-config
248 PYTHON3_BASE_LIB_FILES:= \
249 /usr/lib/python$(PYTHON3_VERSION)/encodings \
250 /usr/lib/python$(PYTHON3_VERSION)/_collections_abc.py \
251 /usr/lib/python$(PYTHON3_VERSION)/_sitebuiltins.py \
252 /usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
253 /usr/lib/python$(PYTHON3_VERSION)/_weakrefset.py \
254 /usr/lib/python$(PYTHON3_VERSION)/abc.py \
255 /usr/lib/python$(PYTHON3_VERSION)/codecs.py \
256 /usr/lib/python$(PYTHON3_VERSION)/genericpath.py \
257 /usr/lib/python$(PYTHON3_VERSION)/io.py \
258 /usr/lib/python$(PYTHON3_VERSION)/os.py \
259 /usr/lib/python$(PYTHON3_VERSION)/posixpath.py \
260 /usr/lib/python$(PYTHON3_VERSION)/site.py \
261 /usr/lib/python$(PYTHON3_VERSION)/sysconfig.py \
262 /usr/lib/python$(PYTHON3_VERSION)/stat.py
264 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
266 define Py3Package/python3-base/filespec
267 +|/usr/bin/python$(PYTHON3_VERSION)
268 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
271 define Py3Package/python3-light/filespec
272 +|/usr/lib/python$(PYTHON3_VERSION)
273 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/cygwinccompiler.py
274 -|/usr/lib/python$(PYTHON3_VERSION)/distutils/command/wininst*
275 -|/usr/lib/python$(PYTHON3_VERSION)/ensurepip
276 -|/usr/lib/python$(PYTHON3_VERSION)/idlelib
277 -|/usr/lib/python$(PYTHON3_VERSION)/tkinter
278 -|/usr/lib/python$(PYTHON3_VERSION)/turtledemo
279 -|/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_test*.so
280 -|/usr/lib/python$(PYTHON3_VERSION)/pdb.doc
281 -|/usr/lib/python$(PYTHON3_VERSION)/test
282 -|/usr/lib/python$(PYTHON3_VERSION)/webbrowser.py
283 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
284 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
285 -|/usr/lib/python$(PYTHON3_VERSION)/_osx_support.py
286 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
289 define Package/libpython3/install
290 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
291 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/
292 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* $(1)/usr/lib/
295 define Py3Package/python3-base/install
296 $(INSTALL_DIR) $(1)/usr/bin
297 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python3
298 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python
299 # This depends on being called before filespec is processed
300 $(SED) 's|
$(TARGET_AR
)|
ar|g
;s|
$(TARGET_CROSS
)readelf|readelf|g
;s|
$(TARGET_CC
)|gcc|g
;s|
$(TARGET_CXX
)|g
++|g
' \
301 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py
304 Py3Package/python3-light/install:=:
305 Py3Package/python3/install:=:
307 define Py3Package/python3/filespec
312 -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
314 ifeq ($(HOST_OS),Linux)
316 -Wl,--no-as-needed -lrt
319 # Would be nice to be able to do this, but hosts are very fiddly
320 # HOST_MAKE_VARS += \
321 # PYTHONSTRICTEXTENSIONBUILD=1
323 ifeq ($(HOST_OS),Darwin)
324 HOST_CONFIGURE_VARS += \
325 ac_cv_header_libintl_h=no
327 USE_PYTHON_CONFIG_PY=1
330 # FIXME: remove when removing patch '028-host-python-support-ssl-with-libressl.patch
'
334 HOST_CONFIGURE_ARGS+= \
335 --enable-optimizations \
336 --with-ensurepip=upgrade \
337 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
338 --with-ssl-default-suites=openssl \
341 --disable-test-modules \
344 define Host/Configure
345 $(SED) 's
/^ENABLE_USER_SITE
= None
$$$$/ENABLE_USER_SITE
= False
/' $(HOST_BUILD_DIR)/Lib/site.py
346 $(call Host/Configure/Default)
350 $(call Host/Compile/Default,python)
351 $(call Host/Compile/Default,sharedmods)
355 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
357 $(HOST_PYTHON3_PKG_DIR)/pkg_resources \
358 $(HOST_PYTHON3_PKG_DIR)/setuptools \
359 $(HOST_PYTHON3_PKG_DIR)/setuptools-* \
360 $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched* \
361 $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_*
363 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
365 $(HOST_PYTHON3_PKG_DIR)/pip \
366 $(HOST_PYTHON3_PKG_DIR)/pip-* \
367 $(HOST_PYTHON3_PKG_DIR)/.pip-patched* \
368 $(HOST_PYTHON3_PKG_DIR)/.pip_installed_*
370 $(call Host/Install/Default)
371 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
372 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-setuptools,)
373 touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
375 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
376 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-pip,)
377 touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
381 $(eval $(call HostBuild))
383 $(foreach package, $(PYTHON3_PACKAGES), \
384 $(eval $(call Py3Package,$(package))) \
385 $(eval $(call BuildPackage,$(package))) \
386 $(eval $(call BuildPackage,$(package)-src)) \
389 $(eval $(call BuildPackage,libpython3))
391 $(eval $(call Py3Package,python3-base))
392 $(eval $(call Py3Package,python3-light))
393 $(eval $(call Py3Package,python3))
395 $(eval $(call BuildPackage,python3-base))
396 $(eval $(call BuildPackage,python3-light))
397 $(eval $(call BuildPackage,python3))
399 $(eval $(call BuildPackage,python3-base-src))
400 $(eval $(call BuildPackage,python3-light-src))