Merge pull request #20730 from pprindeville/strongswan-fix-cicd-kmod
[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:=3
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:=6eed8415b7516fb2f260906db5d48dd4c06acc0cb24a7d6cc15296a604dcdc48
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
38 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
39 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
40
41 PKG_CONFIG_DEPENDS:= \
42 CONFIG_PACKAGE_python3-pkg-resources \
43 CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
44
45 PKG_BUILD_DEPENDS:=bluez python3/host
46 HOST_BUILD_DEPENDS:=bzip2/host libffi/host
47
48 include $(INCLUDE_DIR)/host-build.mk
49 include $(INCLUDE_DIR)/package.mk
50
51 define Package/python3/Default
52 SUBMENU:=Python
53 SECTION:=lang
54 CATEGORY:=Languages
55 TITLE:=Python $(PYTHON3_VERSION) programming language
56 URL:=https://www.python.org/
57 endef
58
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.
66 endef
67
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)
73 endef
74
75 define Package/libpython3/description
76 This package contains only core Python library.
77 endef
78
79 define Package/python3-base
80 $(call Package/python3/Default)
81 TITLE:=Python $(PYTHON3_VERSION) interpreter
82 DEPENDS:=+libpthread +zlib +libpython3
83 endef
84
85 define Package/python3-base/description
86 This package contains only the interpreter and the bare minimum
87 for the interpreter to start.
88 endef
89
90 define Package/python3-light
91 $(call Package/python3/Default)
92 TITLE:=Python $(PYTHON3_VERSION) light installation
93 DEPENDS:=+python3-base +libffi +libbz2
94 endef
95
96 define Package/python3-light/config
97 source "$(SOURCE)/Config-python3-light.in"
98 endef
99
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.
104 endef
105
106 PYTHON3_LIB_FILES_DEL:=
107 PYTHON3_PACKAGES:=
108 PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so
109 PYTHON3_PACKAGES_DEPENDS:=
110 define Py3BasePackage
111 PYTHON3_PACKAGES+=$(1)
112 ifeq ($(3),)
113 PYTHON3_PACKAGES_DEPENDS+=$(1)
114 endif
115 PYTHON3_LIB_FILES_DEL+=$(2)
116 define Py3Package/$(1)/filespec
117 ifneq ($(2),)
118 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
119 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
120 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
121 endif
122 endef
123 Py3Package/$(1)/install?=:
124 endef
125
126 include ./files/python3-package-*.mk
127
128 define Package/python3
129 $(call Package/python3/Default)
130 DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES_DEPENDS),+$(package))
131 endef
132
133 define Package/python3/description
134 This package contains the (almost) full Python install.
135 It's python3-light + all other packages.
136 endef
137
138 EXTRA_LDFLAGS+= \
139 -L$(PKG_BUILD_DIR) \
140 -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
141
142 # Workaround for hardfloat mips
143 # https://bugs.python.org/issue46265
144 ifneq ($(findstring mips,$(CONFIG_ARCH)),)
145 ifeq ($(CONFIG_HAS_FPU),y)
146 CONFIGURE_VARS += \
147 ax_cv_check_cflags___fno_semantic_interposition=no
148 endif
149 endif
150
151 MAKE_VARS += \
152 PYTHONSTRICTEXTENSIONBUILD=1
153
154 CONFIGURE_ARGS+= \
155 --enable-optimizations \
156 --enable-shared \
157 --with-system-ffi \
158 --without-cxx-main \
159 --without-ensurepip \
160 --without-pymalloc \
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)"
166
167 define Build/Prepare
168 $(call Build/Prepare/Default)
169 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
170 endef
171
172 ifdef CONFIG_PACKAGE_python3-setuptools
173 PYTHON3_SETUPTOOLS_BUILD:=1
174 endif
175
176 ifdef CONFIG_PACKAGE_python3-pkg-resources
177 PYTHON3_SETUPTOOLS_BUILD:=1
178 endif
179
180 ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
181 define Build/Compile/python3-setuptools
182 $(HOST_PYTHON3_PIP_VARS) \
183 $(HOST_PYTHON3_PIP) \
184 install \
185 --ignore-installed \
186 --progress-bar off \
187 --root=$(PKG_BUILD_DIR)/install-setuptools \
188 --prefix=/usr \
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,)
191 endef
192 else
193 define Build/Compile/python3-setuptools
194 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
195 endef
196 endif # CONFIG_PACKAGE_python3-setuptools
197
198 ifdef CONFIG_PACKAGE_python3-pip
199 define Build/Compile/python3-pip
200 $(HOST_PYTHON3_PIP_VARS) \
201 $(HOST_PYTHON3_PIP) \
202 install \
203 --ignore-installed \
204 --progress-bar off \
205 --root=$(PKG_BUILD_DIR)/install-pip \
206 --prefix=/usr \
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,)
209 endef
210 else
211 define Build/Compile/python3-pip
212 ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
213 endef
214 endif # CONFIG_PACKAGE_python3-pip
215
216 define Build/Compile
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)
221 endef
222
223 define Build/InstallDev
224 $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
225 $(INSTALL_DIR) $(2)/bin
226 $(CP) \
227 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
228 $(1)/usr/include/
229 $(CP) \
230 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
231 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
232 $(1)/usr/lib/
233 grep \
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
237 $(CP) \
238 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
239 $(1)/usr/lib/pkgconfig
240 $(INSTALL_BIN) \
241 $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
242 $(2)/bin/
243 $(SED) \
244 's|^prefix_real=.*$$$$|prefix_real="$(PYTHON3_DIR)"|' \
245 $(2)/bin/python$(PYTHON3_VERSION)-config
246 endef
247
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
263
264 PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
265
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)))
269 endef
270
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)/idlelib
276 -|/usr/lib/python$(PYTHON3_VERSION)/tkinter
277 -|/usr/lib/python$(PYTHON3_VERSION)/turtledemo
278 -|/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_test*.so
279 -|/usr/lib/python$(PYTHON3_VERSION)/pdb.doc
280 -|/usr/lib/python$(PYTHON3_VERSION)/test
281 -|/usr/lib/python$(PYTHON3_VERSION)/webbrowser.py
282 -|/usr/lib/python$(PYTHON3_VERSION)/*/test
283 -|/usr/lib/python$(PYTHON3_VERSION)/*/tests
284 -|/usr/lib/python$(PYTHON3_VERSION)/_osx_support.py
285 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
286 endef
287
288 define Package/libpython3/install
289 # Adding the lib-dynload folder (even just empty) suppresses 2 warnings when starting Python
290 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/
291 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* $(1)/usr/lib/
292 endef
293
294 define Py3Package/python3-base/install
295 $(INSTALL_DIR) $(1)/usr/bin
296 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python3
297 $(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python
298 # This depends on being called before filespec is processed
299 $(SED) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
300 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py
301 endef
302
303 Py3Package/python3-light/install:=:
304 Py3Package/python3/install:=:
305
306 define Py3Package/python3/filespec
307 -|$(PYTHON3_PKG_DIR)
308 endef
309
310 HOST_LDFLAGS += \
311 -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
312
313 ifeq ($(HOST_OS),Linux)
314 HOST_LDFLAGS += \
315 -Wl,--no-as-needed -lrt
316 endif
317
318 # Would be nice to be able to do this, but hosts are very fiddly
319 # HOST_MAKE_VARS += \
320 # PYTHONSTRICTEXTENSIONBUILD=1
321
322 ifeq ($(HOST_OS),Darwin)
323 HOST_CONFIGURE_VARS += \
324 ac_cv_header_libintl_h=no
325 HOST_MAKE_VARS += \
326 USE_PYTHON_CONFIG_PY=1
327 endif
328
329 HOST_CONFIGURE_ARGS+= \
330 --enable-optimizations \
331 --with-ensurepip=upgrade \
332 --with-system-expat=$(STAGING_DIR_HOST) \
333 --with-ssl-default-suites=openssl \
334 --without-cxx-main \
335 --without-pymalloc \
336 --disable-test-modules \
337 CONFIG_SITE=
338
339 define Host/Configure
340 $(SED) 's/^ENABLE_USER_SITE = None$$$$/ENABLE_USER_SITE = False/' $(HOST_BUILD_DIR)/Lib/site.py
341 $(call Host/Configure/Default)
342 endef
343
344 define Host/Compile
345 $(call Host/Compile/Default,python)
346 $(call Host/Compile/Default,sharedmods)
347 endef
348
349 define Host/Install
350 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
351 rm -rf \
352 $(HOST_PYTHON3_PKG_DIR)/pkg_resources \
353 $(HOST_PYTHON3_PKG_DIR)/setuptools \
354 $(HOST_PYTHON3_PKG_DIR)/setuptools-* \
355 $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched* \
356 $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_*
357 )
358 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
359 rm -rf \
360 $(HOST_PYTHON3_PKG_DIR)/pip \
361 $(HOST_PYTHON3_PKG_DIR)/pip-* \
362 $(HOST_PYTHON3_PKG_DIR)/.pip-patched* \
363 $(HOST_PYTHON3_PKG_DIR)/.pip_installed_*
364 )
365 $(call Host/Install/Default)
366 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
367 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-setuptools,)
368 touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
369 )
370 $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
371 $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-pip,)
372 touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
373 )
374 endef
375
376 $(eval $(call HostBuild))
377
378 $(foreach package, $(PYTHON3_PACKAGES), \
379 $(eval $(call Py3Package,$(package))) \
380 $(eval $(call BuildPackage,$(package))) \
381 $(eval $(call BuildPackage,$(package)-src)) \
382 )
383
384 $(eval $(call BuildPackage,libpython3))
385
386 $(eval $(call Py3Package,python3-base))
387 $(eval $(call Py3Package,python3-light))
388 $(eval $(call Py3Package,python3))
389
390 $(eval $(call BuildPackage,python3-base))
391 $(eval $(call BuildPackage,python3-light))
392 $(eval $(call BuildPackage,python3))
393
394 $(eval $(call BuildPackage,python3-base-src))
395 $(eval $(call BuildPackage,python3-light-src))