@stlite/desktop 0.15.0 → 0.16.0

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.
@@ -92,8 +92,23 @@ 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
+ async function readRequirements(requirementsTxtPath) {
96
+ try {
97
+ const requirementsTxtData = await promises_1.default.readFile(requirementsTxtPath, {
98
+ encoding: "utf-8",
99
+ });
100
+ return requirementsTxtData
101
+ .split("\n")
102
+ .map((r) => r.trim())
103
+ .filter((r) => r !== "");
104
+ }
105
+ catch {
106
+ console.log(`Failed to read ${requirementsTxtPath}. Use [] as the requirements.`);
107
+ return [];
108
+ }
109
+ }
95
110
  (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) => {
111
+ .command("* <appHomeDirSource> [packages..]", "Put the user code and data and the snapshot of the required packages into the build artifact.", () => { }, (argv) => {
97
112
  console.info(argv);
98
113
  })
99
114
  .positional("appHomeDirSource", {
@@ -101,7 +116,13 @@ async function copyStreamlitAppDirectory(options) {
101
116
  type: "string",
102
117
  demandOption: true,
103
118
  })
104
- .options("requirements", {
119
+ .positional("packages", {
120
+ describe: "Package names to install.",
121
+ type: "string",
122
+ array: true,
123
+ })
124
+ .options("requirement", {
125
+ describe: "Install from the given requirements file. This option can be used multiple times.",
105
126
  array: true,
106
127
  type: "string",
107
128
  alias: "r",
@@ -128,10 +149,14 @@ async function copyStreamlitAppDirectory(options) {
128
149
  catch {
129
150
  throw new Error(`${args.appHomeDirSource} does not exist.`);
130
151
  }
152
+ let requirements = args.packages;
153
+ for (const requirementTxtFilePath of args.requirement) {
154
+ requirements = requirements.concat(await readRequirements(requirementTxtFilePath));
155
+ }
131
156
  await copyBuildDirectory({ copyTo: destDir, override: args.force });
132
157
  await createSitePackagesSnapshot({
133
158
  useLocalKernelWheels: args.localKernelWheels,
134
- requirements: args.requirements,
159
+ requirements: requirements,
135
160
  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
161
  });
137
162
  await copyStreamlitAppDirectory({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stlite/desktop",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
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.15.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",