You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2020/01/25 09:53:36 UTC
[openoffice] branch trunk updated (252cf67 -> aec63fa)
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git.
from 252cf67 Merge pull request #27 from pgiffuni/trunk
new 37058ac pyuno: convert some tabs to spaces
new 4f68618 scripting: add Python 3 support to the Python provider
new 2971648 pyuno: wrap the right entrypoint for Python 3 in the pyuno dlopen wrapper
new 827897c pyuno: export the entrypoint for Python 3 from libpyuno
new 00503fa Detect Python's CFLAGS and LIBS using pkg-config when possible.
new aec63fa gtest patch to allow building with Python 3.
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
ext_libraries/gtest/gtest-python3.patch | 96 ++++++++++++++++++++++++++
ext_libraries/gtest/makefile.mk | 2 +-
main/configure.ac | 7 +-
main/pyuno/Library_pyuno_loader.mk | 2 +
main/pyuno/inc/pyuno/pyuno.hxx | 4 ++
main/pyuno/source/loader/pyuno_loader.cxx | 4 +-
main/pyuno/source/module/pyuno_dlopenwrapper.c | 39 ++++++++++-
main/pyuno/source/module/pyuno_module.cxx | 2 +-
main/scripting/source/pyprov/pythonscript.py | 14 ++--
9 files changed, 158 insertions(+), 12 deletions(-)
create mode 100644 ext_libraries/gtest/gtest-python3.patch
[openoffice] 04/06: pyuno: export the entrypoint for Python 3 from
libpyuno
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 827897c355691c72f37439b8706bc13261c25889
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 18 10:25:34 2020 +0200
pyuno: export the entrypoint for Python 3 from libpyuno
Patch by: me
---
main/pyuno/inc/pyuno/pyuno.hxx | 4 ++++
main/pyuno/source/module/pyuno_module.cxx | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/main/pyuno/inc/pyuno/pyuno.hxx b/main/pyuno/inc/pyuno/pyuno.hxx
index 1245921..cc5e366 100644
--- a/main/pyuno/inc/pyuno/pyuno.hxx
+++ b/main/pyuno/inc/pyuno/pyuno.hxx
@@ -76,7 +76,11 @@
preconditions: python has been initialized before and
the global interpreter lock is held
*/
+#if PY_MAJOR_VERSION >= 3
+PY_DLLEXPORT PyMODINIT_FUNC PyInit_pyuno();
+#else
extern "C" PY_DLLEXPORT void SAL_CALL initpyuno();
+#endif
namespace pyuno
diff --git a/main/pyuno/source/module/pyuno_module.cxx b/main/pyuno/source/module/pyuno_module.cxx
index e44b0d3..b781035 100644
--- a/main/pyuno/source/module/pyuno_module.cxx
+++ b/main/pyuno/source/module/pyuno_module.cxx
@@ -746,7 +746,7 @@ static struct PyModuleDef PyUNOModule =
}
#if PY_MAJOR_VERSION >= 3
-extern "C" PyMODINIT_FUNC PyInit_pyuno(void)
+PY_DLLEXPORT PyMODINIT_FUNC PyInit_pyuno()
{
PyObject *m;
[openoffice] 01/06: pyuno: convert some tabs to spaces
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 37058acdf5d65adaf7ee2d972967a68be69f5cf1
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Wed Jan 15 19:31:08 2020 +0200
pyuno: convert some tabs to spaces
Patch by: me
---
main/pyuno/source/loader/pyuno_loader.cxx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/main/pyuno/source/loader/pyuno_loader.cxx b/main/pyuno/source/loader/pyuno_loader.cxx
index 6ba2d1c..4768290 100644
--- a/main/pyuno/source/loader/pyuno_loader.cxx
+++ b/main/pyuno/source/loader/pyuno_loader.cxx
@@ -119,8 +119,8 @@ static void setPythonHome ( const OUString & pythonHome )
#else
static wchar_t *wpath = Py_DecodeLocale(o.pData->buffer, NULL);
if (wpath == NULL) {
- PyErr_SetString(PyExc_SystemError, "Cannot decode python home path");
- return;
+ PyErr_SetString(PyExc_SystemError, "Cannot decode python home path");
+ return;
}
Py_SetPythonHome(wpath);
#endif
[openoffice] 06/06: gtest patch to allow building with Python 3.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit aec63fa3669010e9bec513e6cd55a25fc335d90e
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 25 02:59:46 2020 +0200
gtest patch to allow building with Python 3.
Patch by: me
---
ext_libraries/gtest/gtest-python3.patch | 96 +++++++++++++++++++++++++++++++++
ext_libraries/gtest/makefile.mk | 2 +-
2 files changed, 97 insertions(+), 1 deletion(-)
diff --git a/ext_libraries/gtest/gtest-python3.patch b/ext_libraries/gtest/gtest-python3.patch
new file mode 100644
index 0000000..54e7d6f
--- /dev/null
+++ b/ext_libraries/gtest/gtest-python3.patch
@@ -0,0 +1,96 @@
+--- misc/build/gtest-1.7.0/scripts/fuse_gtest_files.py 2020-01-25 02:36:23.509596000 +0200
++++ misc/build/gtest-1.7.0/scripts/fuse_gtest_files.py 2020-01-25 02:50:02.624028000 +0200
+@@ -60,7 +60,10 @@
+
+ import os
+ import re
+-import sets
++try:
++ import sets
++except ImportError:
++ pass
+ import sys
+
+ # We assume that this file is in the scripts/ directory in the Google
+@@ -90,8 +93,8 @@
+ """
+
+ if not os.path.isfile(os.path.join(directory, relative_path)):
+- print 'ERROR: Cannot find %s in directory %s.' % (relative_path,
+- directory)
++ print ('ERROR: Cannot find %s in directory %s.' % (relative_path,
++ directory))
+ print ('Please either specify a valid project root directory '
+ 'or omit it on the command line.')
+ sys.exit(1)
+@@ -123,7 +126,7 @@
+ (relative_path, output_dir))
+ answer = sys.stdin.readline().strip()
+ if answer not in ['y', 'Y']:
+- print 'ABORTED.'
++ print ('ABORTED.')
+ sys.exit(1)
+
+ # Makes sure the directory holding the output file exists; creates
+@@ -146,8 +149,11 @@
+ def FuseGTestH(gtest_root, output_dir):
+ """Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
+
+- output_file = file(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
+- processed_files = sets.Set() # Holds all gtest headers we've processed.
++ output_file = open(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')
++ if sys.version_info[0] > 2:
++ processed_files = set()
++ else:
++ processed_files = sets.Set() # Holds all gtest headers we've processed.
+
+ def ProcessFile(gtest_header_path):
+ """Processes the given gtest header file."""
+@@ -159,7 +165,7 @@
+ processed_files.add(gtest_header_path)
+
+ # Reads each line in the given gtest header.
+- for line in file(os.path.join(gtest_root, gtest_header_path), 'r'):
++ for line in open(os.path.join(gtest_root, gtest_header_path), 'r'):
+ m = INCLUDE_GTEST_FILE_REGEX.match(line)
+ if m:
+ # It's '#include "gtest/..."' - let's process it recursively.
+@@ -175,7 +181,10 @@
+ def FuseGTestAllCcToFile(gtest_root, output_file):
+ """Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
+
+- processed_files = sets.Set()
++ if sys.version_info[0] > 2:
++ processed_files = set()
++ else:
++ processed_files = sets.Set()
+
+ def ProcessFile(gtest_source_file):
+ """Processes the given gtest source file."""
+@@ -187,7 +196,7 @@
+ processed_files.add(gtest_source_file)
+
+ # Reads each line in the given gtest source file.
+- for line in file(os.path.join(gtest_root, gtest_source_file), 'r'):
++ for line in open(os.path.join(gtest_root, gtest_source_file), 'r'):
+ m = INCLUDE_GTEST_FILE_REGEX.match(line)
+ if m:
+ if 'include/' + m.group(1) == GTEST_SPI_H_SEED:
+@@ -218,7 +227,7 @@
+ def FuseGTestAllCc(gtest_root, output_dir):
+ """Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
+
+- output_file = file(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
++ output_file = open(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')
+ FuseGTestAllCcToFile(gtest_root, output_file)
+ output_file.close()
+
+@@ -242,7 +251,7 @@
+ # fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
+ FuseGTest(sys.argv[1], sys.argv[2])
+ else:
+- print __doc__
++ print (__doc__)
+ sys.exit(1)
+
+
diff --git a/ext_libraries/gtest/makefile.mk b/ext_libraries/gtest/makefile.mk
index 0b811e5..4c0b1c4 100644
--- a/ext_libraries/gtest/makefile.mk
+++ b/ext_libraries/gtest/makefile.mk
@@ -46,7 +46,7 @@ TARFILE_NAME=$(PRJNAME)-$(LIBGTESTVERSION)
# thankfully, does not care.
TARFILE_MD5=2d6ec8ccdf5c46b05ba54a9fd1d130d7
-PATCH_FILES= use-own-tuple.patch
+PATCH_FILES= use-own-tuple.patch gtest-python3.patch
.IF "$(OS)"=="WNT"
[openoffice] 05/06: Detect Python's CFLAGS and LIBS using
pkg-config when possible.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 00503fad63e905b0ef1d175bb9780a358bc27263
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 25 02:11:54 2020 +0200
Detect Python's CFLAGS and LIBS using pkg-config when possible.
This fixes linking to Python on FreeBSD with Python 3.
Patch by: me
---
main/configure.ac | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/main/configure.ac b/main/configure.ac
index 4ec5594..d6e943e 100644
--- a/main/configure.ac
+++ b/main/configure.ac
@@ -4010,8 +4010,11 @@ elif test -n "$with_system_python" -o -n "$with_system_libs" && \
python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
- PYTHON_CFLAGS="-I$python_include"
- PYTHON_LIBS="-lpython$python_version"
+ PKG_CHECK_MODULES(PYTHON, python-$python_version, PYTHON_PC="TRUE", PYTHON_PC="" )
+ if test "$PYTHON_PC" != "TRUE"; then
+ PYTHON_CFLAGS="-I$python_include"
+ PYTHON_LIBS="-lpython$python_version"
+ fi
fi
if test "$with_system_python" = "yes" ; then
SYSTEM_PYTHON=YES
[openoffice] 02/06: scripting: add Python 3 support to the Python
provider
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 4f686187ecfc86b8d293f1b6c9a49fee4b0bf393
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 18 09:52:51 2020 +0200
scripting: add Python 3 support to the Python provider
Patch by: me
---
main/scripting/source/pyprov/pythonscript.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/main/scripting/source/pyprov/pythonscript.py b/main/scripting/source/pyprov/pythonscript.py
index 23e82b5..af01bb0 100644
--- a/main/scripting/source/pyprov/pythonscript.py
+++ b/main/scripting/source/pyprov/pythonscript.py
@@ -56,7 +56,10 @@ ENABLE_EDIT_DIALOG=False # offers a minimal editor for editin
#-------------------------------------------------------------------
def encfile(uni):
- return uni.encode( sys.getfilesystemencoding())
+ if sys.version_info[0] > 2:
+ return uni
+ else:
+ return uni.encode( sys.getfilesystemencoding())
def lastException2String():
(excType,excInstance,excTraceback) = sys.exc_info()
@@ -81,7 +84,7 @@ def getLogTarget():
userInstallation = pathSubst.getSubstituteVariableValue( "user" )
if len( userInstallation ) > 0:
systemPath = uno.fileUrlToSystemPath( userInstallation + "/Scripts/python/log.txt" )
- ret = file( systemPath , "a" )
+ ret = open( systemPath , "a" )
except Exception as e:
print("Exception during creation of pythonscript logfile: "+ lastException2String() + "\n, delagating log to stdout\n")
return ret
@@ -153,13 +156,16 @@ g_implName = "org.openoffice.pyuno.LanguageScriptProviderFor"+LANGUAGENAME
BLOCK_SIZE = 65536
def readTextFromStream( inputStream ):
# read the file
- code = uno.ByteSequence( "" )
+ code = uno.ByteSequence( b"" )
while True:
read,out = inputStream.readBytes( None , BLOCK_SIZE )
code = code + out
if read < BLOCK_SIZE:
break
- return code.value
+ if sys.version_info[0] > 2:
+ return str( code.value, 'utf-8' )
+ else:
+ return code.value
def toIniName( str ):
# TODO: what is the official way to get to know whether i am on the windows platform ?
[openoffice] 03/06: pyuno: wrap the right entrypoint for Python 3
in the pyuno dlopen wrapper
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 29716487c9dd2d298fa194b73f148072e7f0a3e7
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Jan 18 10:20:44 2020 +0200
pyuno: wrap the right entrypoint for Python 3 in the pyuno dlopen wrapper
Patch by: me
---
main/pyuno/Library_pyuno_loader.mk | 2 ++
main/pyuno/source/module/pyuno_dlopenwrapper.c | 39 ++++++++++++++++++++++++--
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/main/pyuno/Library_pyuno_loader.mk b/main/pyuno/Library_pyuno_loader.mk
index afbea6f..c13cee7 100644
--- a/main/pyuno/Library_pyuno_loader.mk
+++ b/main/pyuno/Library_pyuno_loader.mk
@@ -38,6 +38,8 @@ else ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_add_libs,pyuno_loader,-ldl))
endif
+$(call gb_Library_use_external,pyuno_loader,python)
+
$(eval $(call gb_Library_add_cobjects,pyuno_loader,\
pyuno/source/module/pyuno_dlopenwrapper \
))
diff --git a/main/pyuno/source/module/pyuno_dlopenwrapper.c b/main/pyuno/source/module/pyuno_dlopenwrapper.c
index beef85b..bb6614c 100644
--- a/main/pyuno/source/module/pyuno_dlopenwrapper.c
+++ b/main/pyuno/source/module/pyuno_dlopenwrapper.c
@@ -21,6 +21,22 @@
+#ifndef Py_PYTHON_H
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#ifdef _DEBUG
+#undef _DEBUG
+#include <Python.h>
+#define _DEBUG
+#else
+#include <Python.h>
+#endif // #ifdef _DEBUG
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#endif // #ifdef Py_PYTHON_H
+
#include <rtl/string.h>
#include <stdlib.h>
@@ -33,12 +49,24 @@
#endif
#include <dlfcn.h>
+#if PY_MAJOR_VERSION >= 3
+SAL_DLLPUBLIC_EXPORT void* PyInit_pyuno(void)
+#else
SAL_DLLPUBLIC_EXPORT void initpyuno ()
+#endif
{
Dl_info dl_info;
+#if PY_MAJOR_VERSION >= 3
+ void* (*func)(void);
+#else
void (*func)(void);
+#endif
+#if PY_MAJOR_VERSION >= 3
+ if (dladdr((void*)&PyInit_pyuno, &dl_info) != 0) {
+#else
if (dladdr((void*)&initpyuno, &dl_info) != 0) {
+#endif
void* h = 0;
size_t len = strrchr(dl_info.dli_fname, '/') - dl_info.dli_fname + 1;
char* libname = malloc(len + RTL_CONSTASCII_LENGTH( SAL_DLLPREFIX "pyuno" SAL_DLLEXTENSION ) + 1);
@@ -49,8 +77,15 @@ SAL_DLLPUBLIC_EXPORT void initpyuno ()
free(libname);
if( h )
{
- func = (void (*)())dlsym (h, "initpyuno");
- (func) ();
+#if PY_MAJOR_VERSION >= 3
+ func = (void* (*)(void))dlsym (h, "PyInit_pyuno");
+#else
+ func = (void (*)(void))dlsym (h, "initpyuno");
+#endif
+ return (func) ();
}
}
+#if PY_MAJOR_VERSION >= 3
+ return NULL;
+#endif
}