move all Python stuff into __init__ function to prepare for precompilation