@stlite/desktop 0.15.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dump_artifacts.js +49 -3
- package/package.json +2 -2
package/bin/dump_artifacts.js
CHANGED
|
@@ -92,8 +92,43 @@ async function copyStreamlitAppDirectory(options) {
|
|
|
92
92
|
console.log(`Copy ${options.sourceDir} to ${options.copyTo}`);
|
|
93
93
|
return fs_extra_1.default.copy(options.sourceDir, options.copyTo);
|
|
94
94
|
}
|
|
95
|
+
// Original: packages/sharing-editor/bin/gen-sample-app-manifests-json.ts
|
|
96
|
+
// TODO: Be DRY
|
|
97
|
+
async function readRequirements(requirementsTxtPath) {
|
|
98
|
+
try {
|
|
99
|
+
const requirementsTxtData = await promises_1.default.readFile(requirementsTxtPath, {
|
|
100
|
+
encoding: "utf-8",
|
|
101
|
+
});
|
|
102
|
+
return requirementsTxtData
|
|
103
|
+
.split("\n")
|
|
104
|
+
.map((r) => r.trim())
|
|
105
|
+
.filter((r) => r !== "");
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
console.log(`Failed to read ${requirementsTxtPath}. Use [] as the requirements.`);
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Original: kernel/src/requirements.ts
|
|
113
|
+
// TODO: Be DRY
|
|
114
|
+
function verifyRequirements(requirements) {
|
|
115
|
+
requirements.forEach((req) => {
|
|
116
|
+
let url;
|
|
117
|
+
try {
|
|
118
|
+
url = new URL(req);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// `req` is not a URL -> OK
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// Ref: The scheme checker in the micropip implementation is https://github.com/pyodide/micropip/blob/v0.1.0/micropip/_compat_in_pyodide.py#L23-L26
|
|
125
|
+
if (url.protocol === "emfs:" || url.protocol === "file:") {
|
|
126
|
+
throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${req})`);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
95
130
|
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
96
|
-
.command("* <appHomeDirSource>", "Put the user code and data and the snapshot of the required packages into the build artifact.", () => { }, (argv) => {
|
|
131
|
+
.command("* <appHomeDirSource> [packages..]", "Put the user code and data and the snapshot of the required packages into the build artifact.", () => { }, (argv) => {
|
|
97
132
|
console.info(argv);
|
|
98
133
|
})
|
|
99
134
|
.positional("appHomeDirSource", {
|
|
@@ -101,7 +136,13 @@ async function copyStreamlitAppDirectory(options) {
|
|
|
101
136
|
type: "string",
|
|
102
137
|
demandOption: true,
|
|
103
138
|
})
|
|
104
|
-
.
|
|
139
|
+
.positional("packages", {
|
|
140
|
+
describe: "Package names to install.",
|
|
141
|
+
type: "string",
|
|
142
|
+
array: true,
|
|
143
|
+
})
|
|
144
|
+
.options("requirement", {
|
|
145
|
+
describe: "Install from the given requirements file. This option can be used multiple times.",
|
|
105
146
|
array: true,
|
|
106
147
|
type: "string",
|
|
107
148
|
alias: "r",
|
|
@@ -128,10 +169,15 @@ async function copyStreamlitAppDirectory(options) {
|
|
|
128
169
|
catch {
|
|
129
170
|
throw new Error(`${args.appHomeDirSource} does not exist.`);
|
|
130
171
|
}
|
|
172
|
+
let requirements = args.packages;
|
|
173
|
+
for (const requirementTxtFilePath of args.requirement) {
|
|
174
|
+
requirements = requirements.concat(await readRequirements(requirementTxtFilePath));
|
|
175
|
+
}
|
|
176
|
+
verifyRequirements(requirements);
|
|
131
177
|
await copyBuildDirectory({ copyTo: destDir, override: args.force });
|
|
132
178
|
await createSitePackagesSnapshot({
|
|
133
179
|
useLocalKernelWheels: args.localKernelWheels,
|
|
134
|
-
requirements:
|
|
180
|
+
requirements: requirements,
|
|
135
181
|
saveTo: path_1.default.resolve(destDir, "./site-packages-snapshot.tar.gz"), // This path will be loaded in the `readSitePackagesSnapshot` handler in electron/main.ts.
|
|
136
182
|
});
|
|
137
183
|
await copyStreamlitAppDirectory({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stlite/desktop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "./",
|
|
6
6
|
"main": "./build/electron/main.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@craco/craco": "^6.1.2",
|
|
52
|
-
"@stlite/kernel": "^0.
|
|
52
|
+
"@stlite/kernel": "^0.16.0",
|
|
53
53
|
"@testing-library/react": "^11.2.7",
|
|
54
54
|
"@testing-library/user-event": "^13.1.9",
|
|
55
55
|
"@types/jest": "^26.0.19",
|