Re: [PATCH] Switch to python 3

2018-03-16 Thread Sébastien de Menten
Definitely, I would go for supporting python 3 only. People wanting to use
python 2.7 may stay as well with the current 2.6 version or gnucash.

On Mar 16, 2018 15:35, "Alen Siljak" <alen.sil...@gmx.com> wrote:

> Thanks for the consideration, John. I'm happy to push for adoption of
> Python 3 and use that exclusively (as I'm fresh in the Python world).
> Sebastien might still be supporting v2 in some projects so let's see what
> he has to add.
>
> > Sent: Friday, March 16, 2018 at 3:26 PM
> > From: "John Ralls" <jra...@ceridwen.us>
> > To: "Julian Wollrath" <jwollr...@web.de>
> > Cc: gnucash-devel@gnucash.org
> > Subject: Re: [PATCH] Switch to python 3
> >
> > For further discussion here, though, particularly for Sébastien de
> Menten and Alen Siljak: Is it OK to convert to Python-3 only or should the
> bindings support both Python-2.7 and Python-3
> ___
> gnucash-devel mailing list
> gnucash-devel@gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [PATCH] Switch to python 3

2018-03-16 Thread Alen Siljak
Thanks for the consideration, John. I'm happy to push for adoption of Python 3 
and use that exclusively (as I'm fresh in the Python world). 
Sebastien might still be supporting v2 in some projects so let's see what he 
has to add.

> Sent: Friday, March 16, 2018 at 3:26 PM
> From: "John Ralls" <jra...@ceridwen.us>
> To: "Julian Wollrath" <jwollr...@web.de>
> Cc: gnucash-devel@gnucash.org
> Subject: Re: [PATCH] Switch to python 3
>
> For further discussion here, though, particularly for Sébastien de Menten and 
> Alen Siljak: Is it OK to convert to Python-3 only or should the bindings 
> support both Python-2.7 and Python-3
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [PATCH] Switch to python 3

2018-03-16 Thread John Ralls
Sorry, we don’t accept patches on the mailing lists. Please either create a 
pull request on Github or attach it to 
https://bugzilla.gnome.org/show_bug.cgi?id=791831 
. In the latter case patches 
should be made with git format-patch. In either case please make the commit 
summary "Bug 791831 - Add python3 support”, leave a blank line, and then your 
discussion about what the commit does.

For further discussion here, though, particularly for Sébastien de Menten and 
Alen Siljak: Is it OK to convert to Python-3 only or should the bindings 
support both Python-2.7 and Python-3

Regards,
John Ralls

> On Mar 16, 2018, at 12:49 AM, Julian Wollrath  wrote:
> 
> 
> This switches swig to use python 3 specific features, switches the build
> over to python 3 and adapts the tests accordingly.
> ---
> CMakeLists.txt   |  6 +--
> bindings/python/__init__.py  |  2 +-
> bindings/python/function_class.py| 34 ++--
> bindings/python/gnucash_business.py  | 28 +-
> bindings/python/gnucash_core.py  | 78 +---
> bindings/python/tests/runTests.py.in |  7 +--
> bindings/python/tests/test_account.py|  4 +-
> bindings/python/tests/test_numeric.py|  6 ---
> bindings/python/tests/test_split.py  |  6 +--
> bindings/python/tests/test_transaction.py| 40 +++---
> common/cmake_modules/GncAddSwigCommand.cmake |  2 +-
> gnucash/python/gncmod-python.c   |  4 ++
> 12 files changed, 103 insertions(+), 114 deletions(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 370a6d15f..c85bcf23c 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -459,7 +459,7 @@ ENDIF (WITH_SQL)
> # 
> 
> IF (WITH_PYTHON)
> -  FIND_PACKAGE(PythonInterp)
> +  FIND_PACKAGE(PythonInterp 3)
>   IF (NOT PYTHONINTERP_FOUND)
> MESSAGE(SEND_ERROR "Python support enabled, but Python interpreter not 
> found.")
>   ENDIF()
> @@ -468,14 +468,14 @@ IF (WITH_PYTHON)
> MESSAGE(SEND_ERROR "Found python version ${PYTHON_VERSION_STRING}, but 
> it's too old. Need python >= 2.4.0")
>   ENDIF()
> 
> -  FIND_PACKAGE(PythonLibs)
> +  FIND_PACKAGE(PythonLibs 3)
>   IF (NOT PYTHONLIBS_FOUND)
> MESSAGE(SEND_ERROR "Python support enabled, but Python libraries not 
> found.")
>   ENDIF()
> 
>   # Determine where to install the python libraries.
>   EXECUTE_PROCESS(
> -COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print 
> sysconfig.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}', 
> plat_specific=True)"
> +COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; 
> print(sysconfig.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}', 
> plat_specific=True))"
> RESULT_VARIABLE PYTHON_SYSCONFIG_RESULT
> OUTPUT_VARIABLE PYTHON_SYSCONFIG_OUTPUT
> ERROR_VARIABLE PYTHON_SYSCONFIG_ERROR
> diff --git a/bindings/python/__init__.py b/bindings/python/__init__.py
> index 3627eac47..1c874734e 100644
> --- a/bindings/python/__init__.py
> +++ b/bindings/python/__init__.py
> @@ -3,7 +3,7 @@
> # >>> from gnucash import thingy
> # instead of
> # >>> from gnucash.gnucash_core import thingy
> -from gnucash_core import *
> +from gnucash.gnucash_core import *
> ##  @file
> #   @brief helper file for the importing of gnucash
> #   @author Mark Jenkins, ParIT Worker Co-operative 
> diff --git a/bindings/python/function_class.py 
> b/bindings/python/function_class.py
> index f628667a4..db159ff83 100644
> --- a/bindings/python/function_class.py
> +++ b/bindings/python/function_class.py
> @@ -1,5 +1,5 @@
> # function_class.py -- Library for making python classes from a set
> -#  of functions. 
> +#  of functions.
> #
> # Copyright (C) 2008 ParIT Worker Co-operative 
> # This program is free software; you can redistribute it and/or
> @@ -53,7 +53,7 @@ class ClassFromFunctions(object):
> # already exist with the same __instance value, or equivalent 
> __instance
> # values, where this is desirable...
> return super(ClassFromFunctions, cls).__new__(cls)
> -
> +
> def __init__(self, *args, **kargs):
> """Construct a new instance, using either the function
> self._module[self._new_instance] or using existing instance
> @@ -89,7 +89,7 @@ class ClassFromFunctions(object):
> return getattr(self._module, function_name)(
> self.instance,
> *process_list_convert_to_instance(meth_func_args) )
> -
> +
> setattr(cls, method_name, method_function)
> setattr(method_function, "__name__", method_name)
> return method_function
> @@ -97,41 +97,41 @@ class ClassFromFunctions(object):
> @classmethod
> def ya_add_classmethod(cls, function_name, method_name):
>