Merge pull request #4542 from MikePetullo/dovecot
[feed/packages.git] / lang / python / python / 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 # For PYTHON_VERSION
11 include ./files/python-version.mk
12
13 PKG_NAME:=python
14 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
15 PKG_RELEASE:=5
16
17 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
18 PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
19 PKG_MD5SUM:=53b43534153bb2a0363f08bae8b9d990
20 PKG_HASH:=35d543986882f78261f97787fd3e06274bfa6df29fac9b4a94f73930ff98f731
21
22 PKG_LICENSE:=PSF
23 PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE
24
25 # This file provides the necsessary host build variables
26 include ./files/python-host.mk
27
28 # For PyPackage
29 include ./files/python-package.mk
30
31 PKG_INSTALL:=1
32 PKG_BUILD_PARALLEL:=1
33 HOST_BUILD_PARALLEL:=1
34
35 PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
36 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
37
38 PKG_CONFIG_DEPENDS:=CONFIG_PACKAGE_python-setuptools CONFIG_PACKAGE_python-pip
39
40 PKG_BUILD_DEPENDS:=python/host
41 HOST_BUILD_DEPENDS:=bzip2/host expat/host
42
43 include $(INCLUDE_DIR)/host-build.mk
44 include $(INCLUDE_DIR)/package.mk
45
46 define Package/python/Default
47 SUBMENU:=Python
48 SECTION:=lang
49 CATEGORY:=Languages
50 TITLE:=Python $(PYTHON_VERSION) programming language
51 URL:=https://www.python.org/
52 MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
53 endef
54
55 define Package/python/Default/description
56 Python is a dynamic object-oriented programming language that can be used
57 for many kinds of software development. It offers strong support for
58 integration with other languages and tools, comes with extensive standard
59 libraries, and can be learned in a few days. Many Python programmers
60 report substantial productivity gains and feel the language encourages
61 the development of higher quality, more maintainable code.
62 endef
63
64 define Package/python-pip-conf
65 $(call Package/python/Default)
66 TITLE:=Configuration file for pip/pip3
67 URL:=https://pip.pypa.io
68 endef
69
70 define Package/python-pip-conf/description
71 Configuration file for pip/pip3
72 endef
73
74 define Package/python-base
75 $(call Package/python/Default)
76 TITLE:=Python $(PYTHON_VERSION) interpreter
77 DEPENDS:=+libpthread +zlib
78 endef
79
80 define Package/python-base/description
81 This package contains only the interpreter and the bare minimum
82 for the interpreter to start.
83 endef
84
85 define Package/python-light
86 $(call Package/python/Default)
87 TITLE:=Python $(PYTHON_VERSION) light installation
88 DEPENDS:=+python-base +libffi +libbz2
89 endef
90
91 define Package/python-light/description
92 This package is essentially the python-base package plus
93 a few of the rarely used (and big) libraries stripped out
94 into separate packages.
95 endef
96
97 PYTHON_LIB_FILES_DEL:=
98 PYTHON_PACKAGES:=
99 PYTHON_PACKAGES_DEPENDS:=
100 define PyBasePackage
101 PYTHON_PACKAGES+=$(1)
102 ifeq ($(3),)
103 PYTHON_PACKAGES_DEPENDS+=$(1)
104 endif
105 PYTHON_LIB_FILES_DEL+=$(2)
106 define PyPackage/$(1)/filespec
107 ifneq ($(2),)
108 $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
109 -|/usr/lib/python$(PYTHON_VERSION)/*/test
110 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
111 endif
112 endef
113 endef
114
115 include ./files/python-package-*.mk
116
117 define Package/python
118 $(call Package/python/Default)
119 DEPENDS:=+python-light $(foreach package,$(PYTHON_PACKAGES_DEPENDS),+$(package))
120 endef
121
122 define Package/python/description
123 This package contains the (almost) full Python install.
124 It's python-light + all other packages.
125 endef
126
127 MAKE_FLAGS+=\
128 CROSS_COMPILE=yes \
129 LD="$(TARGET_CC)" \
130 PGEN=pgen2
131
132 EXTRA_CFLAGS+= \
133 -DNDEBUG -fno-inline
134 EXTRA_LDFLAGS+= \
135 -L$(PKG_BUILD_DIR)
136
137 ENABLE_IPV6:=
138 ifeq ($(CONFIG_IPV6),y)
139 ENABLE_IPV6 += --enable-ipv6
140 endif
141
142 PYTHON_FOR_BUILD:= \
143 _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
144 _PYTHON_HOST_PLATFORM=linux2 \
145 PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
146 _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
147 $(HOST_PYTHON_BIN)
148
149 CONFIGURE_ARGS+= \
150 --sysconfdir=/etc \
151 --enable-shared \
152 --without-cxx-main \
153 --with-threads \
154 --with-system-ffi \
155 --with-ensurepip=no \
156 --without-pymalloc \
157 PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
158 $(ENABLE_IPV6) \
159 CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
160 OPT="$(TARGET_CFLAGS)"
161
162 define Build/Prepare
163 $(call Build/Prepare/Default)
164 $(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
165 endef
166
167 ifdef CONFIG_PACKAGE_python-setuptools
168 define Build/Compile/python-setuptools
169 $(STAGING_DIR_HOSTPKG)/bin/pip install \
170 --ignore-installed \
171 --root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
172 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
173 endef
174 endif # CONFIG_PACKAGE_python-setuptools
175
176 ifdef CONFIG_PACKAGE_python-pip
177 define Build/Compile/python-pip
178 $(STAGING_DIR_HOSTPKG)/bin/pip install \
179 --ignore-installed \
180 --root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
181 $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
182 endef
183 endif # CONFIG_PACKAGE_python-pip
184
185 define Build/Compile
186 $(call Build/Compile/Default)
187 # Use host pip to install python-setuptools
188 $(call Build/Compile/python-setuptools)
189 $(call Build/Compile/python-pip)
190 endef
191
192 define Build/InstallDev
193 $(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
194 $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
195 $(CP) \
196 $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
197 $(1)/usr/include/
198 $(CP) \
199 $(HOST_PYTHON_LIB_DIR) \
200 $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
201 $(1)/usr/lib/
202 $(CP) \
203 $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \
204 $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \
205 $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
206 $(1)/usr/lib/pkgconfig
207 $(CP) \
208 $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
209 $(1)/usr/lib/python$(PYTHON_VERSION)/
210 endef
211
212 PYTHON_BASE_LIB_FILES:= \
213 /usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
214 /usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
215 /usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
216 /usr/lib/python$(PYTHON_VERSION)/abc.py \
217 /usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
218 /usr/lib/python$(PYTHON_VERSION)/genericpath.py \
219 /usr/lib/python$(PYTHON_VERSION)/linecache.py \
220 /usr/lib/python$(PYTHON_VERSION)/posixpath.py \
221 /usr/lib/python$(PYTHON_VERSION)/os.py \
222 /usr/lib/python$(PYTHON_VERSION)/re.py \
223 /usr/lib/python$(PYTHON_VERSION)/site.py \
224 /usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
225 /usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
226 /usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
227 /usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
228 /usr/lib/python$(PYTHON_VERSION)/stat.py \
229 /usr/lib/python$(PYTHON_VERSION)/traceback.py \
230 /usr/lib/python$(PYTHON_VERSION)/types.py \
231 /usr/lib/python$(PYTHON_VERSION)/UserDict.py \
232 /usr/lib/python$(PYTHON_VERSION)/warnings.py
233
234 PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
235
236 define PyPackage/python-base/filespec
237 +|/usr/bin/python$(PYTHON_VERSION)
238 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
239 endef
240
241 define PyPackage/python-light/filespec
242 +|/usr/lib/python$(PYTHON_VERSION)
243 -|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
244 -|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
245 -|/usr/lib/python$(PYTHON_VERSION)/ensurepip
246 -|/usr/lib/python$(PYTHON_VERSION)/idlelib
247 -|/usr/lib/python$(PYTHON_VERSION)/lib-tk
248 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
249 -|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
250 -|/usr/lib/python$(PYTHON_VERSION)/test
251 -|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
252 -|/usr/lib/python$(PYTHON_VERSION)/*/test
253 -|/usr/lib/python$(PYTHON_VERSION)/*/tests
254 -|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
255 $(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
256 endef
257
258 define PyPackage/python-base/install
259 $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
260 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
261 $(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
262 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
263 endef
264
265 define PyPackage/python/filespec
266 -|$(PYTHON_PKG_DIR)
267 endef
268
269 define Package/python-pip-conf/install
270 $(INSTALL_DIR) $(1)/etc
271 $(CP) ./files/pip.conf $(1)/etc
272 endef
273
274 HOST_LDFLAGS += \
275 -Wl,--no-as-needed -lrt \
276 $$$$(pkg-config --static --libs libcrypto libssl)
277
278 HOST_CONFIGURE_ARGS+= \
279 --without-cxx-main \
280 --without-pymalloc \
281 --with-threads \
282 --prefix=$(HOST_PYTHON_DIR) \
283 --exec-prefix=$(HOST_PYTHON_DIR) \
284 --with-system-expat=$(STAGING_DIR_HOSTPKG) \
285 --with-system-ffi=no \
286 --with-ensurepip=install \
287 CONFIG_SITE=
288
289 define Host/Install
290 $(MAKE) -C $(HOST_BUILD_DIR) install
291 $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/ $(STAGING_DIR)/mk/
292 $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
293 # Install these mk files in the Host/Install phase ;
294 # The Build/InstallDev rule is activated only for target builds.
295 # But if someone needs only the host Python, then
296 # these files need to be installed in this phase, and not Build/InstallDev
297 $(INSTALL_DATA) \
298 ./files/python-package.mk \
299 ./files/python-host.mk \
300 ./files/python-version.mk \
301 ./files/python-package-install.sh \
302 $(STAGING_DIR)/mk/
303 endef
304
305 $(eval $(call HostBuild))
306
307 $(foreach package, $(PYTHON_PACKAGES), \
308 $(eval $(call PyPackage,$(package))) \
309 $(eval $(call BuildPackage,$(package))) \
310 $(eval $(call BuildPackage,$(package)-src)) \
311 )
312
313 $(eval $(call PyPackage,python-base))
314 $(eval $(call PyPackage,python-light))
315 $(eval $(call PyPackage,python))
316
317 $(eval $(call BuildPackage,python-pip-conf))
318
319 $(eval $(call BuildPackage,python-base))
320 $(eval $(call BuildPackage,python-light))
321 $(eval $(call BuildPackage,python))
322
323 $(eval $(call BuildPackage,python-base-src))
324 $(eval $(call BuildPackage,python-light-src))
325 $(eval $(call BuildPackage,python-src))