Inline-Python icon indicating copy to clipboard operation
Inline-Python copied to clipboard

Error while compiling "Could not find python"

Open ggoebel opened this issue 4 years ago • 4 comments

The Problem

Foo.rakumod:

use Bar;
use Baz;

Bar.rakumod

use Inline::Python;

Baz.rakumod

use Inline::Python;

and doing:

raku -I. -MFoo -e ''

results in

===SORRY!=== Error while compiling -e
===SORRY!=== Error while compiling /home/ggoebel/git/test/Foo.rakumod (Foo)
===SORRY!=== Error while compiling /home/ggoebel/git/test/Baz.rakumod (Baz)
Could not find python in:
    file#/home/ggoebel/git/test
    inst#/home/ggoebel/.raku
    inst#/home/ggoebel/raku/share/perl6/site
    inst#/home/ggoebel/raku/share/perl6/vendor
    inst#/home/ggoebel/raku/share/perl6/core
    ap#
    nqp#
    perl5#
at /home/ggoebel/git/test/Baz.rakumod (Baz):1

at /home/ggoebel/git/test/Foo.rakumod (Foo):2

at -e:1

Note: based on the number of files in the .precomp directory, precomp for Bar.rakumod appears to be successful. It is only the second "use Inline::Python" that results in an error. If after getting the error, I change the order of the use statements, then the code will compile (and precompile) without error.

ggoebel avatar Oct 13 '21 00:10 ggoebel

Does adding a no precompilation; to those modules help?

niner avatar Oct 13 '21 06:10 niner

yes. will use that as a workaround. thank you.

ggoebel avatar Oct 13 '21 07:10 ggoebel

I'm not sure this is a practical work around. As it appears any module which uses a module with a dependency on Inline::Python also needs no precompilation. Which in the code I'm working in means waiting several minutes vs. several seconds

ggoebel avatar Oct 13 '21 07:10 ggoebel

If module A prohibits precompilation and module B uses module A, then module B will not be precompiled either (as it cannot be). If you need to add a no precompilation to module B, then something is seriously fishy.

As it is, Inline::Python does try to prohibit precompilation by doing a $*W.do_pragma(Any, 'precompilation', False, []); in the EXPORT sub. For some reason that doesn't seem to work though.

Inline::Python cannot work in precompiled modules right now. The Python runtime it loads represents external state. When precompiling, we'd have to preserve this external state somehow (i.e. the loaded runtime, all loaded modules and the effects of code executed during the build). This requires some serious trickery. Inline::Perl5 gained such support in 2019, but it hasn't been brought to Inline::Python yet:

https://github.com/niner/Inline-Perl5/commit/6958d4aa19f82d33de707bdcad87cdfd819527c8 https://github.com/niner/Inline-Perl5/commit/6e0cf93557ec1bdcc92f5dfafd379da96eb70baa https://github.com/niner/Inline-Perl5/commit/6b7697b4f2cdd1047c327e475c424ef961395e0d https://github.com/niner/Inline-Perl5/commit/42bac8511ae6c6830df12cdd161b905410454e7f https://github.com/niner/Inline-Perl5/commit/f72f46196962bd675fb295658c072e121c8c2aa0

Well, at least the rakudo bugs referred to in that last commit are no longer an issue. That will make doing something similar in Inline::Python much easier.

niner avatar Oct 13 '21 07:10 niner