Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On 12.06.2012 09:23, Stephan Bergmann wrote:
On 06/12/2012 09:17 AM, David Ostrovsky wrote:
What do you mean here?

Personally, for an experimental platform like mingw, and as you have demonstrated that it does not work right now, I would not bother to make it work prior to gbuild'ification.

Has pyuno on mingw ever been known to work?
yes ... with attached patch ;-)
(actually only python.exe with import pyuno was working, open macro dialog from swriter is still crashing, but I suspect some other problems here, need to look into it)

Actually we have two routes to go here:
1/ Taking system-python into installation set (this combination is unique: no other platform using it, but normal on mingw, see external/mingw-dlls/makefile.mk) 2/ Having internal python compiles on mingw and packaging it like on other platforms. I've seen that David Tardon is working on it.

I'm taking the first route with this patch (but i tried to take into consideration that internal python may be working some day on mingw,
that why more if else endif as needed in pyuno module)

** new MINGW_PYTHON specific vars are exported in configure.in:
grep -i -e mingw_py -e mingw_readline -e mingw_termcap config_host.mk
export MINGW_PYTHON_DLL=libpython2.6.dll
export MINGW_PYTHON_MAJOR_VERSION=2.6
export MINGW_PYVERSION=2.6.2
export MINGW_PYTHON_SYSROOT=/usr/i686-w64-mingw32/sys-root/mingw
export MINGW_READLINE_DLL=libreadline6.dll
export MINGW_TERMCAP_DLL=libtermcap-0.dll

** python_wrapper.exe has to be built (with pyversion.hxx and delivering). Changed from python.bin to python.exe in python.cxx.

** external/mingw-dlls: libpython2.6.dll and two other depended libs are copied(readline & termcap)

** scp2 is aware now of this specific case: MINGW_SYSTEM_PYTHON:
o python-core-2.6.2.zip is created from /usr/i686-w64-mingw32/sys-root/mingw/lib/python2.6 and extracted to program/python-core-2.6.2/lib o python.exe is copied from /usr/i686-w64-mingw32/sys-root/mingw/bin/python.exe to program/python-core-2.6.2/bin/python.exe

Can this part be optimized? copying for now /usr/i686-w64-mingw32/sys-root/mingw/bin/python.exe to (OUTDIR)/bin/python.exe with new makefile CustomTarget_python_mingw_bin.mk and wonder if it can be done directly in scp2 (without using CustomTarget_python_mingw_bin.mk):
define something like that:
    -DMINGW_SYSTEM_PYTHON_BIN_DIR=$(MINGW_PYTHON_SYSROOT)/bin \
and try to use it in Dir/File rule?

May be i did too much copy/paste here? Is it really needed to differentiate between SYSTEM_PYTHON=NO and MINGW_SYSTEM_PYTHON = YES?
Can it be done with simple OR-operator (i.e. combine these cases somehow=?

o python.exe (wrapper) is copied from (OUTDIR)/bin/pyuno/python.exe to program/python.exe

Thanks
David

PS: packaging part is still need to be tested.

From fff528293b2aa7f8bf868ded78689943fee5b458 Mon Sep 17 00:00:00 2001
From: David Ostrovsky <d.ostrovsky@gmx.de>
Date: Mon, 18 Jun 2012 00:04:19 +0200
Subject: [PATCH] fixing pyuno bridge on mingw: packaging system-python

Change-Id: Ib46248d217b0161dc20dde0274842bd7381f0cda
---
 config_host.mk.in                      |    6 ++++
 configure.in                           |   19 +++++++++++++-
 external/mingw-dlls/makefile.mk        |    3 ++
 pyuno/CustomTarget_python_mingw_bin.mk |   37 ++++++++++++++++++++++++++
 pyuno/CustomTarget_pyversion.mk        |    8 ++++++
 pyuno/CustomTarget_zipcore.mk          |   15 +++++++++-
 pyuno/Module_pyuno.mk                  |   18 ++++++++++++-
 pyuno/Package_zipcore.mk               |    9 ++++++
 pyuno/zipcore/python.cxx               |    4 ---
 scp2/InstallModule_python.mk           |    9 ++++++
 scp2/source/python/file_python.scp     |   44 +++++++++++++++++++++++++++++++-
 scp2/source/python/module_python.scp   |    3 +-
 12 files changed, 165 insertions(+), 10 deletions(-)
 create mode 100644 pyuno/CustomTarget_python_mingw_bin.mk

diff --git a/config_host.mk.in b/config_host.mk.in
index ecc3042..a79554144 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -338,8 +338,13 @@ export MINGW_PIXMAN_DLL=@MINGW_PIXMAN_DLL@
 export MINGW_PLC4_DLL=@MINGW_PLC4_DLL@
 export MINGW_PLDS4_DLL=@MINGW_PLDS4_DLL@
 export MINGW_PNG15_DLL=@MINGW_PNG15_DLL@
+export MINGW_PYTHON_DLL=@MINGW_PYTHON_DLL@
+export MINGW_PYTHON_MAJOR_VERSION=@MINGW_PYTHON_MAJOR_VERSION@
+export MINGW_PYTHON_SYSROOT=@MINGW_PYTHON_SYSROOT@
+export MINGW_PYVERSION=@MINGW_PYVERSION@
 export MINGW_RAPTOR_DLL=@MINGW_RAPTOR_DLL@
 export MINGW_RASQAL_DLL=@MINGW_RASQAL_DLL@
+export MINGW_READLINE_DLL=@MINGW_READLINE_DLL@
 export MINGW_REDLAND_DLL=@MINGW_REDLAND_DLL@
 export MINGW_SHARED_GCCLIB=@MINGW_SHARED_GCCLIB@
 export MINGW_SHARED_GXXLIB=@MINGW_SHARED_GXXLIB@
@@ -349,6 +354,7 @@ export MINGW_SSH2_DLL=@MINGW_SSH2_DLL@
 export MINGW_SSL3_DLL=@MINGW_SSL3_DLL@
 export MINGW_SSL_DLL=@MINGW_SSL_DLL@
 export MINGW_TASN1_DLL=@MINGW_TASN1_DLL@
+export MINGW_TERMCAP_DLL=@MINGW_TERMCAP_DLL@
 export MINGW_ZLIB_DLL=@MINGW_ZLIB_DLL@
 export MINIZIP_CFLAGS=@MINIZIP_CFLAGS@
 export MINIZIP_LIBS=@MINIZIP_LIBS@
diff --git a/configure.in b/configure.in
index 011aa22..8faca38 100644
--- a/configure.in
+++ b/configure.in
@@ -6678,12 +6678,23 @@ if test $enable_python = system; then
     else
         dnl How to find out the cross-compilation Python installation path?
         dnl Let's hardocode what we know for different distributions for now...
-
         for python_sysroot in /usr/i686-w64-mingw32/sys-root/mingw; do
             for python_version in 2.6; do
                 if test -f ${python_sysroot}/include/python${python_version}/Python.h; then
+                    MINGW_PYTHON_SYSROOT=$python_sysroot
                     PYTHON_CFLAGS="-I${python_sysroot}/include/python$python_version"
                     PYTHON_LIBS="-L${python_sysroot}lib -lpython$python_version $python_libs"
+                    libo_MINGW_CHECK_DLL([PYTHON], [libpython$python_version])
+                    # suffix 6 is hard coded?
+                    libo_MINGW_CHECK_DLL([READLINE], [libreadline6])
+                    # suffix -0 is hard coded?
+                    libo_MINGW_CHECK_DLL([TERMCAP], [libtermcap-0])
+                    # could we somehow extract the really mingw python version from
+                    # actual distro package? 
+                    # 2.6.2 currently on OpenSUSE 12.1?
+                    # rpm -q mingw32-python => mingw32-python-2.6.2-17.17.noarch
+                    MINGW_PYTHON_MAJOR_VERSION="$python_version"
+                    MINGW_PYVERSION=$python_version.2
                     break
                 fi
             done
@@ -6742,6 +6753,12 @@ fi
 AC_SUBST(SYSTEM_PYTHON)
 AC_SUBST(PYTHON_CFLAGS)
 AC_SUBST(PYTHON_LIBS)
+AC_SUBST(MINGW_PYTHON_SYSROOT)
+AC_SUBST([MINGW_PYTHON_DLL])
+AC_SUBST([MINGW_READLINE_DLL])
+AC_SUBST([MINGW_TERMCAP_DLL])
+AC_SUBST(MINGW_PYVERSION)
+AC_SUBST(MINGW_PYTHON_MAJOR_VERSION)
 
 dnl ===================================================================
 dnl Check for system Berkeley db
diff --git a/external/mingw-dlls/makefile.mk b/external/mingw-dlls/makefile.mk
index 5f1722a..a106078 100644
--- a/external/mingw-dlls/makefile.mk
+++ b/external/mingw-dlls/makefile.mk
@@ -74,17 +74,20 @@ MINGW_DLLS:= \
     $(MINGW_NSS3_DLL) \
     $(MINGW_NSSUTIL3_DLL) \
     $(MINGW_PIXMAN_DLL) \
+    $(MINGW_PYTHON_DLL) \
     $(MINGW_PLC4_DLL) \
     $(MINGW_PLDS4_DLL) \
     $(MINGW_PNG15_DLL) \
     $(MINGW_RAPTOR_DLL) \
     $(MINGW_RASQAL_DLL) \
+    $(MINGW_READLINE_DLL) \
     $(MINGW_REDLAND_DLL) \
     $(MINGW_SQLITE3_DLL) \
     $(MINGW_SSH2_DLL) \
     $(MINGW_SSL3_DLL) \
     $(MINGW_SSL_DLL) \
     $(MINGW_TASN1_DLL) \
+    $(MINGW_TERMCAP_DLL) \
     $(MINGW_ZLIB_DLL)
 
 .IF "$(MINGW_SHARED_GCCLIB)" == "YES"
diff --git a/pyuno/CustomTarget_python_mingw_bin.mk b/pyuno/CustomTarget_python_mingw_bin.mk
new file mode 100644
index 0000000..d6ccabe
--- /dev/null
+++ b/pyuno/CustomTarget_python_mingw_bin.mk
@@ -0,0 +1,37 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2012 David Ostrovsky <d.ostrovsky@gmx.de> (initial developer)
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_CustomTarget_CustomTarget,pyuno/python_mingw_bin))
+
+python_mingw_bin_SOURCE := $(MINGW_PYTHON_SYSROOT)/bin/python.exe
+python_mingw_bin_TARGET := $(OUTDIR)/bin/python.exe
+
+$(call gb_CustomTarget_get_target,pyuno/python_mingw_bin) : $(python_mingw_bin_TARGET)
+
+$(python_mingw_bin_TARGET) : $(python_mingw_bin_SOURCE)
+       cp $< $@
+
+# vim: set noet sw=4 ts=4:
diff --git a/pyuno/CustomTarget_pyversion.mk b/pyuno/CustomTarget_pyversion.mk
index 8766e7e..41b26c1 100644
--- a/pyuno/CustomTarget_pyversion.mk
+++ b/pyuno/CustomTarget_pyversion.mk
@@ -29,7 +29,15 @@ $(eval $(call gb_CustomTarget_CustomTarget,pyuno/pyversion))
 $(call gb_CustomTarget_get_target,pyuno/pyversion) : \
     $(call gb_CustomTarget_get_workdir,pyuno/pyversion)/pyversion.hxx
 
+# system python
+ifeq ($(SYSTEM_PYTHON),YES)
+# mingw: MINGW_PYVERSION is defined in configure
+ifeq ($(GUI)$(COM),WNTGCC)
+PYVERSION=$(MINGW_PYVERSION)
+endif
+else
 include $(OUTDIR)/inc/pyversion.Makefile
+endif
 
 $(call gb_CustomTarget_get_workdir,pyuno/pyversion)/pyversion.hxx : 
$(SRCDIR)/pyuno/zipcore/pyversion.inc | \
     $(call gb_CustomTarget_get_workdir,pyuno/pyversion)/.dir
diff --git a/pyuno/CustomTarget_zipcore.mk b/pyuno/CustomTarget_zipcore.mk
index ba22084..a9a6629 100644
--- a/pyuno/CustomTarget_zipcore.mk
+++ b/pyuno/CustomTarget_zipcore.mk
@@ -26,7 +26,18 @@
 
 $(eval $(call gb_CustomTarget_CustomTarget,pyuno/zipcore))
 
+# system python (only mingw)
+ifeq ($(SYSTEM_PYTHON),YES)
+# mingw: MINGW_PYVERSION and MINGW_PYTHON_SYSROOT are defined in configure
+ifeq ($(GUI)$(COM),WNTGCC)
+PYVERSION=$(MINGW_PYVERSION)
+pyuno_PYTHON_LIB_DIR=$(MINGW_PYTHON_SYSROOT)/lib/python$(MINGW_PYTHON_MAJOR_VERSION)
+endif
+else
 include $(OUTDIR)/inc/pyversion.Makefile
+pyuno_PYTHON_LIB_DIR=$(OUTDIR)/lib/python
+endif
+
 pyuno_PYTHON_ARCHIVE_NAME:=python-core-$(PYVERSION).zip
 FIND=find
 GREP=grep
@@ -36,12 +47,12 @@ $(call gb_CustomTarget_get_target,pyuno/zipcore) : \
 
 # capture the files to have them in prerequisite list
 pyuno_zipcore_FINDLIBFILES:=\
-    $(shell $(FIND) $(OUTDIR)/lib/python -type f| $(GREP) -v "\.pyc" | $(GREP) -v "\.py~" | 
$(GREP) -v .orig | $(GREP) -v _failed)
+    $(shell $(FIND) $(pyuno_PYTHON_LIB_DIR) -type f| $(GREP) -v "\.pyc" | $(GREP) -v "\.py~" | 
$(GREP) -v .orig | $(GREP) -v _failed)
 
 # create zip archive
 $(call gb_CustomTarget_get_workdir,pyuno/zipcore)/$(pyuno_PYTHON_ARCHIVE_NAME) : 
$(pyuno_zipcore_FINDLIBFILES) | \
     $(call gb_CustomTarget_get_workdir,pyuno/zipcore)/.dir
        $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),ZIP,1)
-       cd $(OUTDIR)/lib/python && zip $@ $(shell cd $(OUTDIR)/lib/python && $(FIND) . -type f | 
$(GREP) -v "\.pyc" | $(GREP) -v "\.py~" | $(GREP) -v .orig | $(GREP) -v _failed)
+       cd $(pyuno_PYTHON_LIB_DIR) && zip $@ $(shell cd $(pyuno_PYTHON_LIB_DIR) && $(FIND) . -type 
f | $(GREP) -v "\.pyc" | $(GREP) -v "\.py~" | $(GREP) -v .orig | $(GREP) -v _failed)
 
 # vim: set noet sw=4 ts=4:
diff --git a/pyuno/Module_pyuno.mk b/pyuno/Module_pyuno.mk
index e39bcd0..a7bbe8c 100755
--- a/pyuno/Module_pyuno.mk
+++ b/pyuno/Module_pyuno.mk
@@ -41,7 +41,11 @@ $(eval $(call gb_Module_add_targets,pyuno,\
 ))
 endif
 
-ifneq ($(SYSTEM_PYTHON),YES)
+#
+# Windows: only --enable-python=internal possible
+# mingw: both cases possible: internal && system
+# that why it makes sense to handle the next 3 targets
+# with SYSTEM_PYTHON=YES and SYSTEM_PYTHON=NO
 
 # zipcore: python.exe on Windows
 # zipcore: pyversion.hxx on Windows
@@ -53,6 +57,7 @@ $(eval $(call gb_Module_add_targets,pyuno,\
 ))
 endif
 
+ifneq ($(SYSTEM_PYTHON),YES)
 
 # zipcore: python.sh on Unix
 ifeq ($(GUI),UNX)
@@ -77,6 +82,17 @@ $(eval $(call gb_Module_add_targets,pyuno,\
 ))
 endif
 
+else # SYSTEM_PYTHON
+
+# previous two targets has to be executed also with system-python on mingw
+ifeq ($(OS)$(COM),WNTGCC)
+$(eval $(call gb_Module_add_targets,pyuno,\
+    CustomTarget_zipcore \
+    CustomTarget_python_mingw_bin \
+    Package_zipcore \
+))
+endif
+
 endif # SYSTEM_PYTHON
 
 endif # DISABLE_PYTHON
diff --git a/pyuno/Package_zipcore.mk b/pyuno/Package_zipcore.mk
index 9069a8f..3666ad7 100644
--- a/pyuno/Package_zipcore.mk
+++ b/pyuno/Package_zipcore.mk
@@ -26,7 +26,16 @@
 
 $(eval $(call gb_Package_Package,python_zipcore,$(call gb_CustomTarget_get_workdir,pyuno/zipcore)))
 
+# system python
+ifeq ($(SYSTEM_PYTHON),YES)
+# mingw: MINGW_PYVERSION is defined in configure
+ifeq ($(GUI)$(COM),WNTGCC)
+PYVERSION=$(MINGW_PYVERSION)
+endif
+else
 include $(OUTDIR)/inc/pyversion.Makefile
+endif
+
 pyuno_PYTHON_ARCHIVE_NAME:=python-core-$(PYVERSION).zip
 
 $(eval $(call 
gb_Package_add_file,python_zipcore,bin/$(pyuno_PYTHON_ARCHIVE_NAME),$(pyuno_PYTHON_ARCHIVE_NAME)))
diff --git a/pyuno/zipcore/python.cxx b/pyuno/zipcore/python.cxx
index cffee38..f4d3024 100644
--- a/pyuno/zipcore/python.cxx
+++ b/pyuno/zipcore/python.cxx
@@ -138,11 +138,7 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
     wchar_t pythonexe[MAX_PATH];
     wchar_t * pythonexeEnd = tools::buildPath(
         pythonexe, path, pathEnd,
-#ifdef __MINGW32__
-        MY_STRING(L"\\python-core-" MY_PYVERSION L"\\bin\\python.bin"));
-#else
         MY_STRING(L"\\python-core-" MY_PYVERSION L"\\bin\\python.exe"));
-#endif
     if (pythonexeEnd == NULL) {
         exit(EXIT_FAILURE);
     }
diff --git a/scp2/InstallModule_python.mk b/scp2/InstallModule_python.mk
index 53d0891..25276fa 100644
--- a/scp2/InstallModule_python.mk
+++ b/scp2/InstallModule_python.mk
@@ -40,6 +40,15 @@ else ifeq ($(SYSTEM_PYTHON),YES)
 $(eval $(call gb_InstallModule_add_defs,scp2/python,\
        -DSYSTEM_PYTHON \
 ))
+
+# mingw: mix mode copy file from system python to installation set
+ifeq ($(GUI)$(COM),WNTGCC)
+$(eval $(call gb_InstallModule_add_defs,scp2/python,\
+       -DPYVERSION=$(MINGW_PYVERSION) \
+       -DMINGW_SYSTEM_PYTHON=YES \
+))
+endif
+
 else
 include $(OUTDIR)/inc/pyversion.Makefile
 
diff --git a/scp2/source/python/file_python.scp b/scp2/source/python/file_python.scp
index 47ab5fe..b761620 100644
--- a/scp2/source/python/file_python.scp
+++ b/scp2/source/python/file_python.scp
@@ -310,7 +310,7 @@ Unixlink gid_Unixlink_Python_libpython
     Styles = ();
 End
 #endif //MACOSX
-#endif
+#endif //SYSTEM_PYTHON
 
 #ifdef UNX
 
@@ -324,5 +324,47 @@ End
 
 #endif
 
+#ifdef MINGW_SYSTEM_PYTHON
+
+// python_wrapper.exe
+File gid_File_Py_Bin_Python
+    BIN_FILE_BODY;
+    Name = EXENAME(pyuno/python);
+    Dir = gid_Brand_Dir_Program;
+    Styles = (PACKED);
+End
+
+Directory gid_Dir_Py_PythonCore
+    ParentID = gid_Brand_Dir_Program;
+    HostName = STRING(CONCAT2(python-core-,PYVERSION));
+End
+
+Directory gid_Dir_Py_PythonCore_Lib
+    ParentID = gid_Dir_Py_PythonCore;
+    HostName = "lib";
+End
+
+File gid_File_Py_Python_Core
+    TXT_FILE_BODY;
+    Dir = gid_Dir_Py_PythonCore_Lib;
+    Name = STRING(CONCAT3(python-core-,PYVERSION,.zip));
+    Styles = (ARCHIVE);
+End
+
+Directory gid_Dir_Py_PythonCore_Bin
+    ParentID = gid_Dir_Py_PythonCore
+    HostName = bin
+End
+
+File gid_File_Py_Python_Bin
+    BIN_FILE_BODY;
+    Dir = gid_Dir_Py_PythonCore_Bin;
+    Name = EXENAME(python);
+    Styles = (PACKED);
+End
+
+
+#endif //MINGW_SYSTEM_PYTHON
+
 // DISABLE_PYUNO
 #endif
diff --git a/scp2/source/python/module_python.scp b/scp2/source/python/module_python.scp
index 0f15826..a1e173a 100644
--- a/scp2/source/python/module_python.scp
+++ b/scp2/source/python/module_python.scp
@@ -41,7 +41,8 @@ Module gid_Module_Optional_Pyuno
             gid_Dir_PythonFramework_Versions_ver_lib,
             gid_Dir_PythonFramework_Versions_ver_lib_pythonver,
             gid_Dir_PythonFramework_Versions_ver_lib_pythonver_config,
-            gid_Dir_Py_PythonCore, gid_Dir_Py_PythonCore_Bin,
+            gid_Dir_Py_PythonCore, 
+            gid_Dir_Py_PythonCore_Bin,
             gid_Dir_Py_PythonCore_Lib);
     Files = (gid_File_Pyuno,
              gid_File_Lib_Pyuno,
-- 
1.7.5.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.