File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -36,27 +36,24 @@ def uninstall(finder):
3636 sys .meta_path .remove (finder )
3737
3838def gen_code (jl ):
39- jlb = base64 .b64encode (jl .encode ('utf8' )).decode ('ascii' )
4039 buf = io .StringIO ()
4140 pr = lambda x : print (x , file = buf )
41+ jl2 = jl .replace ('\\ ' , '\\ \\ ' ).replace ("'" , "\\ '" )
4242 pr ('# This file was automatically generated by juliacall.importer' )
4343 pr ('import juliacall.importer' )
44- pr ('juliacall.importer.exec_module(__name__, """' )
45- for i in range (0 , len (jlb ), 80 ):
46- pr (jlb [i :i + 80 ])
47- pr ('""")' )
44+ pr ('juliacall.importer.exec_module(__name__,' )
45+ pr ("'''" + jl2 + "''')" )
4846 return buf .getvalue ()
4947
5048def gen_file (jl , py ):
51- with open (jl ) as fp :
49+ with open (jl , encoding = 'utf-8' ) as fp :
5250 jlcode = fp .read ()
5351 pycode = gen_code (jlcode )
54- with open (py , 'w' ) as fp :
52+ with open (py , 'w' , encoding = 'utf-8' ) as fp :
5553 fp .write (pycode )
5654
5755def exec_module (name , code ):
5856 pymod = sys .modules [name ]
59- code = base64 .b64decode (code .encode ('ascii' )).decode ('utf8' )
6057 jlmod = newmodule (name )
6158 jlmod .seval ('begin\n ' + code + '\n end' )
6259 delattr (pymod , 'juliacall' )
You can’t perform that action at this time.
0 commit comments