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 # FIXME: if updating, get rid of [1] & [2] asap
20 PKG_HASH
:=f8145616e68c00041d1a6399b76387390388f8359581abc24432bb969b5e3c57
22 PKG_MAINTAINER
:=Alexandru Ardelean
<ardeleanalex@gmail.com
>, Jeffery To
<jeffery.to@gmail.com
>
23 PKG_LICENSE
:=Python
/2.0
24 PKG_LICENSE_FILES
:=LICENSE Doc
/copyright.rst Doc
/license.rst Modules
/_ctypes
/darwin
/LICENSE Modules
/_ctypes
/libffi_osx
/LICENSE Modules
/expat
/COPYING
25 PKG_CPE_ID
:=cpe
:/a
:python
:python
27 # This file provides the necsessary host build variables
28 include ..
/python3-host.mk
32 include ..
/python3-package.mk
37 HOST_BUILD_PARALLEL
:=1
39 PKG_BUILD_DIR
:=$(BUILD_DIR
)/Python-
$(PKG_VERSION
)
40 HOST_BUILD_DIR
:=$(BUILD_DIR_HOST
)/Python-
$(PKG_VERSION
)
42 PKG_CONFIG_DEPENDS
:= \
43 CONFIG_PACKAGE_python3-pkg-resources \
44 CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
46 PKG_BUILD_DEPENDS
:=bluez python3
/host
47 HOST_BUILD_DEPENDS
:=bzip2
/host expat
/host libffi
/host
49 include $(INCLUDE_DIR
)/host-build.mk
50 include $(INCLUDE_DIR
)/package.mk
52 define Package
/python3
/Default
56 TITLE
:=Python
$(PYTHON3_VERSION
) programming language
57 URL
:=https
://www.python.org
/
60 define Package
/python3
/Default
/description
61 Python is a dynamic object-oriented programming language that can be used
62 for many kinds of software development. It offers strong support for
63 integration with other languages and tools
, comes with extensive standard
64 libraries
, and can be learned in a few days. Many Python programmers
65 report substantial productivity gains and feel the language encourages
66 the development of higher quality
, more maintainable code.
69 define Package
/libpython3
70 $(call Package
/python3
/Default
)
71 TITLE
:=Python
$(PYTHON3_VERSION
) core library
72 DEPENDS
:=+libpthread
+zlib
73 ABI_VERSION
:=$(PYTHON3_VERSION
)
76 define Package
/libpython3
/description
77 This package contains only core Python library.
80 define Package
/python3-base
81 $(call Package
/python3
/Default
)
82 TITLE
:=Python
$(PYTHON3_VERSION
) interpreter
83 DEPENDS
:=+libpthread
+zlib
+libpython3
86 define Package
/python3-base
/description
87 This package contains only the interpreter and the bare minimum
88 for the interpreter to start.
91 define Package
/python3-light
92 $(call Package
/python3
/Default
)
93 TITLE
:=Python
$(PYTHON3_VERSION
) light installation
94 DEPENDS
:=+python3-base
+libffi
+libbz2
+libuuid
97 define Package
/python3-light
/config
98 source
"$(SOURCE)/Config-python3-light.in"
101 define Package
/python3-light
/description
102 This package is essentially the python3-base package plus
103 a few of the rarely used
(and big
) libraries stripped out
104 into separate packages.
107 PYTHON3_LIB_FILES_DEL
:=
109 PYTHON3_SO_SUFFIX
:=cpython-
$(PYTHON3_VERSION_MAJOR
)$(PYTHON3_VERSION_MINOR
).so
110 PYTHON3_PACKAGES_DEPENDS
:=
111 define Py3BasePackage
112 PYTHON3_PACKAGES
+=$(1)
114 PYTHON3_PACKAGES_DEPENDS
+=$(1)
116 PYTHON3_LIB_FILES_DEL
+=$(2)
117 define Py3Package
/$(1)/filespec
119 $(subst $(space
),$(newline
),$(foreach lib_file
,$(2),+|
$(lib_file
)))
120 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
121 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
124 Py3Package
/$(1)/install?
=:
127 include .
/files
/python3-package-
*.mk
129 define Package
/python3
130 $(call Package
/python3
/Default
)
131 DEPENDS
:=+python3-light
$(foreach package
,$(PYTHON3_PACKAGES_DEPENDS
),+$(package
))
134 define Package
/python3
/description
135 This package contains the
(almost
) full Python
install.
136 It
's python3-light + all other packages.
139 TARGET_CONFIGURE_OPTS+= \
140 READELF="$(TARGET_CROSS)readelf"
149 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
152 --enable-optimizations \
156 --without-ensurepip \
158 $(if $(CONFIG_IPV6),--enable-ipv6) \
159 $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto) \
160 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
161 OPT="$(TARGET_CFLAGS)"
164 $(call Build/Prepare/Default)
165 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
168 ifdef CONFIG_PACKAGE_python3-setuptools
169 PYTHON3_SETUPTOOLS_BUILD:=1
172 ifdef CONFIG_PACKAGE_python3-pkg-resources
173 PYTHON3_SETUPTOOLS_BUILD:=1
176 ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
177 define Build/Compile/python3-setuptools
178 $(HOST_PYTHON3_PIP) \
179 --disable-pip-version-check \
180 --cache-dir "$(DL_DIR)/pip-cache" \
183 --root=$(PKG_BUILD_DIR)/install-setuptools \
185 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
186 $(call PatchDir,$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-setuptools,)
189 define Build/Compile/python3-setuptools
190 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
192 endif # CONFIG_PACKAGE_python3-setuptools
194 ifdef CONFIG_PACKAGE_python3-pip
195 define Build/Compile/python3-pip
196 $(HOST_PYTHON3_PIP) \
197 --disable-pip-version-check \
198 --cache-dir "$(DL_DIR)/pip-cache" \
201 --root=$(PKG_BUILD_DIR)/install-pip \
203 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
204 # FIXME: [1] get rid of this asap; 'patch
' doesn't like Windows endings
, and this file is full of them...
205 # I actually tried this in a number of ways and the only way to fix this is to implement
206 # a poor-man's dos2unix using sed.
207 # The issue is with the pip package; it seems that it throws in some Windows line-endings
208 # and 'patch' won't handle them. So, we do a "dos2unix" and then patch.
209 # We can get rid of this once this is solved upstream and in pip:
210 # https://github.com/pypa/pep517/pull/130
211 sed
's/\r//' -i
$(PKG_BUILD_DIR
)/install-pip
/usr
/lib
/python
$(PYTHON3_VERSION
)/site-packages
/pip
/_vendor
/pep517
/in_process
/__init__.py
212 $(call PatchDir
,$(PKG_BUILD_DIR
)/install-pip
/usr
/lib
/python
$(PYTHON3_VERSION
)/site-packages
,.
/patches-pip
,)
215 define Build
/Compile
/python3-pip
216 ls
$(PKG_BUILD_DIR
)/Lib
/ensurepip
/_bundled
/pip-
$(PYTHON3_PIP_VERSION
)-py3-none-any.whl
218 endif # CONFIG_PACKAGE_python3-pip
221 $(call Build
/Compile
/Default
)
222 # Use host pip to install python-setuptools
223 $(call Build
/Compile
/python3-setuptools
)
224 $(call Build
/Compile
/python3-pip
)
227 define Build
/InstallDev
228 $(INSTALL_DIR
) $(1)/usr
/include $(1)/usr
/lib
$(1)/usr
/lib
/pkgconfig
229 $(INSTALL_DIR
) $(2)/bin
231 $(PKG_INSTALL_DIR
)/usr
/include/python
$(PYTHON3_VERSION
) \
234 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
) \
235 $(PKG_INSTALL_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION
).so
* \
238 '^_PYTHON_HOST_PLATFORM=' \
239 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
)/config-
$(PYTHON3_VERSION
)/Makefile
> \
240 $(1)/usr
/lib
/python
$(PYTHON3_VERSION
)/config-
$(PYTHON3_VERSION
)/Makefile-vars
242 $(PKG_INSTALL_DIR
)/usr
/lib
/pkgconfig
/python
*.
pc \
243 $(1)/usr
/lib
/pkgconfig
245 $(PKG_INSTALL_DIR
)/usr
/bin
/python
$(PYTHON3_VERSION
)-config \
248 's|^prefix_real=.*$$$$|prefix_real="$(PYTHON3_DIR)"|' \
249 $(2)/bin
/python
$(PYTHON3_VERSION
)-config
252 PYTHON3_BASE_LIB_FILES
:= \
253 /usr
/lib
/python
$(PYTHON3_VERSION
)/encodings \
254 /usr
/lib
/python
$(PYTHON3_VERSION
)/_collections_abc.py \
255 /usr
/lib
/python
$(PYTHON3_VERSION
)/_sitebuiltins.py \
256 /usr
/lib
/python
$(PYTHON3_VERSION
)/_sysconfigdata.py \
257 /usr
/lib
/python
$(PYTHON3_VERSION
)/_weakrefset.py \
258 /usr
/lib
/python
$(PYTHON3_VERSION
)/abc.py \
259 /usr
/lib
/python
$(PYTHON3_VERSION
)/codecs.py \
260 /usr
/lib
/python
$(PYTHON3_VERSION
)/genericpath.py \
261 /usr
/lib
/python
$(PYTHON3_VERSION
)/io.py \
262 /usr
/lib
/python
$(PYTHON3_VERSION
)/os.py \
263 /usr
/lib
/python
$(PYTHON3_VERSION
)/posixpath.py \
264 /usr
/lib
/python
$(PYTHON3_VERSION
)/site.py \
265 /usr
/lib
/python
$(PYTHON3_VERSION
)/sysconfig.py \
266 /usr
/lib
/python
$(PYTHON3_VERSION
)/stat.py
268 PYTHON3_LIB_FILES_DEL
+=$(PYTHON3_BASE_LIB_FILES
)
270 define Py3Package
/python3-base
/filespec
271 +|
/usr
/bin
/python
$(PYTHON3_VERSION
)
272 $(subst $(space
),$(newline
),$(foreach lib_file
,$(PYTHON3_BASE_LIB_FILES
),+|
$(lib_file
)))
275 define Py3Package
/python3-light
/filespec
276 +|
/usr
/lib
/python
$(PYTHON3_VERSION
)
277 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/distutils
/cygwinccompiler.py
278 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/distutils
/command
/wininst
*
279 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/ensurepip
280 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/idlelib
281 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/tkinter
282 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/turtledemo
283 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/lib-dynload
/_test
*.so
284 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/pdb.doc
285 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/test
286 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/webbrowser.py
287 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/test
288 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/*/tests
289 -|
/usr
/lib
/python
$(PYTHON3_VERSION
)/_osx_support.py
290 $(subst $(space
),$(newline
),$(foreach lib_file
,$(PYTHON3_LIB_FILES_DEL
),-|
$(lib_file
)))
293 define Package
/libpython3
/install
294 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
295 $(INSTALL_DIR
) $(1)/usr
/lib
/python
$(PYTHON3_VERSION
)/lib-dynload
/
296 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpython
$(PYTHON3_VERSION
).so
* $(1)/usr
/lib
/
299 define Py3Package
/python3-base
/install
300 $(INSTALL_DIR
) $(1)/usr
/bin
301 $(LN
) python
$(PYTHON3_VERSION
) $(1)/usr
/bin
/python3
302 $(LN
) python
$(PYTHON3_VERSION
) $(1)/usr
/bin
/python
303 # This depends on being called before filespec is processed
304 $(SED
) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
305 $(PKG_INSTALL_DIR
)/usr
/lib
/python
$(PYTHON3_VERSION
)/_sysconfigdata.py
308 Py3Package
/python3-light
/install:=:
309 Py3Package
/python3
/install:=:
311 define Py3Package
/python3
/filespec
316 -Wl
$(comma
)-rpath
$(comma
)$(STAGING_DIR_HOSTPKG
)/lib
318 ifeq ($(HOST_OS
),Linux
)
320 -Wl
,--no-as-needed
-lrt
323 ifeq ($(HOST_OS
),Darwin
)
324 HOST_CONFIGURE_VARS
+= \
325 ac_cv_header_libintl_h
=no
327 USE_PYTHON_CONFIG_PY
=1
330 HOST_CONFIGURE_ARGS
+= \
331 --enable-optimizations \
332 --with-ensurepip
=upgrade \
333 --with-system-expat
=$(STAGING_DIR_HOSTPKG
) \
338 define Host
/Configure
339 $(SED
) 's/^ENABLE_USER_SITE = None$$$$/ENABLE_USER_SITE = False/' $(HOST_BUILD_DIR
)/Lib
/site.py
340 $(call Host
/Configure
/Default
)
344 $(call Host
/Compile
/Default
,python
)
345 $(call Host
/Compile
/Default
,sharedmods
)
349 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)),,
351 $(HOST_PYTHON3_PKG_DIR
)/pkg_resources \
352 $(HOST_PYTHON3_PKG_DIR
)/setuptools \
353 $(HOST_PYTHON3_PKG_DIR
)/setuptools-
* \
354 $(HOST_PYTHON3_PKG_DIR
)/.setuptools-patched
* \
355 $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
*
357 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)),,
359 $(HOST_PYTHON3_PKG_DIR
)/pip \
360 $(HOST_PYTHON3_PKG_DIR
)/pip-
* \
361 $(HOST_PYTHON3_PKG_DIR
)/.pip-patched
* \
362 $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
*
364 $(call Host
/Install
/Default
)
365 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)),,
366 $(call HostPatchDir
,$(HOST_PYTHON3_PKG_DIR
),.
/patches-setuptools
,)
367 touch
$(HOST_PYTHON3_PKG_DIR
)/.setuptools_installed_
$(PYTHON3_SETUPTOOLS_VERSION
)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE
)
369 $(if
$(wildcard $(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)),,
370 # FIXME: [2] get rid of this asap; same as [1]
371 sed
's/\r//' -i
$(HOST_PYTHON3_PKG_DIR
)/pip
/_vendor
/pep517
/in_process
/__init__.py
372 $(call HostPatchDir
,$(HOST_PYTHON3_PKG_DIR
),.
/patches-pip
,)
373 touch
$(HOST_PYTHON3_PKG_DIR
)/.pip_installed_
$(PYTHON3_PIP_VERSION
)-$(PYTHON3_PIP_PKG_RELEASE
)
377 $(eval
$(call HostBuild
))
379 $(foreach package
, $(PYTHON3_PACKAGES
), \
380 $(eval
$(call Py3Package
,$(package
))) \
381 $(eval
$(call BuildPackage
,$(package
))) \
382 $(eval
$(call BuildPackage
,$(package
)-src
)) \
385 $(eval
$(call BuildPackage
,libpython3
))
387 $(eval
$(call Py3Package
,python3-base
))
388 $(eval
$(call Py3Package
,python3-light
))
389 $(eval
$(call Py3Package
,python3
))
391 $(eval
$(call BuildPackage
,python3-base
))
392 $(eval
$(call BuildPackage
,python3-light
))
393 $(eval
$(call BuildPackage
,python3
))
395 $(eval
$(call BuildPackage
,python3-base-src
))
396 $(eval
$(call BuildPackage
,python3-light-src
))