python3: Fix package descriptions
[feed/packages.git] / lang / python / python3 / Makefile
1 #
2 # Copyright (C) 2006-2016 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 # The file included below defines PYTHON3_VERSION
11 include ../python3-version.mk
12
13 PKG_NAME:=python3
14 PKG_RELEASE:=1
15 PKG_VERSION:=$(PYTHON3_VERSION).$(PYTHON3_VERSION_MICRO)
16
17 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
18 PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
19 PKG_HASH:=2f0e409df2ab57aa9fc4cbddfb976af44e4e55bf6f619eee6bc5c2297264a7f6
20
21 PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
22 PKG_LICENSE:=PSF-2.0
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
25
26 # This file provides the necsessary host build variables
27 include ../python3-host.mk
28
29 # For Py3Package
30 PYTHON3_PKG_BUILD:=0
31 include ../python3-package.mk
32
33 PKG_FIXUP:=autoreconf
34 PKG_INSTALL:=1
35 PKG_BUILD_PARALLEL:=1
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
40
41 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
42 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
43
44 PKG_BUILD_DEPENDS:=bluez python3/host python-build/host python-installer/host python-wheel/host
45 HOST_BUILD_DEPENDS:=bzip2/host libffi/host
46
47 include $(INCLUDE_DIR)/host-build.mk
48 include $(INCLUDE_DIR)/package.mk
49
50 define Package/python3/Default
51 SUBMENU:=Python
52 SECTION:=lang
53 CATEGORY:=Languages
54 TITLE:=Python $(PYTHON3_VERSION)
55 URL:=https://www.python.org/
56 endef
57
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.
69 endef
70
71 define Package/libpython3
72 $(call Package/python3/Default)
73 TITLE+= core library
74 DEPENDS:=+libpthread
75 ABI_VERSION:=$(PYTHON3_VERSION)
76 endef
77
78 define Package/libpython3/description
79 $(call Package/python3/Default/description)
80
81 This package contains only core Python library.
82 endef
83
84 define Package/python3-base
85 $(call Package/python3/Default)
86 TITLE+= base interpreter
87 DEPENDS:=+libpython3
88 endef
89
90 define Package/python3-base/description
91 $(call Package/python3/Default/description)
92
93 This package contains only the interpreter and the bare minimum for the
94 interpreter to start.
95 endef
96
97 define Package/python3-light
98 $(call Package/python3/Default)
99 TITLE+= light installation
100 DEPENDS:=+python3-base +libbz2 +zlib
101 endef
102
103 define Package/python3-light/config
104 source "$(SOURCE)/Config-python3-light.in"
105 endef
106
107 define Package/python3-light/description
108 $(call Package/python3/Default/description)
109
110 This package installs the base interpreter package and contains the most
111 commonly used parts of the standard library.
112 endef
113
114 PYTHON3_LIB_FILES_DEL:=
115 PYTHON3_PACKAGES:=
116 PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so
117 PYTHON3_PACKAGES_DEPENDS:=
118 define Py3BasePackage
119 PYTHON3_PACKAGES+=$(1)
120 ifeq ($(3),)
121 PYTHON3_PACKAGES_DEPENDS+=$(1)
122 endif
123 PYTHON3_LIB_FILES_DEL+=$(2)
124 define Py3Package/$(1)/filespec
125 ifneq ($(2),)
126 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
127 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
128 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
129 endif
130 endef
131 Py3Package/$(1)/install?=:
132 endef
133
134 include ./files/python3-package-*.mk
135
136 define Package/python3
137 $(call Package/python3/Default)
138 TITLE+= programming language
139 DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES_DEPENDS),+$(package))
140 endef
141
142 define Package/python3/description
143 $(call Package/python3/Default/description)
144
145 This package installs almost all parts of the standard Python
146 installation.
147 endef
148
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"
153
154 EXTRA_LDFLAGS+= \
155 -L$(PKG_BUILD_DIR) \
156 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
157
158 # Bypass configure tests for cross compilation
159 CONFIGURE_VARS += \
160 ac_cv_buggy_getaddrinfo=no \
161 ac_cv_file__dev_ptc=no \
162 ac_cv_file__dev_ptmx=yes
163
164 # Do not link with libbsd for flock
165 # https://github.com/openwrt/packages/issues/21161
166 CONFIGURE_VARS += \
167 ac_cv_lib_bsd_flock=no
168
169 # Disable stdlib modules
170 # Check for a better way in the future: https://github.com/python/cpython/issues/98558
171 CONFIGURE_VARS += \
172 py_cv_module__tkinter=n/a \
173 py_cv_module_nis=n/a
174
175 # Workaround for hardfloat mips
176 # https://bugs.python.org/issue46265
177 ifneq ($(findstring mips,$(CONFIG_ARCH)),)
178 ifeq ($(CONFIG_HAS_FPU),y)
179 CONFIGURE_VARS += \
180 ax_cv_check_cflags___fno_semantic_interposition=no
181 endif
182 endif
183
184 MAKE_VARS += \
185 PYTHONSTRICTEXTENSIONBUILD=1
186
187 CONFIGURE_ARGS += \
188 --enable-optimizations \
189 --enable-shared \
190 --disable-test-modules \
191 --with-build-python \
192 --with-system-ffi \
193 --without-cxx-main \
194 --without-ensurepip \
195 $(if $(CONFIG_IPV6),--enable-ipv6) \
196 $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto)
197
198 define Build/InstallDev
199 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
200 $(INSTALL_DIR) $(2)/bin
201 $(CP) \
202 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
203 $(1)/usr/include/
204 $(CP) \
205 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
206 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
207 $(1)/usr/lib/
208 grep \
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
212 $(CP) \
213 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
214 $(1)/usr/lib/pkgconfig
215 $(INSTALL_BIN) \
216 $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
217 $(2)/bin/
218 $(SED) \
219 's|^prefix_real=.*$$$$|prefix_real="$(PYTHON3_DIR)"|' \
220 $(2)/bin/python$(PYTHON3_VERSION)-config
221 endef
222
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
238
239 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
240
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)))
244 endef
245
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)))
261 endef
262
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/
267 endef
268
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
276 endef
277
278 Py3Package/python3-light/install:=:
279 Package/python3/install:=:
280
281 # libuuid is provided by e2fsprogs and uuid/uuid.h is moved into
282 # $(STAGING_DIR_HOST)/include/e2fsprogs
283 HOST_CFLAGS += \
284 -I$(STAGING_DIR_HOST)/include/e2fsprogs
285 HOST_CPPFLAGS += \
286 -I$(STAGING_DIR_HOST)/include/e2fsprogs
287
288 HOST_LDFLAGS += \
289 -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
290
291 ifeq ($(HOST_OS),Linux)
292 HOST_LDFLAGS += \
293 -Wl,--no-as-needed -lrt
294 endif
295
296 # Would be nice to be able to do this, but hosts are very fiddly
297 # HOST_MAKE_VARS += \
298 # PYTHONSTRICTEXTENSIONBUILD=1
299
300 # Bypass configure test
301 HOST_CONFIGURE_VARS += \
302 ac_cv_working_openssl_hashlib=yes
303
304 ifeq ($(HOST_OS),Darwin)
305 HOST_CONFIGURE_VARS += \
306 ac_cv_header_libintl_h=no
307 HOST_MAKE_VARS += \
308 USE_PYTHON_CONFIG_PY=1
309 endif
310
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 \
317 --without-cxx-main
318
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
324 endef
325
326 define Host/Install
327 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
328 rm -rf \
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_*
334 )
335 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
336 rm -rf \
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_*
341 )
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)
346 )
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)
350 )
351 endef
352
353 $(eval $(call HostBuild))
354
355 $(foreach package, $(PYTHON3_PACKAGES), \
356 $(eval $(call Py3Package,$(package))) \
357 $(eval $(call BuildPackage,$(package))) \
358 $(eval $(call BuildPackage,$(package)-src)) \
359 )
360
361 $(eval $(call BuildPackage,libpython3))
362 $(eval $(call BuildPackage,python3))
363
364 $(eval $(call Py3Package,python3-base))
365 $(eval $(call Py3Package,python3-light))
366
367 $(eval $(call BuildPackage,python3-base))
368 $(eval $(call BuildPackage,python3-light))
369
370 $(eval $(call BuildPackage,python3-base-src))
371 $(eval $(call BuildPackage,python3-light-src))