Don't try to be too smart with python on win32

This commit is contained in:
Yevgen Muntyan 2010-12-05 22:17:34 -08:00
parent 90978e85d9
commit baf3af0dc1
6 changed files with 42 additions and 197 deletions

View File

@ -1,50 +1,3 @@
##############################################################################
# _MOO_AC_CHECK_PYGTK(action-if-found,action-if-not-found)
# checks pygtk stuff
#
AC_DEFUN([_MOO_AC_CHECK_PYGTK],[
AC_REQUIRE([MOO_AC_CHECK_OS])
PKG_CHECK_MODULES(PYGTK,pygtk-2.0 >= 2.6.0,[
AC_MSG_CHECKING([whether pygtk can be used])
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PYGTK_CFLAGS $PYTHON_INCLUDES"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PYGTK_CFLAGS $PYTHON_INCLUDES"
save_LIBS="$LIBS"
LIBS="$LIBS $PYGTK_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $PYGTK_LDFLAGS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS"
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <pygobject.h>
int main ()
{
PyObject *object = pygobject_new (NULL);
return 0;
}]])],[
AC_MSG_RESULT(yes)
PYGTK_DEFS_DIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
AC_SUBST(PYGTK_DEFS_DIR)
PYGTK_CODEGEN_DIR=`$PKG_CONFIG --variable=codegendir pygtk-2.0`
AC_SUBST(PYGTK_CODEGEN_DIR)
AC_MSG_NOTICE([pygtk defs dir: $PYGTK_DEFS_DIR])
m4_if([$1],[],[:],[$1])
],[
AC_MSG_RESULT([no])
m4_if([$2],[],[:],[$2])
])
CFLAGS="$save_CFLAGS"
CPPFLAGS="$save_CPPFLAGS"
LIBS="$save_LIBS"
LDFLAGS="$save_LDFLAGS"
],[
m4_if([$2],[],[:],[$2])
])
])
############################################################################## ##############################################################################
# MOO_AC_PYTHON() # MOO_AC_PYTHON()
# #
@ -67,23 +20,18 @@ AC_DEFUN_ONCE([MOO_AC_PYTHON],[
fi fi
]) ])
if test "x$MOO_OS_CYGWIN" = "xyes"; then
MOO_ENABLE_PYTHON=false
fi
if $MOO_ENABLE_PYTHON; then if $MOO_ENABLE_PYTHON; then
MOO_ENABLE_PYTHON=false MOO_ENABLE_PYTHON=false
MOO_AC_CHECK_PYTHON($_moo_python_version,[ MOO_AC_CHECK_PYTHON($_moo_python_version,[
_MOO_AC_CHECK_PYGTK([ PKG_CHECK_MODULES(PYGTK,pygtk-2.0 >= 2.6.0,[
MOO_ENABLE_PYTHON=true MOO_ENABLE_PYTHON=true
_MOO_SPLIT_VERSION_PKG(PYGTK, pygtk-2.0) ],[:])
AC_SUBST(PYGTK_VERSION)
AC_SUBST(PYGTK_MAJOR_VERSION)
AC_SUBST(PYGTK_MINOR_VERSION)
AC_SUBST(PYGTK_MICRO_VERSION)
])
]) ])
if $MOO_ENABLE_PYTHON; then
AC_SUBST([PYGTK_DEFS_DIR],[`$PKG_CONFIG --variable=defsdir pygtk-2.0`])
fi
if $MOO_ENABLE_PYTHON; then if $MOO_ENABLE_PYTHON; then
AC_MSG_NOTICE([compiling python support]) AC_MSG_NOTICE([compiling python support])
elif test "x$_moo_want_python" = "xyes"; then elif test "x$_moo_want_python" = "xyes"; then
@ -103,6 +51,6 @@ AC_DEFUN_ONCE([MOO_AC_PYTHON],[
if $MOO_ENABLE_PYTHON; then if $MOO_ENABLE_PYTHON; then
MOO_CFLAGS="$MOO_CFLAGS $PYGTK_CFLAGS $PYTHON_INCLUDES" MOO_CFLAGS="$MOO_CFLAGS $PYGTK_CFLAGS $PYTHON_INCLUDES"
MOO_CXXFLAGS="$MOO_CXXFLAGS $PYGTK_CFLAGS $PYTHON_INCLUDES" MOO_CXXFLAGS="$MOO_CXXFLAGS $PYGTK_CFLAGS $PYTHON_INCLUDES"
MOO_LIBS="$MOO_LIBS $PYGTK_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYGTK_LDFLAGS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS" MOO_LIBS="$MOO_LIBS $PYGTK_LIBS $PYTHON_LIBS"
fi fi
]) ])

View File

@ -1,96 +0,0 @@
dnl ------------------------------------------------------------------------
dnl MOO_AM_PYTHON_DEVEL_CROSS_MINGW([action-if-found[,action-if-not-found]])
dnl
AC_DEFUN([MOO_AM_PYTHON_DEVEL_CROSS_MINGW],[
AC_REQUIRE([AC_PROG_SED]) dnl to get $SED set
AM_PATH_PYTHON
if test "x$WIN32_PYTHON_HOME" = x; then
AC_MSG_ERROR([WIN32_PYTHON_HOME environment variable must be set dnl
when cross-compiling with mingw])
fi
AC_MSG_CHECKING(host system python version)
if test "x$WIN32_PYTHON_VERSION" = x; then
# guess python version, very clever heuristics here
for _ac_python_minor in 3 4 5 6 7 8 9; do
if test -f "$WIN32_PYTHON_HOME/libs/libpython2$_ac_python_minor.a" -o \
-f "$WIN32_PYTHON_HOME/libs/python2$_ac_python_minor.lib" ;
then
_ac_pyversion="2.$_ac_python_minor"
break
fi
done
else
_ac_pyversion=$WIN32_PYTHON_VERSION
fi
if test "x$_ac_pyversion" = x; then
AC_MSG_ERROR([Could not determine Python version])
fi
AC_MSG_RESULT([$_ac_pyversion])
_ac_pyversion_no_dot=`echo $_ac_pyversion | $SED 's/^2\.*\([[3-9]]\).*/2\1/'`
AC_MSG_CHECKING(installation directory for python modules)
if test "x$WIN32_PYTHON_PKG_DIR" != x; then
_ac_pythondir="$WIN32_PYTHON_PKG_DIR"
else
_ac_pythondir="$WIN32_PYTHON_HOME/Lib/site-packages"
fi
AC_MSG_RESULT([$_ac_pythondir])
if test "x$WIN32_PYTHON_INCLUDES" != x; then
_ac_pyincludes="$WIN32_PYTHON_INCLUDES"
else
_ac_pyincludes="-I$WIN32_PYTHON_HOME/include"
fi
if test "x$WIN32_PYTHON_LIBS" != x; then
_ac_pylibs="$WIN32_PYTHON_LIBS"
else
_ac_pylibs="-L$WIN32_PYTHON_HOME/libs -lpython$_ac_pyversion_no_dot"
fi
if test "x$WIN32_PYTHON_LDFLAGS" != x; then
_ac_pyldflags="$WIN32_PYTHON_LDFLAGS"
else
_ac_pyldflags=
fi
_ac_have_pydev=false
_ac_save_CPPFLAGS="$CPPFLAGS"
_ac_save_LDFLAGS="$LDFLAGS"
_ac_save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $_ac_pyincludes"
LDFLAGS="$LDFLAGS $_ac_pyldflags"
LIBS="$LIBS $_ac_pylibs"
AC_MSG_CHECKING(python headers and linker flags)
AC_TRY_LINK([#include <Python.h>],[Py_Initialize();],[
AC_MSG_RESULT([$_ac_pyincludes $_ac_pyldflags $_ac_pylibs])
_ac_have_pydev=true
],[
AC_MSG_RESULT(not found)
])
CPPFLAGS="$_ac_save_CPPFLAGS"
LDFLAGS="$_ac_save_LDFLAGS"
LIBS="$_ac_save_LIBS"
if $_ac_have_pydev; then
AC_SUBST(PYTHON_PLATFORM, [nt])
AC_SUBST(PYTHON_INCLUDES,[$_ac_pyincludes])
AC_SUBST(PYTHON_LIBS,[$_ac_pylibs])
AC_SUBST(PYTHON_EXTRA_LIBS,[])
AC_SUBST(PYTHON_LDFLAGS,[$_ac_pyldflags])
AC_SUBST(PYTHON_EXTRA_LDFLAGS,[])
AC_SUBST(pythondir,[$_ac_pythondir])
AC_SUBST(pyexecdir,[$_ac_pythondir])
AC_SUBST(pkgpythondir,[\${pythondir}/$PACKAGE])
AC_SUBST(pkgpyexecdir,[\${pythondir}/$PACKAGE])
m4_if([$1],[],[:],[$1])
else
m4_if([$2],[],[:],[$2])
fi
])
dnl
dnl end of MOO_AM_PYTHON_DEVEL_CROSS_MINGW
dnl --------------------------------------

View File

@ -72,27 +72,6 @@ Please check your Python installation.])
AC_SUBST([PYTHON_LIBS]) AC_SUBST([PYTHON_LIBS])
fi fi
# Check for Python extra linker flags
# if PYTHON_EXTRA_LIBS is set, do not do anything
if test $python_found = yes; then
if test "x$PYTHON_EXTRA_LIBS" = "x"; then
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
print conf('LOCALMODLIBS'), conf('LIBS')"`
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
print conf('LDFLAGS')"`
fi
AC_MSG_CHECKING([Python extra libs])
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
AC_MSG_CHECKING([Python extra linker flags])
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
AC_SUBST([PYTHON_EXTRA_LIBS])
AC_SUBST([PYTHON_EXTRA_LDFLAGS])
fi
if test $python_found = yes; then if test $python_found = yes; then
m4_if([$1],[],[:],[$1]) m4_if([$1],[],[:],[$1])
else else
@ -102,10 +81,10 @@ Please check your Python installation.])
############################################################################## ##############################################################################
# _MOO_AC_CHECK_PYTHON_UNIX(min-version,action-if-found,action-if-not-found) # MOO_AC_CHECK_PYTHON_NATIVE(min-version,action-if-found,action-if-not-found)
# checks python stuff when building for unix # checks python stuff when building for unix
# #
AC_DEFUN([_MOO_AC_CHECK_PYTHON_UNIX],[ AC_DEFUN([MOO_AC_CHECK_PYTHON_NATIVE],[
AM_PATH_PYTHON([$1],[ AM_PATH_PYTHON([$1],[
_MOO_AC_PYTHON_DEVEL([ _MOO_AC_PYTHON_DEVEL([
python_found=yes python_found=yes
@ -122,24 +101,39 @@ AC_DEFUN([_MOO_AC_CHECK_PYTHON_UNIX],[
else else
PYTHON_INCLUDES="" PYTHON_INCLUDES=""
PYTHON_LIBS="" PYTHON_LIBS=""
PYTHON_EXTRA_LIBS=""
m4_if([$3],[],[:],[$3]) m4_if([$3],[],[:],[$3])
fi fi
]) ])
AC_DEFUN([MOO_AM_PYTHON_DEVEL_CROSS_MINGW],[
if test x"$PYTHON_INCLUDES" = x; then
AC_MSG_ERROR([PYTHON_INCLUDES is not set])
fi
if test x"$PYTHON_LIBS" = x; then
AC_MSG_ERROR([PYTHON_LIBS is not set])
fi
AC_ARG_VAR([PYTHON_INCLUDES], [python preprocessor flags])
AC_ARG_VAR([PYTHON_LIBS], [python linker flags])
AC_SUBST(PYTHON_INCLUDES)
AC_SUBST(PYTHON_LIBS)
AC_MSG_CHECKING([for Python include path])
AC_MSG_RESULT([$PYTHON_INCLUDES])
AC_MSG_CHECKING([for Python linker flags])
AC_MSG_RESULT([$PYTHON_LIBS])
$1
])
############################################################################## ##############################################################################
# MOO_AC_CHECK_PYTHON(min-version,action-if-found,action-if-not-found) # MOO_AC_CHECK_PYTHON(min-version,action-if-found,action-if-not-found)
# checks for python, python includes and libs # checks for python, python includes and libs
# #
AC_DEFUN([MOO_AC_CHECK_PYTHON],[ AC_DEFUN([MOO_AC_CHECK_PYTHON],[
AC_MSG_NOTICE([checking for headers and libs required to compile python extensions])
AC_REQUIRE([MOO_AC_CHECK_OS]) AC_REQUIRE([MOO_AC_CHECK_OS])
if test x$MOO_OS_CYGWIN != xyes; then if test "$cross_compiling" = yes -a "$MOO_OS_WIN32" = true; then
if test x$MOO_OS_MINGW = xyes; then
MOO_AM_PYTHON_DEVEL_CROSS_MINGW([$2],[$3]) MOO_AM_PYTHON_DEVEL_CROSS_MINGW([$2],[$3])
else else
_MOO_AC_CHECK_PYTHON_UNIX([$1],[$2],[$3]) MOO_AC_CHECK_PYTHON_NATIVE([$1],[$2],[$3])
fi
fi fi
]) ])

View File

@ -12,7 +12,7 @@ import override
import reversewrapper import reversewrapper
import warnings import warnings
pygtk_version = 6 pygtk_version = 16
class Coverage(object): class Coverage(object):
def __init__(self, name): def __init__(self, name):
@ -1681,11 +1681,6 @@ def main(argv):
errorfilename = arg errorfilename = arg
elif opt == '--platform': elif opt == '--platform':
sys.platform = arg sys.platform = arg
elif opt == '--pygtk-version':
global pygtk_version
pygtk_version = int(arg)
if pygtk_version < 8:
defines['pygtk-2.6'] = '1'
elif opt in ('-t', '--load-types'): elif opt in ('-t', '--load-types'):
globals = {} globals = {}
execfile(arg, globals) execfile(arg, globals)

View File

@ -23,7 +23,7 @@ built_moo_python_sources += \
moopython/pygtk/moo-mod.c \ moopython/pygtk/moo-mod.c \
moopython/pygtk/moo-mod.h moopython/pygtk/moo-mod.h
if MOO_OS_MINGW if MOO_OS_WIN32
codegen_platform = --platform win32 codegen_platform = --platform win32
endif endif
@ -36,8 +36,8 @@ codegen_script = $(srcdir)/moopython/codegen/codegen.py
codegen = $(PYTHON) $(codegen_script) $(codegen_platform) --pygtk-version=$(PYGTK_MINOR_VERSION) codegen = $(PYTHON) $(codegen_script) $(codegen_platform) --pygtk-version=$(PYGTK_MINOR_VERSION)
moopython/pygtk/moo-mod.c: $(moo_override_files) $(moo_defs_files) $(codegen_files) moopython/pygtk/moo-mod.c: $(moo_override_files) $(moo_defs_files) $(codegen_files)
$(MKDIR_P) moopython/pygtk $(AM_V_at)$(MKDIR_P) moopython/pygtk
$(codegen) --prefix _moo \ $(AM_V_GEN)$(codegen) --prefix _moo \
--load-types $(srcdir)/moopython/codegen/argtypes_m.py \ --load-types $(srcdir)/moopython/codegen/argtypes_m.py \
--register $(PYGTK_DEFS_DIR)/gtk-types.defs \ --register $(PYGTK_DEFS_DIR)/gtk-types.defs \
--register $(PYGTK_DEFS_DIR)/gdk-types.defs \ --register $(PYGTK_DEFS_DIR)/gdk-types.defs \
@ -47,4 +47,5 @@ moopython/pygtk/moo-mod.c: $(moo_override_files) $(moo_defs_files) $(codegen_fil
mv $@.tmp $@ mv $@.tmp $@
moopython/pygtk/moo-mod.h: moopython/pygtk/moo.py $(top_srcdir)/tools/xml2h.py moopython/pygtk/moo-mod.h: moopython/pygtk/moo.py $(top_srcdir)/tools/xml2h.py
$(AM_V_at)$(MKDIR_P) moopython/pygtk
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/tools/xml2h.py $(srcdir)/moopython/pygtk/moo.py moopython/pygtk/moo-mod.h MOO_PY $(AM_V_GEN)$(PYTHON) $(top_srcdir)/tools/xml2h.py $(srcdir)/moopython/pygtk/moo.py moopython/pygtk/moo-mod.h MOO_PY

View File

@ -70,6 +70,9 @@ export OBJCFLAGS="-mms-bitfields -march=i686 $_def_cflags"
export PKG_CONFIG_LIBDIR="$mgwtargetdir/lib/pkgconfig" export PKG_CONFIG_LIBDIR="$mgwtargetdir/lib/pkgconfig"
export PKG_CONFIG_PATH="$mgwtargetdir/lib/pkgconfig" export PKG_CONFIG_PATH="$mgwtargetdir/lib/pkgconfig"
export PYTHON_INCLUDES="-I$mgwtargetdir/include/python"
export PYTHON_LIBS="-lpython27"
configure_args="--build=i686-pc-linux-gnu --host=i586-pc-mingw32msvc --target=i586-pc-mingw32msvc \ configure_args="--build=i686-pc-linux-gnu --host=i586-pc-mingw32msvc --target=i586-pc-mingw32msvc \
AR=$AR RANLIB=$RANLIB STRIP=$STRIP AS=$AS DLLTOOL=$DLLTOOL OBJDUMP=$OBJDUMP NM=$NM WINDRES=$WINDRES RC=$RC \ AR=$AR RANLIB=$RANLIB STRIP=$STRIP AS=$AS DLLTOOL=$DLLTOOL OBJDUMP=$OBJDUMP NM=$NM WINDRES=$WINDRES RC=$RC \
INSTALL=`which install-check` \ INSTALL=`which install-check` \