Python Interace¶
In order to build the python interface, you nee to check out the repository
python/source
in particular, the python package lives in
python/source/kepler
Currently, this has been tested with Python 3.8.1 and gcc
9.2.1 on Fedora Linux 29 and requires current NumPy
1.17.4 and matplotlib 3.1.2 or better. (NumPy
has been fixed to compile KEPLER after Version 1.11.) Ideally, when
you import the package, all dependencies should be compiled
automatically, however, you need to make sure you us the same
directory paths. (…)
Kepler can now be run as a Python module and development is on the way to improve the interface and implement all plot types from Mongo.
Installing the Python Module¶
This has only been tested for Fedora Linux 22+ so far. First, you
need to get a current version of Python, most easy to install
locally. As of the time of this writing, this is Version 3.8.1.
Earlier versions may not support all the features used by the current
python code, may have bugs, and hence may not work; there is no
support for out-of-date Python or Python packages.
First start to make a non-optimised compile to check whether you have all pre-requisites (libraries, header files) installed on your system:
# using bash
export py=3.8.1
wget https://www.python.org/ftp/python/${py}/Python-${py}.tar.xz
cd
tar -xvJf Python-${py}.tar.xz
cd Python-${py}
./configure --prefix=$HOME/Python
make -j
Note
the make -j command may giv you some message of components
in python it did not build because of missing dependencies. You
should try to find them all to build a complete python install,
otherwise some key components may not be build. Specifically,
pip3 has happened to be missing in some of the
installations I attempted.
Find and install missing dependencies, re-compile until all works.
When this is accomplished, compile and install the full version
make clean
./configure --prefix=$HOME/Python --enable-optimizations --enable-shared
make install
Then, I change my ~/.bashrc to file to include
export PYTHON=${HOME}/Python
export PATH=$PYTHON/bin:$PATH
export MANPATH=$PYTHON/man:$MANPATH
export PYTHONPATH=${PYTHONPATH}:${PYTHON}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${PYTHON}/lib
and open a new bash shell. Now, you want to install a phledora of python packages,
pip3 install -U --force-reinstall numpy scipy ipython[notebook] psutil pyyaml six matplotlib py-cpuinfo
You will need to install numpy 1.14 or higher (1.14.5
as of this writing), which you may have to check out from the
development page and compile/install your self. (Numpy developers
kindly included a bug fix to f2py to make KEPLER work.)
By default, it appears that some versions of numpy do not create a
link for f2py3 by defaul, so we need to make this by hand:
cd
cd Python/bin
ln -s f2py3.? f2py3
If you now create a kepler.code.Kepler object, in an ideal
world, this should compile the necessary binary libraries all from
scratch.
Note
Please let me know of any problems, their solutions, and possible updates for this documentation
Updating your Python Install¶
A useful scrtip that I run every now and then to update python is
#!/usr/bin/bash
pip3 install --upgrade pip
pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip3 install -U
pip3 check
You should coupy this into a file, e.g., update_python and
make executable.
Python Tools and Documentation¶
These have been put into a separate documentation packages as this KEPLER doc with all its cross-links is getting too bulky and slow to compile. You may find it at