Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[JS] Upgrade the js package versions to the upcoming releases (#30091)

Kirill Suvorovbf538235c880
diff --git a/.github/workflows/job_build_linux.yml b/.github/workflows/job_build_linux.yml
index 0683b4b2e2d..5ceabbae6c3 100644
--- a/.github/workflows/job_build_linux.yml
+++ b/.github/workflows/job_build_linux.yml
@@ -85,7 +85,7 @@ jobs:
OPENVINO_REPO: /__w/openvino/openvino/openvino
OPENVINO_CONTRIB_REPO: /__w/openvino/openvino/openvino_contrib
INSTALL_DIR: /__w/openvino/openvino/openvino_install
- INSTALL_DIR_JS: /__w/openvino/openvino/openvino_install/js
+ INSTALL_DIR_JS: /__w/openvino/openvino/openvino/src/bindings/js/node/bin
INSTALL_TEST_DIR: /__w/openvino/openvino/tests_install
INSTALL_WHEELS_DIR: /__w/openvino/openvino/install/wheels
DEVELOPER_PACKAGE_DIR: /__w/openvino/openvino/developer_package_install
@@ -285,6 +285,15 @@ jobs:
if: ${{ fromJSON(inputs.affected-components).JS_API && inputs.build-js }}
run: tar -cvf - * | pigz > ${BUILD_DIR}/openvino_js_package.tar.gz
working-directory: ${{ env.INSTALL_DIR_JS }}
+
+ - name: Pack openvino_node_npm_package
+ id: openvino_node_npm_package
+ if: ${{ fromJSON(inputs.affected-components).JS_API && inputs.build-js }}
+ run: |
+ npm i
+ ARCHIVE_NAME=$(npm pack --silent --pack-destination ${{ env.BUILD_DIR }})
+ echo "archive_name=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
+ working-directory: ${{ env.OPENVINO_REPO }}/src/bindings/js/node
- name: Build RPM packages
if: ${{ inputs.build-rpm-packages }}
@@ -333,6 +342,14 @@ jobs:
path: ${{ env.BUILD_DIR }}/openvino_js_package.tar.gz
if-no-files-found: 'error'
+ - name: Upload openvino-node NPM package
+ if: ${{ fromJSON(inputs.affected-components).JS_API && inputs.build-js }}
+ uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
+ with:
+ name: openvino_node_npm_package
+ path: ${{ env.BUILD_DIR }}/${{ steps.openvino_node_npm_package.outputs.archive_name }}
+ if-no-files-found: 'error'
+
- name: Upload OpenVINO developer package
if: ${{ always() }}
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
@@ -385,6 +402,7 @@ jobs:
${{ env.BUILD_DIR }}/deb
${{ env.MANIFEST_PATH }}
${{ env.STORE_JS == 'true' && format('{0}/openvino_js_package.tar.gz', env.BUILD_DIR) || '' }}
+ ${{ env.STORE_JS == 'true' && format('{0}/{1}', env.BUILD_DIR, steps.openvino_node_npm_package.outputs.archive_name) || '' }}
${{ env.STORE_WHEELS == 'true' && format('{0}/wheels', env.INSTALL_WHEELS_DIR) || '' }}
storage_dir: ${{ env.PRODUCT_TYPE }}
storage_root: ${{ env.ARTIFACTS_SHARE }}
diff --git a/.github/workflows/job_build_windows.yml b/.github/workflows/job_build_windows.yml
index dcbb832d30a..5770626cbab 100644
--- a/.github/workflows/job_build_windows.yml
+++ b/.github/workflows/job_build_windows.yml
@@ -32,6 +32,7 @@ permissions: read-all
env:
PIP_CACHE_PATH: "C:\\mount\\caches\\pip\\win"
PYTHON_VERSION: '3.11'
+ NODEJS_VERSION: '21'
jobs:
Build:
@@ -50,7 +51,7 @@ jobs:
OPENVINO_REPO: "${{ github.workspace }}\\openvino"
OPENVINO_CONTRIB_REPO: "${{ github.workspace }}\\openvino_contrib"
INSTALL_DIR: "${{ github.workspace }}\\openvino_install"
- INSTALL_DIR_JS: "${{ github.workspace }}\\openvino_install\\js"
+ INSTALL_DIR_JS: "${{ github.workspace }}\\openvino\\src\\bindings\\js\\node\\bin"
INSTALL_TEST_DIR: "${{ github.workspace }}\\tests_install"
INSTALL_WHEELS_DIR: "${{ github.workspace }}\\install\\wheels"
INSTALL_DEV_PACKAGE: "${{ github.workspace }}\\install\\developer_package"
@@ -82,6 +83,12 @@ jobs:
pip-cache-path: ${{ env.PIP_CACHE_PATH }}
should-setup-pip-paths: 'true'
self-hosted-runner: 'true'
+
+ - name: Setup NodeJS
+ if: ${{ fromJSON(inputs.affected-components).JS_API }}
+ uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
+ with:
+ node-version: ${{ env.NODEJS_VERSION }}
- name: Generate product manifest and set CI_BUILD_NUMBER & CI_BUILD_DEV_TAG
id: create_manifest
@@ -319,6 +326,15 @@ jobs:
DestinationPath = "${{ env.BUILD_DIR }}/openvino_js_package.zip"
}
Compress-Archive @compress
+
+ - name: Pack openvino_node_npm_package
+ id: openvino_node_npm_package
+ if: ${{ fromJSON(inputs.affected-components).JS_API }}
+ run: |
+ npm i
+ $archiveName = npm pack --silent --pack-destination ${{ env.BUILD_DIR }}
+ Write-Output "archive_name=$archiveName" >> $env:GITHUB_OUTPUT
+ working-directory: ${{ env.OPENVINO_REPO }}/src/bindings/js/node
- name: Cmake & Build - OpenVINO Contrib
run: |
@@ -375,6 +391,14 @@ jobs:
path: ${{ env.BUILD_DIR }}/openvino_js_package.zip
if-no-files-found: 'error'
+ - name: Upload openvino-node NPM package
+ if: ${{ fromJSON(inputs.affected-components).JS_API }}
+ uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
+ with:
+ name: openvino_node_npm_package
+ path: ${{ env.BUILD_DIR }}/${{ steps.openvino_node_npm_package.outputs.archive_name }}
+ if-no-files-found: 'error'
+
- name: Store artifacts to a shared drive
id: store_artifacts
if: always()
@@ -386,8 +410,9 @@ jobs:
${{ env.BUILD_DIR }}/openvino_tests.zip
${{ env.MANIFEST_PATH }}
${{ fromJSON(inputs.affected-components).JS_API && format('{0}/openvino_js_package.zip', env.BUILD_DIR) || '' }}
+ ${{ fromJSON(inputs.affected-components).JS_API && format('{0}/{1}', env.BUILD_DIR, steps.openvino_node_npm_package.outputs.archive_name) || '' }}
${{ env.STORE_WHEELS == 'true' && format('{0}/wheels', env.INSTALL_WHEELS_DIR) || '' }}
storage_dir: ${{ env.PRODUCT_TYPE }}
storage_root: ${{ env.ARTIFACTS_SHARE }}
env:
- STORE_WHEELS: ${{ inputs.build-type != 'Debug' }}
\ No newline at end of file
+ STORE_WHEELS: ${{ inputs.build-type != 'Debug' }}
diff --git a/.github/workflows/job_openvino_js.yml b/.github/workflows/job_openvino_js.yml
index 6425ecdd7db..1de915af43a 100644
--- a/.github/workflows/job_openvino_js.yml
+++ b/.github/workflows/job_openvino_js.yml
@@ -26,7 +26,7 @@ jobs:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input
- OPENVINO_JS_DIR: ${{ github.workspace }}/openvino/src/bindings/js
+ OPENVINO_JS_DIR: ${{ github.workspace }}/openvino/src/bindings/js/node
OPENVINO_JS_LIBS_DIR: ${{ github.workspace }}/openvino/src/bindings/js/node/bin
NODE_VERSION: 21
DISPLAY: ':99'
@@ -46,13 +46,13 @@ jobs:
# Needed as ${{ github.workspace }} is not working correctly when using Docker
- name: Setup Variables
run: |
- echo "OPENVINO_JS_DIR=$GITHUB_WORKSPACE/openvino/src/bindings/js" >> "$GITHUB_ENV"
+ echo "OPENVINO_JS_DIR=$GITHUB_WORKSPACE/openvino/src/bindings/js/node" >> "$GITHUB_ENV"
echo "OPENVINO_JS_LIBS_DIR=$GITHUB_WORKSPACE/openvino/src/bindings/js/node/bin" >> "$GITHUB_ENV"
- name: Download OpenVINO artifacts (JS)
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
- pattern: openvino_[js]*
+ name: openvino_js_package
path: ${{ env.OPENVINO_JS_LIBS_DIR }}
merge-multiple: true
@@ -67,11 +67,11 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
- name: Configure OpenVINO JS API
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: npm i
- name: Test OpenVINO JS API
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: npm run test
- name: Install electron deps and run Xvfb
@@ -81,5 +81,5 @@ jobs:
Xvfb "$DISPLAY" &
- name: E2E of openvino-node package
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: npm run test:e2e
diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml
index ee3d6d7478a..2119d035ff1 100644
--- a/.github/workflows/mac.yml
+++ b/.github/workflows/mac.yml
@@ -32,6 +32,7 @@ permissions: read-all
env:
PYTHON_VERSION: '3.11'
+ NODEJS_VERSION: '21'
MANIFEST_FILE: manifest.yml
PRODUCT_TYPE: public_macos_x86_64_release
@@ -79,12 +80,14 @@ jobs:
OPENVINO_REPO: ${{ github.workspace }}/openvino
OPENVINO_CONTRIB_REPO: ${{ github.workspace }}/openvino_contrib
INSTALL_DIR: ${{ github.workspace }}/openvino_install
- INSTALL_DIR_JS: ${{ github.workspace }}/openvino_install/js
+ INSTALL_DIR_JS: ${{ github.workspace }}/openvino/src/bindings/js/node/bin
INSTALL_TEST_DIR: ${{ github.workspace }}/tests_install
DEVELOPER_PACKAGE_DIR: ${{ github.workspace }}/developer_package_install
INSTALL_WHEELS_DIR: ${{ github.workspace }}/install/wheels
BUILD_DIR: ${{ github.workspace }}/build
if: "!needs.smart_ci.outputs.skip_workflow"
+ outputs:
+ openvino_npm_archive_name: ${{ steps.openvino_node_npm_package.outputs.archive_name }}
steps:
- name: Clone OpenVINO
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -135,6 +138,12 @@ jobs:
# For running Paddle frontend unit tests
python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt
+ - name: Setup NodeJS
+ if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API
+ uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
+ with:
+ node-version: ${{ env.NODEJS_VERSION }}
+
#
# Build
#
@@ -276,6 +285,15 @@ jobs:
run: tar -cvf - * | pigz > ${BUILD_DIR}/openvino_js_package.tar.gz
working-directory: ${{ env.INSTALL_DIR_JS }}
+ - name: Pack openvino_node_npm_package
+ id: openvino_node_npm_package
+ if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API
+ run: |
+ npm i
+ ARCHIVE_NAME=$(npm pack --silent --pack-destination ${{ env.BUILD_DIR }})
+ echo "archive_name=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
+ working-directory: ${{ env.OPENVINO_REPO }}/src/bindings/js/node
+
#
# Upload build artifacts
#
@@ -319,6 +337,14 @@ jobs:
path: ${{ env.BUILD_DIR }}/openvino_js_package.tar.gz
if-no-files-found: 'error'
+ - name: Upload openvino-node NPM package
+ if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API
+ uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
+ with:
+ name: openvino_node_npm_package
+ path: ${{ env.BUILD_DIR }}/${{ steps.openvino_node_npm_package.outputs.archive_name }}
+ if-no-files-found: 'error'
+
- name: Upload product manifest
if: ${{ always() }}
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
@@ -368,7 +394,7 @@ jobs:
- name: Download OpenVINO artifacts
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
- pattern: "{openvino_package,openvino_developer_package,openvino_js_package,openvino_package_manifest}"
+ pattern: "{openvino_package,openvino_developer_package,openvino_js_package,openvino_node_npm_package,openvino_package_manifest}"
path: ${{ env.ARTIFACTS_DIR }}
merge-multiple: true
@@ -390,5 +416,6 @@ jobs:
${{ env.ARTIFACTS_DIR }}/developer_package.tar.gz
${{ env.WHEELS_DIR }}
${{ fromJSON(needs.smart_ci.outputs.affected_components).JS_API && format('{0}/openvino_js_package.tar.gz', env.ARTIFACTS_DIR) || '' }}
+ ${{ fromJSON(needs.smart_ci.outputs.affected_components).JS_API && format('{0}/{1}', env.ARTIFACTS_DIR, needs.Build.outputs.openvino_npm_archive_name) || '' }}
storage_dir: ${{ env.PRODUCT_TYPE }}
- storage_root: ${{ env.ARTIFACTS_SHARE }}
\ No newline at end of file
+ storage_root: ${{ env.ARTIFACTS_SHARE }}
diff --git a/.github/workflows/mac_arm64.yml b/.github/workflows/mac_arm64.yml
index 2e2ed8a2663..375a6e305ad 100644
--- a/.github/workflows/mac_arm64.yml
+++ b/.github/workflows/mac_arm64.yml
@@ -32,6 +32,7 @@ permissions: read-all
env:
PYTHON_VERSION: '3.11'
+ NODEJS_VERSION: '21'
jobs:
Smart_CI:
@@ -75,7 +76,7 @@ jobs:
OPENVINO_REPO: ${{ github.workspace }}/openvino
OPENVINO_CONTRIB_REPO: ${{ github.workspace }}/openvino_contrib
INSTALL_DIR: ${{ github.workspace }}/openvino_install
- INSTALL_DIR_JS: ${{ github.workspace }}/openvino_install/js
+ INSTALL_DIR_JS: ${{ github.workspace }}/openvino/src/bindings/js/node/bin
INSTALL_TEST_DIR: ${{ github.workspace }}/tests_install
INSTALL_WHEELS_DIR: ${{ github.workspace }}/install/wheels
BUILD_DIR: ${{ github.workspace }}/build
@@ -130,6 +131,12 @@ jobs:
# For running Paddle frontend unit tests
python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt
+ - name: Setup NodeJS
+ if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API
+ uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
+ with:
+ node-version: ${{ env.NODEJS_VERSION }}
+
#
# Build
#
@@ -248,6 +255,15 @@ jobs:
run: tar -cvf - * | pigz > ${BUILD_DIR}/openvino_js_package.tar.gz
working-directory: ${{ env.INSTALL_DIR_JS }}
+ - name: Pack openvino_node_npm_package
+ id: openvino_node_npm_package
+ if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API
+ run: |
+ npm i
+ ARCHIVE_NAME=$(npm pack --silent --pack-destination ${{ env.BUILD_DIR }})
+ echo "archive_name=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
+ working-directory: ${{ env.OPENVINO_REPO }}/src/bindings/js/node
+
#
# Upload build artifacts
#
@@ -283,6 +299,14 @@ jobs:
path: ${{ env.BUILD_DIR }}/openvino_js_package.tar.gz
if-no-files-found: 'error'
+ - name: Upload openvino-node NPM package
+ if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API
+ uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
+ with:
+ name: openvino_node_npm_package
+ path: ${{ env.BUILD_DIR }}/${{ steps.openvino_node_npm_package.outputs.archive_name }}
+ if-no-files-found: 'error'
+
Samples:
needs: [ Build, Smart_CI ]
uses: ./.github/workflows/job_samples_tests.yml
diff --git a/.github/workflows/ubuntu_20.yml b/.github/workflows/ubuntu_20.yml
index 50e5e872834..4098986c12a 100644
--- a/.github/workflows/ubuntu_20.yml
+++ b/.github/workflows/ubuntu_20.yml
@@ -89,7 +89,7 @@ jobs:
os: 'ubuntu_20_04'
build-contrib: true
build-debian-packages: true
- build-js: true
+ build-js: false
build-rpm-packages: false
build-additional-python-packages: true
cmake-options: >-
diff --git a/.github/workflows/ubuntu_24.yml b/.github/workflows/ubuntu_24.yml
index f790a931f08..f688281710f 100644
--- a/.github/workflows/ubuntu_24.yml
+++ b/.github/workflows/ubuntu_24.yml
@@ -85,7 +85,7 @@ jobs:
event-name: ${{ github.event_name }}
os: 'ubuntu_24_04'
build-rpm-packages: false
- build-js: true
+ build-js: false
build-debian-packages: true
build-contrib: true
build-additional-python-packages: true
diff --git a/.github/workflows/windows_vs2022_release.yml b/.github/workflows/windows_vs2022_release.yml
index 1ec097ce886..857d3bb8f16 100644
--- a/.github/workflows/windows_vs2022_release.yml
+++ b/.github/workflows/windows_vs2022_release.yml
@@ -173,7 +173,7 @@ jobs:
shell: pwsh
runs-on: 'aks-win-4-cores-8gb'
env:
- OPENVINO_JS_DIR: "${{ github.workspace }}\\openvino\\src\\bindings\\js"
+ OPENVINO_JS_DIR: "${{ github.workspace }}\\openvino\\src\\bindings\\js\\node"
OPENVINO_JS_LIBS_DIR: "${{ github.workspace }}\\openvino\\src\\bindings\\js\\node\\bin"
NODE_VERSION: 21
if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API
@@ -204,35 +204,36 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
- name: Configure OpenVINO JS API
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: npm i
- name: Test OpenVINO JS API
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: npm test
- name: Test OpenVINO JS API (cmd)
shell: cmd
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: call npm test
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2
- name: E2E of openvino-node package
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: npm run test:e2e
- name: E2E of openvino-node package (cmd)
shell: cmd
- working-directory: ${{ env.OPENVINO_JS_DIR }}/node
+ working-directory: ${{ env.OPENVINO_JS_DIR }}
run: call npm run test:e2e
- name: Create package dir
- working-directory: ${{ env.OPENVINO_JS_DIR }}
+ working-directory: ${{ github.workspace }}
run: mkdir project-uses-openvino-node
+
- name: Test installation of openvino-node package
- working-directory: ${{ env.OPENVINO_JS_DIR }}/project-uses-openvino-node
+ working-directory: ${{ github.workspace }}/project-uses-openvino-node
run: |
npm i openvino-node
node -e "const { addon: ov } = require('openvino-node'); console.log(ov);"
diff --git a/src/bindings/js/node/package.json b/src/bindings/js/node/package.json
index 9e438f78f9a..0a58f1ca909 100644
--- a/src/bindings/js/node/package.json
+++ b/src/bindings/js/node/package.json
@@ -31,9 +31,9 @@
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"eslint": "^8.49.0",
+ "mocha": "^10.6.0",
"random-bigint": "^0.0.1",
- "typescript": "^5.0.4",
- "mocha": "^10.6.0"
+ "typescript": "^5.0.4"
},
"engines": {
"node": ">=21.0.0"
diff --git a/src/bindings/js/node/scripts/lib/binary-manager.js b/src/bindings/js/node/scripts/lib/binary-manager.js
index f0af78b4909..880fc463268 100644
--- a/src/bindings/js/node/scripts/lib/binary-manager.js
+++ b/src/bindings/js/node/scripts/lib/binary-manager.js
@@ -3,7 +3,7 @@ const tar = require('tar-fs');
const path = require('node:path');
const gunzip = require('gunzip-maybe');
const fs = require('node:fs/promises');
-const { createReadStream } = require('node:fs');
+const { createReadStream, existsSync } = require('node:fs');
const { downloadFile, checkIfPathExists, removeDirectory } = require('./utils');
@@ -32,7 +32,7 @@ class BinaryManager {
package_name: packageNameTemplate,
remote_path: remotePathTemplate,
} = this.binaryConfig;
- const fullPathTemplate = `${remotePathTemplate}${packageNameTemplate}`
+ const fullPathTemplate = `${remotePathTemplate}${packageNameTemplate}`;
const fullPath = fullPathTemplate
.replace(new RegExp('{version}', 'g'), this.version)
.replace(new RegExp('{platform}', 'g'), this.getPlatformLabel())
@@ -49,18 +49,24 @@ class BinaryManager {
}
/**
- * Prepares the binary by downloading and extracting the OpenVINO runtime archive.
+ * Prepares the binary by downloading and extracting the OpenVINO runtime
+ * archive.
*
* @param {string} packageRoot - The root directory of the package.
* @param {string} version - The version of the binary.
* @param {Object} binaryConfig - The configuration object for the binary.
* @param {Object} options - The options for preparing the binary.
- * @param {boolean} options.force - Whether to force the download if the directory already exists.
- * @param {boolean} options.ignoreIfExists - Whether to ignore the download if the directory already exists.
- * @param {string} [options.proxy] - The proxy to use for downloading the file.
- * @throws {Error} If the directory already exists and the force option is not set.
+ * @param {boolean} options.force - Whether to force the download if the
+ * directory already exists.
+ * @param {boolean} options.ignoreIfExists - Whether to ignore the download
+ * if the directory already exists.
+ * @param {string} [options.proxy] - The proxy to use for downloading the
+ * file.
+ * @throws {Error} If the directory already exists and the force option
+ * is not set.
* @throws {Error} If the download or extraction fails.
- * @returns {Promise<void>} A promise that resolves when the binary is prepared.
+ * @returns {Promise<void>} A promise that resolves when the binary is
+ * prepared.
*/
static async prepareBinary(packageRoot, version, binaryConfig, options) {
const binaryManager = new this(packageRoot, version, binaryConfig);
@@ -83,6 +89,24 @@ class BinaryManager {
);
}
+ // Install binaries from directories if possible
+ if (process.env.npm_package_resolved.startsWith('file:')) {
+ const binDir = path.join(
+ path.dirname(process.env.npm_package_resolved),
+ 'bin'
+ ).replace('file:', '');
+ if (existsSync(path.join(binDir, 'libopenvino.so'))) {
+ try {
+ await fs.cp(binDir, destinationPath, {'recursive': true});
+
+ return;
+ } catch(error) {
+ console.error(`Failed to copy bin directory: ${error}.`);
+ }
+ }
+ console.log('Do not find bin directory with openvino library.');
+ }
+
const archiveUrl = binaryManager.getArchiveUrl();
let tempDirectoryPath = null;
@@ -99,7 +123,7 @@ class BinaryManager {
tempDirectoryPath,
filename,
options.proxy,
- )
+ );
console.log('OpenVINO runtime archive downloaded.');
await removeDirectory(destinationPath);
@@ -119,9 +143,11 @@ class BinaryManager {
* Supported platforms: 'win32', 'linux', 'darwin'.
* Supported architectures: 'arm64', 'armhf', 'x64'.
*
- * If the platform or architecture is not supported, an error message is logged to the console.
+ * If the platform or architecture is not supported, an error message
+ * is logged to the console.
*
- * @returns {boolean} Returns true if the platform and architecture are compatible, otherwise false.
+ * @returns {boolean} Returns true if the platform and architecture are
+ * compatible, otherwise false.
*/
static isCompatible() {
const missleadings = [];
@@ -140,6 +166,7 @@ class BinaryManager {
if (missleadings.length) {
console.error(missleadings.join(' '));
+
return false;
}