onnxruntime-node 1.22.0-dev.20250418-c19a49615b → 1.22.0-rev

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/script/install.js CHANGED
@@ -1,134 +1,134 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
-
4
- 'use strict';
5
-
6
- // This script is written in JavaScript. This is because it is used in "install" script in package.json, which is called
7
- // when the package is installed either as a dependency or from "npm ci"/"npm install" without parameters. TypeScript is
8
- // not always available.
9
-
10
- // The purpose of this script is to download the required binaries for the platform and architecture.
11
- // Currently, most of the binaries are already bundled in the package, except for the files that described in the file
12
- // install-metadata.js.
13
- //
14
- // Some files (eg. the CUDA EP binaries) are not bundled because they are too large to be allowed in the npm registry.
15
- // Instead, they are downloaded from the Nuget feed. The script will download the binaries if they are not already
16
- // present in the NPM package.
17
-
18
- // Step.1: Check if we should exit early
19
- const os = require('os');
20
- const path = require('path');
21
- const { bootstrap: globalAgentBootstrap } = require('global-agent');
22
- const { installPackages, parseInstallFlag } = require('./install-utils.js');
23
-
24
- const INSTALL_METADATA = require('./install-metadata.js');
25
-
26
- // Bootstrap global-agent to honor the proxy settings in
27
- // environment variables, e.g. GLOBAL_AGENT_HTTPS_PROXY.
28
- // See https://github.com/gajus/global-agent/blob/v3.0.0/README.md#environment-variables for details.
29
- globalAgentBootstrap();
30
-
31
- // commandline flag:
32
- //
33
- // --onnxruntime-node-install Force install the files that are not bundled in the package.
34
- //
35
- // --onnxruntime-node-install=skip Skip the installation of the files that are not bundled in the package.
36
- //
37
- // --onnxruntime-node-install=cuda12 Force install the CUDA EP binaries for CUDA 12.
38
- //
39
- // --onnxruntime-node-install-cuda Force install the CUDA EP binaries.
40
- // (deprecated, use --onnxruntime-node-install=cuda12)
41
- //
42
- // --onnxruntime-node-install-cuda=skip Skip the installation of the CUDA EP binaries.
43
- // (deprecated, use --onnxruntime-node-install=skip)
44
- //
45
- //
46
- // Alternatively, use environment variable "ONNXRUNTIME_NODE_INSTALL" or "ONNXRUNTIME_NODE_INSTALL_CUDA" (deprecated).
47
- //
48
- // If the flag is not provided, the script will look up the metadata file to determine the manifest.
49
- //
50
-
51
- /**
52
- * Possible values:
53
- * - undefined: the default behavior. This is the value when no installation flag is specified.
54
- *
55
- * - false: skip installation. This is the value when the installation flag is set to "skip":
56
- * --onnxruntime-node-install=skip
57
- *
58
- * - true: force installation. This is the value when the installation flag is set with no value:
59
- * --onnxruntime-node-install
60
- *
61
- * - string: the installation flag is set to a specific value:
62
- * --onnxruntime-node-install=cuda12
63
- */
64
- const INSTALL_FLAG = parseInstallFlag();
65
-
66
- // if installation is skipped, exit early
67
- if (INSTALL_FLAG === false) {
68
- process.exit(0);
69
- }
70
- // if installation is not specified, exit early when the installation is local (e.g. `npm ci` in <ORT_ROOT>/js/node/)
71
- if (INSTALL_FLAG === undefined) {
72
- const npm_config_local_prefix = process.env.npm_config_local_prefix;
73
- const npm_package_json = process.env.npm_package_json;
74
- const IS_LOCAL_INSTALL =
75
- npm_config_local_prefix && npm_package_json && path.dirname(npm_package_json) === npm_config_local_prefix;
76
- if (IS_LOCAL_INSTALL) {
77
- process.exit(0);
78
- }
79
- }
80
-
81
- const PLATFORM = `${os.platform()}/${os.arch()}`;
82
- let INSTALL_MANIFEST_NAMES = INSTALL_METADATA.requirements[PLATFORM] ?? [];
83
-
84
- // if installation is specified explicitly, validate the manifest
85
- if (typeof INSTALL_FLAG === 'string') {
86
- const installations = INSTALL_FLAG.split(',').map((x) => x.trim());
87
- for (const installation of installations) {
88
- if (INSTALL_MANIFEST_NAMES.indexOf(installation) === -1) {
89
- throw new Error(`Invalid installation: ${installation} for platform: ${PLATFORM}`);
90
- }
91
- }
92
- INSTALL_MANIFEST_NAMES = installations;
93
- }
94
-
95
- const BIN_FOLDER = path.join(__dirname, '..', 'bin/napi-v6', PLATFORM);
96
- const INSTALL_MANIFESTS = [];
97
-
98
- const PACKAGES = new Set();
99
- for (const name of INSTALL_MANIFEST_NAMES) {
100
- const manifest = INSTALL_METADATA.manifests[`${PLATFORM}:${name}`];
101
- if (!manifest) {
102
- throw new Error(`Manifest not found: ${name} for platform: ${PLATFORM}`);
103
- }
104
-
105
- for (const [filename, { package: pkg, path: pathInPackage }] of Object.entries(manifest)) {
106
- const packageCandidates = INSTALL_METADATA.packages[pkg];
107
- if (!packageCandidates) {
108
- throw new Error(`Package information not found: ${pkg}`);
109
- }
110
- PACKAGES.add(packageCandidates);
111
-
112
- INSTALL_MANIFESTS.push({
113
- filepath: path.normalize(path.join(BIN_FOLDER, filename)),
114
- packagesInfo: packageCandidates,
115
- pathInPackage,
116
- });
117
- }
118
- }
119
-
120
- // If the installation flag is not specified, we do a check to see if the files are already installed.
121
- if (INSTALL_FLAG === undefined) {
122
- let hasMissingFiles = false;
123
- for (const { filepath } of INSTALL_MANIFESTS) {
124
- if (!require('fs').existsSync(filepath)) {
125
- hasMissingFiles = true;
126
- break;
127
- }
128
- }
129
- if (!hasMissingFiles) {
130
- process.exit(0);
131
- }
132
- }
133
-
134
- void installPackages(PACKAGES, INSTALL_MANIFESTS, INSTALL_METADATA.feeds);
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ 'use strict';
5
+
6
+ // This script is written in JavaScript. This is because it is used in "install" script in package.json, which is called
7
+ // when the package is installed either as a dependency or from "npm ci"/"npm install" without parameters. TypeScript is
8
+ // not always available.
9
+
10
+ // The purpose of this script is to download the required binaries for the platform and architecture.
11
+ // Currently, most of the binaries are already bundled in the package, except for the files that described in the file
12
+ // install-metadata.js.
13
+ //
14
+ // Some files (eg. the CUDA EP binaries) are not bundled because they are too large to be allowed in the npm registry.
15
+ // Instead, they are downloaded from the Nuget feed. The script will download the binaries if they are not already
16
+ // present in the NPM package.
17
+
18
+ // Step.1: Check if we should exit early
19
+ const os = require('os');
20
+ const path = require('path');
21
+ const { bootstrap: globalAgentBootstrap } = require('global-agent');
22
+ const { installPackages, parseInstallFlag } = require('./install-utils.js');
23
+
24
+ const INSTALL_METADATA = require('./install-metadata.js');
25
+
26
+ // Bootstrap global-agent to honor the proxy settings in
27
+ // environment variables, e.g. GLOBAL_AGENT_HTTPS_PROXY.
28
+ // See https://github.com/gajus/global-agent/blob/v3.0.0/README.md#environment-variables for details.
29
+ globalAgentBootstrap();
30
+
31
+ // commandline flag:
32
+ //
33
+ // --onnxruntime-node-install Force install the files that are not bundled in the package.
34
+ //
35
+ // --onnxruntime-node-install=skip Skip the installation of the files that are not bundled in the package.
36
+ //
37
+ // --onnxruntime-node-install=cuda12 Force install the CUDA EP binaries for CUDA 12.
38
+ //
39
+ // --onnxruntime-node-install-cuda Force install the CUDA EP binaries.
40
+ // (deprecated, use --onnxruntime-node-install=cuda12)
41
+ //
42
+ // --onnxruntime-node-install-cuda=skip Skip the installation of the CUDA EP binaries.
43
+ // (deprecated, use --onnxruntime-node-install=skip)
44
+ //
45
+ //
46
+ // Alternatively, use environment variable "ONNXRUNTIME_NODE_INSTALL" or "ONNXRUNTIME_NODE_INSTALL_CUDA" (deprecated).
47
+ //
48
+ // If the flag is not provided, the script will look up the metadata file to determine the manifest.
49
+ //
50
+
51
+ /**
52
+ * Possible values:
53
+ * - undefined: the default behavior. This is the value when no installation flag is specified.
54
+ *
55
+ * - false: skip installation. This is the value when the installation flag is set to "skip":
56
+ * --onnxruntime-node-install=skip
57
+ *
58
+ * - true: force installation. This is the value when the installation flag is set with no value:
59
+ * --onnxruntime-node-install
60
+ *
61
+ * - string: the installation flag is set to a specific value:
62
+ * --onnxruntime-node-install=cuda12
63
+ */
64
+ const INSTALL_FLAG = parseInstallFlag();
65
+
66
+ // if installation is skipped, exit early
67
+ if (INSTALL_FLAG === false) {
68
+ process.exit(0);
69
+ }
70
+ // if installation is not specified, exit early when the installation is local (e.g. `npm ci` in <ORT_ROOT>/js/node/)
71
+ if (INSTALL_FLAG === undefined) {
72
+ const npm_config_local_prefix = process.env.npm_config_local_prefix;
73
+ const npm_package_json = process.env.npm_package_json;
74
+ const IS_LOCAL_INSTALL =
75
+ npm_config_local_prefix && npm_package_json && path.dirname(npm_package_json) === npm_config_local_prefix;
76
+ if (IS_LOCAL_INSTALL) {
77
+ process.exit(0);
78
+ }
79
+ }
80
+
81
+ const PLATFORM = `${os.platform()}/${os.arch()}`;
82
+ let INSTALL_MANIFEST_NAMES = INSTALL_METADATA.requirements[PLATFORM] ?? [];
83
+
84
+ // if installation is specified explicitly, validate the manifest
85
+ if (typeof INSTALL_FLAG === 'string') {
86
+ const installations = INSTALL_FLAG.split(',').map((x) => x.trim());
87
+ for (const installation of installations) {
88
+ if (INSTALL_MANIFEST_NAMES.indexOf(installation) === -1) {
89
+ throw new Error(`Invalid installation: ${installation} for platform: ${PLATFORM}`);
90
+ }
91
+ }
92
+ INSTALL_MANIFEST_NAMES = installations;
93
+ }
94
+
95
+ const BIN_FOLDER = path.join(__dirname, '..', 'bin/napi-v6', PLATFORM);
96
+ const INSTALL_MANIFESTS = [];
97
+
98
+ const PACKAGES = new Set();
99
+ for (const name of INSTALL_MANIFEST_NAMES) {
100
+ const manifest = INSTALL_METADATA.manifests[`${PLATFORM}:${name}`];
101
+ if (!manifest) {
102
+ throw new Error(`Manifest not found: ${name} for platform: ${PLATFORM}`);
103
+ }
104
+
105
+ for (const [filename, { package: pkg, path: pathInPackage }] of Object.entries(manifest)) {
106
+ const packageCandidates = INSTALL_METADATA.packages[pkg];
107
+ if (!packageCandidates) {
108
+ throw new Error(`Package information not found: ${pkg}`);
109
+ }
110
+ PACKAGES.add(packageCandidates);
111
+
112
+ INSTALL_MANIFESTS.push({
113
+ filepath: path.normalize(path.join(BIN_FOLDER, filename)),
114
+ packagesInfo: packageCandidates,
115
+ pathInPackage,
116
+ });
117
+ }
118
+ }
119
+
120
+ // If the installation flag is not specified, we do a check to see if the files are already installed.
121
+ if (INSTALL_FLAG === undefined) {
122
+ let hasMissingFiles = false;
123
+ for (const { filepath } of INSTALL_MANIFESTS) {
124
+ if (!require('fs').existsSync(filepath)) {
125
+ hasMissingFiles = true;
126
+ break;
127
+ }
128
+ }
129
+ if (!hasMissingFiles) {
130
+ process.exit(0);
131
+ }
132
+ }
133
+
134
+ void installPackages(PACKAGES, INSTALL_MANIFESTS, INSTALL_METADATA.feeds);
package/script/prepack.ts CHANGED
@@ -1,20 +1,20 @@
1
- // Copyright (c) Microsoft Corporation. All rights reserved.
2
- // Licensed under the MIT License.
3
-
4
- import * as fs from 'fs-extra';
5
- import * as path from 'path';
6
-
7
- function updatePackageJson() {
8
- const commonPackageJsonPath = path.join(__dirname, '..', '..', 'common', 'package.json');
9
- const selfPackageJsonPath = path.join(__dirname, '..', 'package.json');
10
- console.log(`=== start to update package.json: ${selfPackageJsonPath}`);
11
- const packageCommon = fs.readJSONSync(commonPackageJsonPath);
12
- const packageSelf = fs.readJSONSync(selfPackageJsonPath);
13
- const version = packageCommon.version;
14
- packageSelf.dependencies['onnxruntime-common'] = `${version}`;
15
- fs.writeJSONSync(selfPackageJsonPath, packageSelf, { spaces: 2 });
16
- console.log('=== finished updating package.json.');
17
- }
18
-
19
- // update version of dependency "onnxruntime-common" before packing
20
- updatePackageJson();
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ import * as fs from 'fs-extra';
5
+ import * as path from 'path';
6
+
7
+ function updatePackageJson() {
8
+ const commonPackageJsonPath = path.join(__dirname, '..', '..', 'common', 'package.json');
9
+ const selfPackageJsonPath = path.join(__dirname, '..', 'package.json');
10
+ console.log(`=== start to update package.json: ${selfPackageJsonPath}`);
11
+ const packageCommon = fs.readJSONSync(commonPackageJsonPath);
12
+ const packageSelf = fs.readJSONSync(selfPackageJsonPath);
13
+ const version = packageCommon.version;
14
+ packageSelf.dependencies['onnxruntime-common'] = `${version}`;
15
+ fs.writeJSONSync(selfPackageJsonPath, packageSelf, { spaces: 2 });
16
+ console.log('=== finished updating package.json.');
17
+ }
18
+
19
+ // update version of dependency "onnxruntime-common" before packing
20
+ updatePackageJson();
package/__commit.txt DELETED
@@ -1 +0,0 @@
1
- c19a49615bcbda238250aa2d86e28b80afe38498