File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -583,3 +583,48 @@ multi sub EVAL(
583
583
CATCH { note $ _ }
584
584
$ py . run ($ code , | ($ mode eq ' eval' ?? : eval !! : file));
585
585
}
586
+
587
+ CompUnit::RepositoryRegistry. use-repository(
588
+ class :: does CompUnit::Repository {
589
+ method need (
590
+ CompUnit::DependencySpecification $ spec ,
591
+ CompUnit::PrecompilationRepository $ precomp ? ,
592
+ )
593
+ returns CompUnit: D
594
+ {
595
+ if $ spec . from eq ' Python' {
596
+ my $ python = Inline::Python. default_python;
597
+
598
+ if $ * RAKUDO_MODULE_DEBUG -> $ RMD {
599
+ $ RMD (" Loading { $ spec . short-name} via Inline::Python" );
600
+ }
601
+ my $ handle := $ python . import(
602
+ $ spec . short-name,
603
+ );
604
+ return CompUnit. new (
605
+ : short-name($ spec . short-name),
606
+ : handle(CompUnit::Handle. from-unit(Stash . new )),
607
+ : repo(self ),
608
+ : repo-id($ spec . short-name),
609
+ : from($ spec . from ),
610
+ );
611
+ }
612
+
613
+ return self . next-repo. need ($ spec , | ($ precomp ?? $ precomp !! ())) if self . next-repo;
614
+ X::CompUnit::UnsatisfiedDependency . new (: specification($ spec )). throw ;
615
+ }
616
+
617
+ method loaded () {
618
+ []
619
+ }
620
+
621
+ method id () {
622
+ ' Python'
623
+ }
624
+
625
+ method path-spec () {
626
+ ' python#'
627
+ }
628
+ }. new (),
629
+ : current($ * REPO ),
630
+ )
Original file line number Diff line number Diff line change
1
+ # !/usr/bin/env perl6
2
+
3
+ use v6 ;
4
+ use Inline::Python;
5
+ use Test ;
6
+
7
+ use string: from<Python >;
8
+
9
+ my $ py = Inline::Python. default_python;
10
+ is ($ py . call(' string' , ' capwords' , ' foo bar' ), ' Foo Bar' );
11
+
12
+ done-testing ;
You can’t perform that action at this time.
0 commit comments