Skip to content

Commit 98facf8

Browse files
committed
fix imports
1 parent b49c434 commit 98facf8

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

pyprez.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/*Sun Nov 06 2022 15:37:14 GMT -0800 (Pacific Standard Time)*/
1+
/*Sun Nov 06 2022 15:53:57 GMT -0800 (Pacific Standard Time)*/
22

33
if (!window.pyprezUpdateDate){
44
/* github pages can only serve one branch and takes a few minutes to update, this will help identify which version
55
of code we are on */
6-
var pyprezUpdateDate = new Date("Sun Nov 06 2022 15:37:14 GMT -0800 (Pacific Standard Time)");
7-
var pyprezCommitMessage = "disable linting default";
8-
var pyprezPrevCommit = "development:commit 00821134b665ac2a1b3c9de7d9ae3c08a6e9f8fe";
6+
var pyprezUpdateDate = new Date("Sun Nov 06 2022 15:53:57 GMT -0800 (Pacific Standard Time)");
7+
var pyprezCommitMessage = "fix imports";
8+
var pyprezPrevCommit = "development:commit b49c434f40e62e250ff08c4266e3fb9778947c0d";
99
}
1010

1111
/*
@@ -45,7 +45,7 @@ if (!window.pyprezInitStarted){// allow importing this script multiple times wit
4545
showThemeSelect: true,
4646
showNamespaceSelect: false,
4747
patch: true,
48-
lint: false
48+
lint: true
4949
}
5050
let strConfig = {
5151
patchSrc: "https://modularizer.github.io/pyprez/patches.py",
@@ -609,25 +609,30 @@ if (!window.pyprezInitStarted){// allow importing this script multiple times wit
609609
console.debug("auto loading packages detected in code")
610610
return this.installPackagesFromComments(code).then(()=>{
611611
console.warn("installed it here")
612-
return window.pyodide.loadPackage(requirements)
612+
return window.pyodide.loadPackagesFromImports(code)
613613
})
614614
}
615615
}else{
616616
console.debug("loading", requirements)
617617
return this.installPackagesFromComments(code).then(()=>{
618618
console.warn("installed it here2")
619-
return window.pyodide.loadPackage(requirements)
619+
return window.pyodide.loadPackagesFromImports(code)
620620
})
621621
}
622622

623623
})
624624
}
625625
installPackagesFromComments(code){
626-
let m = code.match(/#\s*(micro)?pip\s*install\s*(\S*)/g);
627-
console.warn(m);
628-
let packageNames = m?m.map(s => s.match(/#\s*(micro)?pip\s*install\s*(\S*)/)[2]):[];
629-
console.warn("preparing to micropip install", packageNames)
630-
return micropipPromise.then(()=>{console.warn('installing');return micropip.install(packageNames)})
626+
// let m = code.match(/#\s*(micro)?pip\s*install\s*(\S*)/g);
627+
// console.warn(m);
628+
// let packageNames = m?m.map(s => s.match(/#\s*(micro)?pip\s*install\s*(\S*)/)[2]):[];
629+
// if (packageNames.length){
630+
// console.warn("preparing to micropip install", packageNames)
631+
// return micropipPromise.then(()=>{console.warn('installing');return micropip.install(packageNames)})
632+
// }else{
633+
return new Promise((res, rej)=>{res(true)})
634+
// }
635+
631636
}
632637
loadAndRunAsync(code, namespace="global", requirements="detect"){
633638
/* run a python script asynchronously as soon as pyodide is loaded and all required packages are imported*/
@@ -769,7 +774,7 @@ if (!window.pyprezInitStarted){// allow importing this script multiple times wit
769774
}
770775

771776
// now load packages detected in code imports
772-
pyprez.installPackagesFromComments(this.code);
777+
// pyprez.installPackagesFromComments(this.code);
773778
}
774779
loadEditor(){
775780
/* first load the editor as though codemirror does not and will not exist, then load codemirror*/

0 commit comments

Comments
 (0)