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