diff options
author | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2010-12-26 10:28:49 +0100 |
---|---|---|
committer | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2011-01-25 08:59:57 +0100 |
commit | e3418f69cf2f17d54dfb521adedbe8abf6e35927 (patch) | |
tree | aa465725122a3ac95ba4656e31cfd129b8bb0609 /package/python/python.mk | |
parent | b06e7ac4e135a01ddb8914c779dff2bda25e00b1 (diff) |
python: convert to autotargets, bump to 2.7.1, many improvements
This commit does a number of changes and improvements to the Python
interpreter package :
* It converts the .mk file to the AUTOTARGETS infrastructure. Even
though Python uses only autoconf and not automake, the AUTOTARGETS
is a fairly good fit for the Python interpreter, so we make use of
it.
* It bumps the version to 2.7.1. As this is a minor release compared
to 2.7, there are no particular changes needed because of this
bump. All changes done to the package are cleanups and improvements
unrelated to the version bump.
* It uses the system libffi. Until now, Python was building its own
libffi (a library used by interprets to build code that makes
function call at runtime). Using the Python internal libffi was not
working as Python was not passing the appropriate arguments down to
libffi ./configure script. And it sounded better to use a
system-wide libffi, that could potentially be used by other
packages as well. This libffi is needed for the ctypes Python
module.
* Remove all "depends on BR2_PACKAGE_PYTHON" by moving all
Python-related options under a "if BR2_PACKAGE_PYTHON ... endif"
condition.
* Make the installation of pre-compiled Python modules (.pyc) the
default, since they are smaller and do not need to be compiled on
the target. It is still possible to install uncompiled modules, or
both the uncompiled and pre-compiled versions.
* The options to select the set of Python modules to compile has been
moved to a submenu.
* The codecscjk (Japanese, Korean and Chinese codecs) module is no
longer enabled by default.
* The commented options for gdbm and nis in Python have been
removed. Those were not supported, so let's get rid of unused code.
* The option for the tkinker module in Python has been removed, since
we don't have a package for Tk in Buildroot.
* Options for the bzip2, sqlite and zlib modules have been added,
since those modules have external dependencies.
* The set of patches has been completely reworked and extended, with
more fine-grained patches and newer functionalities. The patches
are split in two categories:
- Patches that make various modifications to the Python build
system to support cross-compilation or make some minor
modifications. Those patches are numbered from 0 to 100.
- Patches that add configuration options to the Python build
system in order to enable/disable the compilation of Python
extensions or modules (test modules, pydoc, lib2to3, sqlite, tk,
curses, expat, codecs-cjk, nis, unicodedata, database modules,
ssl, bzip2, zlib). These patches are numbered from 100 to 200.
All features of the previous four patches are preserved, but they
are organized differently and the patches have been renamed. This
makes it difficult to see the differences from the existing
patches.
* The host Python interpreter is now installed in $(HOST_DIR), since
it is used to build third party Python modules.
* The BR2_PACKAGE_PYTHON_DEV option is removed since
BR2_HAVE_DEVFILES already does the necessary work.
* The "make -i install" workaround introduced by Maxime Ripard is no
longer needed. It was caused by the compilation of the tests that
required the unicodedata module (which wasn't built in the host
Python interpreter). Since we no longer compile the Python tests,
the problem doesn't exist anymore and we can avoid this "-i"
option.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'package/python/python.mk')
-rw-r--r-- | package/python/python.mk | 286 |
1 files changed, 107 insertions, 179 deletions
diff --git a/package/python/python.mk b/package/python/python.mk index 3afc1326d..4b80538f9 100644 --- a/package/python/python.mk +++ b/package/python/python.mk @@ -3,218 +3,146 @@ # python # ############################################################# -PYTHON_VERSION=2.7 -PYTHON_VERSION_MAJOR=2.7 -PYTHON_SOURCE:=Python-$(PYTHON_VERSION).tar.bz2 -PYTHON_SITE:=http://python.org/ftp/python/$(PYTHON_VERSION) -PYTHON_DIR:=$(BUILD_DIR)/Python-$(PYTHON_VERSION) -PYTHON_CAT:=$(BZCAT) -PYTHON_BINARY:=python -PYTHON_TARGET_BINARY:=usr/bin/python$(PYTHON_VERSION_MAJOR) -PYTHON_DEPS:= -PYTHON_SITE_PACKAGE_DIR=$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages - -BR2_PYTHON_DISABLED_MODULES=dbm zipfile +PYTHON_VERSION_MAJOR = 2.7 +PYTHON_VERSION = $(PYTHON_VERSION_MAJOR).1 +PYTHON_SOURCE = Python-$(PYTHON_VERSION).tar.bz2 +PYTHON_SITE = http://python.org/ftp/python/$(PYTHON_VERSION) + +# Python needs itself and a "pgen" program to build itself, both being +# provided in the Python sources. So in order to cross-compile Python, +# we need to build a host Python first. This host Python is also +# installed in $(HOST_DIR), as it is needed when cross-compiling +# third-party Python modules. + +HOST_PYTHON_CONF_OPT += \ + --without-cxx-main \ + --disable-sqlite3 \ + --disable-tk \ + --with-expat=none \ + --disable-curses \ + --disable-codecs-cjk \ + --disable-nis \ + --disable-unicodedata \ + --disable-dbm \ + --disable-gdbm \ + --disable-bsddb \ + --disable-test-modules \ + --disable-bz2 \ + --disable-zlib \ + --disable-ssl + +HOST_PYTHON_MAKE_ENV = \ + PYTHON_MODULES_INCLUDE=$(HOST_DIR)/usr/include \ + PYTHON_MODULES_LIB="$(HOST_DIR)/lib $(HOST_DIR)/usr/lib" + +HOST_PYTHON_AUTORECONF = YES + +PYTHON_DEPENDENCIES = host-python libffi + +PYTHON_INSTALL_STAGING = YES ifeq ($(BR2_PACKAGE_PYTHON_READLINE),y) -PYTHON_DEPS += readline -else -BR2_PYTHON_DISABLED_MODULES += readline +PYTHON_DEPENDENCIES += readline endif ifeq ($(BR2_PACKAGE_PYTHON_CURSES),y) -PYTHON_DEPS += ncurses +PYTHON_DEPENDENCIES += ncurses else -BR2_PYTHON_DISABLED_MODULES += _curses _curses_panel +PYTHON_CONF_OPT += --disable-curses endif ifeq ($(BR2_PACKAGE_PYTHON_PYEXPAT),y) -PYTHON_DEPS += expat -else -BR2_PYTHON_DISABLED_MODULES += pyexpat -endif - -ifeq ($(BR2_PACKAGE_PYTHON_GDBM),y) -PYTHON_DEPS += gdbm +PYTHON_DEPENDENCIES += expat +PYTHON_CONF_OPT += --with-expat=system else -BR2_PYTHON_DISABLED_MODULES += gdbm +PYTHON_CONF_OPT += --with-expat=none endif ifeq ($(BR2_PACKAGE_PYTHON_BSDDB),y) -PYTHON_DEPS += berkeleydb +PYTHON_DEPENDENCIES += berkeleydb else -BR2_PYTHON_DISABLED_MODULES += bsddb +PYTHON_CONF_OPT += --disable-bsddb endif -ifeq ($(BR2_PACKAGE_PYTHON_TKINTER),y) -PYTHON_DEPS += tcl +ifeq ($(BR2_PACKAGE_PYTHON_SQLITE),y) +PYTHON_DEPENDENCIES += sqlite else -BR2_PYTHON_DISABLED_MODULES += _tkinter +PYTHON_CONF_OPT += --disable-sqlite3 endif ifeq ($(BR2_PACKAGE_PYTHON_SSL),y) -PYTHON_DEPS += openssl -endif - -ifneq ($(BR2_PACKAGE_PYTHON_NIS),y) -BR2_PYTHON_DISABLED_MODULES += nis +PYTHON_DEPENDENCIES += openssl +else +PYTHON_CONF_OPT += --disable-ssl endif ifneq ($(BR2_PACKAGE_PYTHON_CODECSCJK),y) -BR2_PYTHON_DISABLED_MODULES += _codecs_kr _codecs_jp _codecs_cn _codecs_tw _codecs_hk +PYTHON_CONF_OPT += --disable-codecs-cjk endif ifneq ($(BR2_PACKAGE_PYTHON_UNICODEDATA),y) -BR2_PYTHON_DISABLED_MODULES += unicodedata +PYTHON_CONF_OPT += --disable-unicodedata endif -$(DL_DIR)/$(PYTHON_SOURCE): - $(call DOWNLOAD,$(PYTHON_SITE),$(PYTHON_SOURCE)) - -python-source: $(DL_DIR)/$(PYTHON_SOURCE) - -$(PYTHON_DIR)/.unpacked: $(DL_DIR)/$(PYTHON_SOURCE) - $(PYTHON_CAT) $(DL_DIR)/$(PYTHON_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) - - touch $@ - -$(PYTHON_DIR)/.patched: $(PYTHON_DIR)/.unpacked - toolchain/patch-kernel.sh $(PYTHON_DIR) package/python/ python-$(PYTHON_VERSION_MAJOR)-\*.patch - touch $@ - -$(PYTHON_DIR)/.hostpython: $(PYTHON_DIR)/.patched - (cd $(PYTHON_DIR); rm -rf config.cache; \ - CC="$(HOSTCC)" OPT="-O2" \ - ./configure $(QUIET) \ - --with-cxx=no \ - $(DISABLE_NLS) && \ - $(MAKE) python Parser/pgen && \ - mv python hostpython && \ - mv Parser/pgen Parser/hostpgen && \ - $(MAKE) distclean \ - ) && \ - touch $@ - -$(PYTHON_DIR)/.configured: $(PYTHON_DIR)/.hostpython - (cd $(PYTHON_DIR); rm -rf config.cache; \ - $(TARGET_CONFIGURE_OPTS) \ - $(TARGET_CONFIGURE_ARGS) \ - OPT="$(TARGET_CFLAGS)" \ - ./configure $(QUIET) \ - --target=$(GNU_TARGET_NAME) \ - --host=$(GNU_TARGET_NAME) \ - --build=$(GNU_HOST_NAME) \ - --prefix=/usr \ - --sysconfdir=/etc \ - --with-cxx=no \ - --enable-shared \ - $(DISABLE_IPV6) \ - $(DISABLE_NLS) \ - ) - touch $@ - -$(PYTHON_DIR)/$(PYTHON_BINARY): $(PYTHON_DIR)/.configured -ifneq ($(BR2_PACKAGE_PYTHON_SSL),y) - export PYTHON_DISABLE_SSL=1 -endif - $(MAKE) CC="$(TARGET_CC)" -C $(PYTHON_DIR) DESTDIR=$(TARGET_DIR) \ - PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \ - PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib" \ - PYTHON_DISABLE_MODULES="$(BR2_PYTHON_DISABLED_MODULES)" \ - HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen - -$(TARGET_DIR)/$(PYTHON_TARGET_BINARY): $(PYTHON_DIR)/$(PYTHON_BINARY) -ifneq ($(BR2_PACKAGE_PYTHON_SSL),y) - export PYTHON_DISABLE_SSL=1 -endif - rm -rf $(PYTHON_DIR)/Lib/test - LD_LIBRARY_PATH=$(STAGING_DIR)/lib - # FIXME: The make -i just below is to work around python's bug - # #1669349 (http://bugs.python.org/issue1669349) which is introducing - # a failure at make install on a python-free system. Since none of - # the other the provided workaround work, the make -i is the only - # solution. The failing lib is install later in the process, so - # even if the compilation is failing without the patch, with it, the - # target python is fully functionnal. - # The "-i" will have to be removed when the bug will be solved. - $(MAKE) CC="$(TARGET_CC)" -C $(PYTHON_DIR) -i install \ - DESTDIR=$(TARGET_DIR) CROSS_COMPILE=yes \ - PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \ - PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib" \ - PYTHON_DISABLE_MODULES="$(BR2_PYTHON_DISABLED_MODULES)" \ - HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen && \ - rm $(TARGET_DIR)/usr/bin/python && \ - ln -s python$(PYTHON_VERSION_MAJOR) $(TARGET_DIR)/usr/bin/python && \ - rm $(TARGET_DIR)/usr/bin/idle && \ - rm $(TARGET_DIR)/usr/bin/pydoc && \ - find $(TARGET_DIR)/usr/lib/ -name '*.pyo' -exec rm {} \; && \ - rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \ - $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc \ - $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/test - cp -dpr $(TARGET_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR) $(STAGING_DIR)/usr/include/ - mkdir -p $(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) - cp -dpr $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config $(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/ - -ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY),y) - find $(TARGET_DIR)/usr/lib/ -name '*.pyc' -exec rm {} \; -endif -ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y) - find $(TARGET_DIR)/usr/lib/ -name '*.py' -exec rm {} \; -endif -ifneq ($(BR2_PACKAGE_PYTHON_DEV),y) - rm -rf $(TARGET_DIR)/usr/include/python$(PYTHON_VERSION_MAJOR) - rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config -endif -ifneq ($(BR2_PACKAGE_PYTHON_BSDDB),y) - rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/bsddb -endif -ifneq ($(BR2_PACKAGE_PYTHON_CURSES),y) - rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/curses -endif -ifneq ($(BR2_PACKAGE_PYTHON_TKINTER),y) - rm -rf $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/lib-tk +ifeq ($(BR2_PACKAGE_PYTHON_BZIP2),y) +PYTHON_DEPENDENCIES += bzip2 +else +PYTHON_CONF_OPT += --disable-bz2 endif - touch -c $@ - -python: $(PYTHON_DEPS) $(TARGET_DIR)/$(PYTHON_TARGET_BINARY) - -python-clean: - -$(MAKE) -C $(PYTHON_DIR) distclean - rm -f $(PYTHON_DIR)/.configured $(TARGET_DIR)/$(PYTHON_TARGET_BINARY) - -rm -rf $(TARGET_DIR)/usr/lib/python* $(TARGET_DIR)/usr/include/python* - -rm -f $(STAGING_DIR)/usr/lib/libpython$(PYTHON_VERSION_MAJOR).so - -python-dirclean: - rm -rf $(PYTHON_DIR) - -#### LIBPYTHON +ifeq ($(BR2_PACKAGE_PYTHON_ZLIB),y) +PYTHON_DEPENDENCIES += zlib +else +PYTHON_CONF_OPT += --disable-zlib +endif + +PYTHON_CONF_ENV += \ + PYTHON_FOR_BUILD=$(HOST_PYTHON_DIR)/python \ + PGEN_FOR_BUILD=$(HOST_PYTHON_DIR)/Parser/pgen \ + ac_cv_have_long_long_format=yes + +PYTHON_CONF_OPT += \ + --without-cxx-main \ + --without-doc-strings \ + --with-system-ffi \ + --disable-pydoc \ + --disable-test-modules \ + --disable-lib2to3 \ + --disable-gdbm \ + --disable-tk \ + --disable-nis \ + --disable-dbm + +PYTHON_MAKE_ENV = \ + PYTHON_MODULES_INCLUDE=$(STAGING_DIR)/usr/include \ + PYTHON_MODULES_LIB="$(STAGING_DIR)/lib $(STAGING_DIR)/usr/lib" -LIBPYTHON_BINARY:=libpython$(PYTHON_VERSION_MAJOR).so +# +# Development files removal +# +define PYTHON_REMOVE_DEVFILES + rm -f $(TARGET_DIR)/usr/bin/python$(PYTHON_VERSION_MAJOR)-config + rm -f $(TARGET_DIR)/usr/bin/python-config +endef -libpython: python $(TARGET_DIR)/usr/lib/$(LIBPYTHON_BINARY) +ifneq ($(BR2_HAVE_DEVFILES),y) +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_DEVFILES +endif +# +# Remove useless files. In the config/ directory, only the Makefile +# and the pyconfig.h files are needed at runtime. +# +define PYTHON_REMOVE_USELESS_FILES + for i in `find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/config/ \ + -type f -not -name pyconfig.h -a -not -name Makefile` ; do \ + rm -f $$i ; \ + done +endef -$(STAGING_DIR)/usr/lib/$(LIBPYTHON_BINARY): $(TARGET_DIR)/$(PYTHON_TARGET_BINARY) - cp -dpr $(PYTHON_DIR)/$(LIBPYTHON_BINARY).* $(STAGING_DIR)/usr/lib - (\ - cd $(STAGING_DIR)/usr/lib ; \ - rm -f $(LIBPYTHON_BINARY) ; \ - ln -s `basename \`ls libpython*.so.*\`` $(LIBPYTHON_BINARY) \ - ) +PYTHON_POST_INSTALL_TARGET_HOOKS += PYTHON_REMOVE_USELESS_FILES -$(TARGET_DIR)/usr/lib/$(LIBPYTHON_BINARY): $(STAGING_DIR)/usr/lib/$(LIBPYTHON_BINARY) - cp -dpr $(STAGING_DIR)/usr/lib/$(LIBPYTHON_BINARY).* $(TARGET_DIR)/usr/lib - (\ - cd $(TARGET_DIR)/usr/lib ; \ - rm -f $(LIBPYTHON_BINARY) ; \ - ln -s `basename \`ls libpython*.so.*\`` $(LIBPYTHON_BINARY) \ - ) +PYTHON_AUTORECONF = YES -############################################################# -# -# Toplevel Makefile options -# -############################################################# -ifeq ($(BR2_PACKAGE_PYTHON),y) -TARGETS+=python -endif +$(eval $(call AUTOTARGETS,package,python)) +$(eval $(call AUTOTARGETS,package,python,host)) |