I am trying to pack a pychess package into a zip file and import it using zipimport, but running into some problems.
I packed it into a zip file with the following script that works:
import zipfile
zf = zipfile.PyZipFile('../pychess.zip.mod', mode='w')
try:
zf.writepy('.')
finally:
zf.close()
for name in zf.namelist():
print name
However, I cannot perform complex imports in my code:
z = zipimport.zipimporter('./pychess.zip.mod')
Utils = z.load_module('Utils')
from Utils import lutils
How to import, for example. pychess.Utils.lutils.LBoard from zip file?
Here is the complete list of modules I need to import:
import pychess
from pychess.Utils.lutils import LBoard
from pychess.Utils.const import *
from pychess.Utils.lutils import lmovegen
from pychess.Utils.lutils import lmove
Thank!
source
share