You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular he suggests that each pyjulia ought to make a separate Pkg.clone of PyCall, and Pkg.build it specializing to the instance of Python that is being used.
This should probably be done in conjunction with an PR to PyCall, so that if you set some environment variable during the Pkg.build phase then it looks up CPython symbols in the global namespace (for cases where libpython is statically linked into python). In this case, I'm hoping you can just use ccall(:Py_SomeSymbol, ...), which should be a trivial change to the @pysym macro in PyCall.
I would also suggest cloning into a "private" directory for pyjulia, and push!(mydirectory, LOAD_PATH) so that Julia can find it. You can also push a private directory to Base.LOAD_CACHE_PATH so that the PyCall.ji cache file will be stored there. In particular, do something like:
using Compat
push!(mydirectory, LOAD_PATH)
push!(mydirectory, Base.LOAD_CACHE_PATH)
using PyCall
pop!(LOAD_PATH)
pop!(Base.LOAD_CACHE_PATH)
when you are initializing pyjulia. (Do using Compat first so that if it has been updated and needs to be recompiled, it's cache file will go into the standard Julia cache path rather than into your private cache path.)
The real problem here is that is python the precompile environment needs to look the same as the runtime environment. In particular that means that in the general case python needs to be in charge of the precompile environment as well. Talking with @vtjnash, we could create a python script that takes the appropriate arguments and pretends to be julia closely enough for julia to use it for precompilation.
@Keno, I'm not sure I follow you. As long as we build with the right version of Julia, and use the pyjulia Pkg.build("PyCall") output, I don't see why precompilation within julia shouldn't work.
Oh, no, I see — the problem is that precompilation needs to run PyCall's __init__, and this will fail unless we are running inside Python.
Ok, unfortunately this approach does not work on windows. Luckily, the Python FAQ states that On Windows, Python must be a DLL to handle importing modules that are themselves DLL’s. (This is the first key undocumented fact.) [1], so I think we can safely ignore that case.
Bad news on linux as well. Doing this corrupts the c runtime library state :(. I'll see if we can move the argument parsing into libjulia instead. That'll make this an 0.5 only thing but that may not be so bad.
Activity
stevengj commentedon Feb 12, 2016
This should probably be done in conjunction with an PR to PyCall, so that if you set some environment variable during the
Pkg.buildphase then it looks up CPython symbols in the global namespace (for cases wherelibpythonis statically linked intopython). In this case, I'm hoping you can just useccall(:Py_SomeSymbol, ...), which should be a trivial change to the@pysymmacro in PyCall.stevengj commentedon Feb 12, 2016
I would also suggest cloning into a "private" directory for
pyjulia, andpush!(mydirectory, LOAD_PATH)so that Julia can find it. You can also push a private directory toBase.LOAD_CACHE_PATHso that thePyCall.jicache file will be stored there. In particular, do something like:when you are initializing
pyjulia. (Dousing Compatfirst so that if it has been updated and needs to be recompiled, it's cache file will go into the standard Julia cache path rather than into your private cache path.)Keno commentedon Jul 6, 2016
The real problem here is that is python the precompile environment needs to look the same as the runtime environment. In particular that means that in the general case python needs to be in charge of the precompile environment as well. Talking with @vtjnash, we could create a python script that takes the appropriate arguments and pretends to be julia closely enough for julia to use it for precompilation.
stevengj commentedon Jul 6, 2016
@Keno, I'm not sure I follow you. As long as we build with the right version of Julia, and use the pyjuliaPkg.build("PyCall")output, I don't see why precompilation withinjuliashouldn't work.Oh, no, I see — the problem is that precompilation needs to run PyCall's
__init__, and this will fail unless we are running inside Python.Keno commentedon Jul 6, 2016
Because that will try to load the symbols from the executable environment, which won't be there in the precompile process.
Keno commentedon Jul 6, 2016
@vtjnash and I came up with something that I think is actually quite clever:
Seems to work ok. Will have to try across operating systems and fully end-to-end.
Keno commentedon Jul 7, 2016
Ok, unfortunately this approach does not work on windows. Luckily, the Python FAQ states that
On Windows, Python must be a DLL to handle importing modules that are themselves DLL’s. (This is the first key undocumented fact.)[1], so I think we can safely ignore that case.[1] https://docs.python.org/2/faq/windows.html#how-can-i-embed-python-into-a-windows-application
Keno commentedon Jul 7, 2016
Bad news on linux as well. Doing this corrupts the c runtime library state :(. I'll see if we can move the argument parsing into libjulia instead. That'll make this an 0.5 only thing but that may not be so bad.
Keno commentedon Jul 18, 2016
Fixed by #54.