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):
36
36
sys .meta_path .remove (finder )
37
37
38
38
def gen_code (jl ):
39
- jlb = base64 .b64encode (jl .encode ('utf8' )).decode ('ascii' )
40
39
buf = io .StringIO ()
41
40
pr = lambda x : print (x , file = buf )
41
+ jl2 = jl .replace ('\\ ' , '\\ \\ ' ).replace ("'" , "\\ '" )
42
42
pr ('# This file was automatically generated by juliacall.importer' )
43
43
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 + "''')" )
48
46
return buf .getvalue ()
49
47
50
48
def gen_file (jl , py ):
51
- with open (jl ) as fp :
49
+ with open (jl , encoding = 'utf-8' ) as fp :
52
50
jlcode = fp .read ()
53
51
pycode = gen_code (jlcode )
54
- with open (py , 'w' ) as fp :
52
+ with open (py , 'w' , encoding = 'utf-8' ) as fp :
55
53
fp .write (pycode )
56
54
57
55
def exec_module (name , code ):
58
56
pymod = sys .modules [name ]
59
- code = base64 .b64decode (code .encode ('ascii' )).decode ('utf8' )
60
57
jlmod = newmodule (name )
61
58
jlmod .seval ('begin\n ' + code + '\n end' )
62
59
delattr (pymod , 'juliacall' )
You can’t perform that action at this time.
0 commit comments