freeswitch-stable: cleanup Python setup

- Rename PYTHON_PKG_DIR to PYTHON_SITE_DIR, otherwise it's confusing.
- Remove the 'sed' hacks; handle the Python setup like the Perl setup is
  already done.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
Sebastian Kemper 2017-06-27 22:14:43 +02:00
parent fb6cc32a6a
commit 639072e26e
4 changed files with 86 additions and 31 deletions

View file

@ -393,13 +393,13 @@ Library (ESL).
endef endef
define Package/$(PKG_NAME)-misc-python-esl/install define Package/$(PKG_NAME)-misc-python-esl/install
$(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR) $(INSTALL_DIR) $(1)$(PYTHON_SITE_DIR)
$(INSTALL_DATA) \ $(INSTALL_DATA) \
$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/ESL.py \ $(PKG_INSTALL_DIR)$(PYTHON_SITE_DIR)/ESL.py \
$(1)$(PYTHON_PKG_DIR) $(1)$(PYTHON_SITE_DIR)
$(INSTALL_BIN) \ $(INSTALL_BIN) \
$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/_ESL.so \ $(PKG_INSTALL_DIR)$(PYTHON_SITE_DIR)/_ESL.so \
$(1)$(PYTHON_PKG_DIR) $(1)$(PYTHON_SITE_DIR)
endef endef
define Package/$(PKG_NAME)-misc-timezones define Package/$(PKG_NAME)-misc-timezones
@ -506,10 +506,10 @@ ifeq ($(1),perl)
$$(1)$(PERL_SITELIB)/auto $$(1)$(PERL_SITELIB)/auto
endif endif
ifeq ($(1),python) ifeq ($(1),python)
$(INSTALL_DIR) $$(1)$(PYTHON_PKG_DIR) $(INSTALL_DIR) $$(1)$(PYTHON_SITE_DIR)
$(INSTALL_DATA) \ $(INSTALL_DATA) \
$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/$(PRG_NAME).py \ $(PKG_INSTALL_DIR)$(PYTHON_SITE_DIR)/$(PRG_NAME).py \
$$(1)$(PYTHON_PKG_DIR) $$(1)$(PYTHON_SITE_DIR)
endif endif
endef endef
$$(eval $$(call BuildPackage,$(PKG_NAME)-mod-$(1))) $$(eval $$(call BuildPackage,$(PKG_NAME)-mod-$(1)))
@ -635,15 +635,17 @@ ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-python-esl)$(CONFIG_PACKAGE_$(PKG_NAME)
$(call include_mk, python-version.mk) $(call include_mk, python-version.mk)
PYTHON_DIR:=$(STAGING_DIR)/usr PYTHON_SITE_DIR:=$(FS_STABLE_LIB_DIR)/python$(PYTHON_VERSION)/site-packages
PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
PYTHON_LDFLAGS:=-lpython$(PYTHON_VERSION) -ldl -lpthread -lm -Xlinker -export-dynamic
PYTHON_PKG_DIR:=$(FS_STABLE_LIB_DIR)/python$(PYTHON_VERSION)/site-packages
CONFIGURE_VARS+= \ CONFIGURE_VARS+= \
_python_sysroot="$(STAGING_DIR)" \ PYTHON_CFLAGS="-I$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION)" \
_python_prefix="/usr" \ PYTHON_LDFLAGS="-lpython$(PYTHON_VERSION) -ldl -lpthread -lm -Xlinker -export-dynamic" \
_python_exec_prefix="/usr" PYTHON_LIB="python$(PYTHON_VERSION)" \
PYTHON_LIBDIR="$(FS_STABLE_LIB_DIR)" \
PYTHON_SITE_DIR="$(PYTHON_SITE_DIR)"
CONFIGURE_ARGS+= \
--with-python=$(STAGING_DIR_HOSTPKG)/bin/python$(PYTHON_VERSION)
else else
@ -754,21 +756,6 @@ define Build/Prepare
$(if $(CONFIG_PACKAGE_$(PKG_NAME)-mod-$(m)), $(if $(CONFIG_PACKAGE_$(PKG_NAME)-mod-$(m)),
$(SED) '/mod_$(m)$$$$/s/^#//' $(PKG_BUILD_DIR)/modules.conf)) $(SED) '/mod_$(m)$$$$/s/^#//' $(PKG_BUILD_DIR)/modules.conf))
ifneq ($(CONFIG_PACKAGE_$(PKG_NAME)-misc-python-esl)$(CONFIG_PACKAGE_$(PKG_NAME)-mod-python),)
$(SED) 's|^LOCAL_CFLAGS=.*|LOCAL_CFLAGS=-I$(PYTHON_INC_DIR)|' \
$(PKG_BUILD_DIR)/libs/esl/python/Makefile
$(SED) 's|^LOCAL_LDFLAGS=.*|LOCAL_LDFLAGS=$(PYTHON_LDFLAGS)|' \
$(PKG_BUILD_DIR)/libs/esl/python/Makefile
$(SED) 's|^SITE_DIR=.*|SITE_DIR=$$$$(DESTDIR)$(PYTHON_PKG_DIR)|' \
$(PKG_BUILD_DIR)/libs/esl/python/Makefile
$(SED) 's|^PYTHON_SITE_DIR=.*|PYTHON_SITE_DIR=$(PYTHON_PKG_DIR)|' \
$(PKG_BUILD_DIR)/src/mod/languages/mod_python/Makefile.am
$(SED) 's|@PYTHON_CFLAGS@|-I$(PYTHON_INC_DIR)|' \
$(PKG_BUILD_DIR)/src/mod/languages/mod_python/Makefile.am
$(SED) 's|@PYTHON_LDFLAGS@|$(PYTHON_LDFLAGS)|' \
$(PKG_BUILD_DIR)/src/mod/languages/mod_python/Makefile.am
endif
$(SED) 's|$(FS_STABLE_ANCHOR)|APR_SETVAR(LDFLAGS,$(FS_STABLE_APR_LIBS) $(TARGET_LDFLAGS))|' \ $(SED) 's|$(FS_STABLE_ANCHOR)|APR_SETVAR(LDFLAGS,$(FS_STABLE_APR_LIBS) $(TARGET_LDFLAGS))|' \
$(PKG_BUILD_DIR)/libs/unimrcp/build/acmacros/apr.m4 $(PKG_BUILD_DIR)/libs/unimrcp/build/acmacros/apr.m4

View file

@ -55,3 +55,28 @@
save_CFLAGS="$CFLAGS" save_CFLAGS="$CFLAGS"
CFLAGS="$PERL_CFLAGS" CFLAGS="$PERL_CFLAGS"
@@ -1656,24 +1626,12 @@ then
if test "$python_has_distutils" != "no" ; then
AC_MSG_CHECKING([location of site-packages])
- PYTHON_SITE_DIR="`$PYTHON -c 'from distutils import sysconfig; print(sysconfig.get_python_lib(0));'`"
-
if test -z "$PYTHON_SITE_DIR" ; then
AC_MSG_ERROR([Unable to detect python site-packages path])
- elif test ! -d "$PYTHON_SITE_DIR" ; then
- AC_MSG_ERROR([Path $PYTHON_SITE_DIR returned by python does not exist!])
fi
AC_MSG_RESULT([$PYTHON_SITE_DIR])
AC_SUBST([PYTHON_SITE_DIR], [$PYTHON_SITE_DIR])
- #
- # python distutils found, get settings from python directly
- #
- PYTHON_CFLAGS="`$PYTHON -c 'from distutils import sysconfig; flags = [[\"-I\" + sysconfig.get_python_inc(0), \"-I\" + sysconfig.get_python_inc(1), \" \".join(sysconfig.get_config_var(\"CFLAGS\").split())]]; print(\" \".join(flags));' | sed -e 's/-arch i386//g;s/-arch x86_64//g'`"
- PYTHON_LDFLAGS="`$PYTHON -c 'from distutils import sysconfig; libs = sysconfig.get_config_var(\"LIBS\").split() + sysconfig.get_config_var(\"SYSLIBS\").split(); libs.append(\"-lpython\"+sysconfig.get_config_var(\"VERSION\")); print(\" \".join(libs));'`"
- PYTHON_LIB="`$PYTHON -c 'from distutils import sysconfig; print(\"python\" + sysconfig.get_config_var(\"VERSION\"));'`"
- PYTHON_LIBDIR="`$PYTHON -c 'from distutils import sysconfig; print(sysconfig.get_config_var(\"LIBDIR\"));'`"
-
# handle python being installed into /usr/local
AC_MSG_CHECKING([python libdir])
if test -z "`echo $PYTHON_LIBDIR | grep "/usr/lib"`" ; then

View file

@ -1,6 +1,6 @@
--- a/configure.ac --- a/configure.ac
+++ b/configure.ac +++ b/configure.ac
@@ -1953,7 +1953,13 @@ AC_SUBST(OUR_DISABLED_INSTALL_MODS) @@ -1941,7 +1941,13 @@ AC_SUBST(OUR_DISABLED_INSTALL_MODS)
AC_SUBST(OUR_DISABLED_UNINSTALL_MODS) AC_SUBST(OUR_DISABLED_UNINSTALL_MODS)
AC_SUBST(AM_MAKEFLAGS) AC_SUBST(AM_MAKEFLAGS)

View file

@ -0,0 +1,43 @@
--- a/libs/esl/python/Makefile
+++ b/libs/esl/python/Makefile
@@ -1,6 +1,4 @@
-LOCAL_CFLAGS=`python ./python-config --includes`
-LOCAL_LDFLAGS=`python ./python-config --ldflags`
-SITE_DIR=$(DESTDIR)/`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)"`
+SITE_DIR=$(DESTDIR)/$(PYTHON_SITE_DIR)
all: _ESL.so
@@ -8,10 +6,10 @@ esl_wrap.cpp:
swig2.0 -module ESL -classic -python -c++ -DMULTIPLICITY -threads -I../src/include -o esl_wrap.cpp ../ESL.i
esl_wrap.o: esl_wrap.cpp
- $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o
+ $(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(PYTHON_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o
_ESL.so: esl_wrap.o
- $(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o _ESL.so -L. $(LIBS)
+ $(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(PYTHON_LDFLAGS) -o _ESL.so -L. $(LIBS)
install: _ESL.so
mkdir -p $(SITE_DIR)
--- a/libs/esl/Makefile.am
+++ b/libs/esl/Makefile.am
@@ -77,7 +77,7 @@ luamod: $(MYLIB)
$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" LUA_CFLAGS="$(LUA_CFLAGS)" LUA_LIBS="$(LUA_LIBS)" -C lua
pymod: $(MYLIB)
- $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C python
+ $(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" PYTHON_CFLAGS="$(PYTHON_CFLAGS)" PYTHON_LDFLAGS="$(PYTHON_LDFLAGS)" -C python
tclmod: $(MYLIB)
$(MAKE) MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CFLAGS)" CXXFLAGS="-I$(switch_srcdir)/libs/esl/src/include $(SWITCH_AM_CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C tcl
@@ -98,7 +98,7 @@ phpmod-install: phpmod
$(MAKE) -C php install
pymod-install: pymod
- $(MAKE) -C python install
+ $(MAKE) PYTHON_SITE_DIR="$(PYTHON_SITE_DIR)" -C python install
rubymod-install: rubymod
$(MAKE) -C ruby install