Hi everyone, I managed to finalize support for Python 3 (standing on the shoulder of giants here) and I could use some help with testing the changes.
The Work-In-Progress code can be found here: https://github.com/afh/ledger/tree/wip/python3 Currently there are 5 unit tests failing: BaselineTest_dir-import_py (Failed) BaselineTest_dir-python_py (Failed) BaselineTest_feat-import_py (Failed) BaselineTest_feat-option_py (Failed) BaselineTest_feat-value_py (Failed) One major change is replacing the ledger module (ledger.so) with a ledger package¹ (see below), which includes aforementioned ledger module yet allows extending ledger through python more easily. Another major change is the clean-up of the CMake infrastructure (>= 2.8.8 is required now), to improve the maintainability. To build ledger with python3 support² run: % mkdir build_py3 % (cd build_py3; \ cmake \ -DBUILD_DEBUG=ON \ -DBUILD_DOCS=ON \ -DBUILD_WEB_DOCS=ON \ -DUSE_PYTHON=ON \ -DPython_ADDITIONAL_VERSIONS=3.5 \ -DPYTHON_INCLUDE_DIR=$PATH_TO_PYTHON_INCLUDE_DIR \ ) % make -Cbuild_py3 % make -Cbuild_py3 doc % make -Cbuild_py3 install Should this fail due to required software not being found add the following options to the cmake command and replace the $PATH_TO_... variable with the absolute path to the directory where the required software can be found on your system: -DGmp_ROOT_DIR=$PATH_TO_GMP_ROOT -DMpfr_ROOT_DIR=$PATH_TO_MPFR_ROOT -DIcu_ROOT_DIR=$PATH_TO_ICU_ROOT -DLibintl_ROOT_DIR=$PATH_TO_GETTEXT_ROOT -DBOOST_ROOT=$PATH_TO_BOOST_ROOT To test please run the unit tests: % (cd build_py3; ctest --output-on-failure) and the (inofficial) python test suite: % ./build_py3/ledger python python/demo.py % PYTHONPATH=$PATH_TO_PYTHON_SITE_PACKAGES python3 python/demo.py In addition to that I'm keen on seeing any other ledger python related code that you use for testing or yourself and are willing to share. I would also like to open a dialog about how to best handle the ledger python API. Currently `>>> import ledger` loads the ledger module (ledger.so) into python. When using packages it makes sense to put the ledger module in ledger.core (or something similar), which breaks compatibility with existing scripts. I've written the __init__.py files in a way that `import ledger` works in both scenarios (using ledger python and python3 directly), but from a python API standpoint a different approach might make more sense: Keep the python namespace clean by requiring users to think about which aspects from the ledger python API they want, e.g. import python vs from ledger.core import * When invoking `% ledger python` only the core ledger module is available not the extensions that the package may provide in the future (unless PYTHONPATH is set accordingly). This is because when using `% ledger python` the ledger command registers ledger as a built-in python module (provided by its own binary) with the python runtime. Without PYTHONPATH set accordingly only the core ledger module is known to python, with PYTHONPATH set the python runtime can find and load the ledger package just fine. I hope you can still follow my train of thought ;) and I look forward to your feedback! Happy testing, Alexis ¹ https://docs.python.org/2/tutorial/modules.html#packages ² You have to choose between Python 2 or Python 3 when configuring your build. -- --- You received this message because you are subscribed to the Google Groups "Ledger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
