@reboot-dev/reboot 0.26.0 → 0.27.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.
package/binding.gyp CHANGED
@@ -3,18 +3,8 @@
3
3
  {
4
4
  "python3":
5
5
  "<!(echo $RBT_PYTHON3_USE)",
6
- # Using `node` to get the OS and arch since it is platform independent.
7
- "os_and_arch":
8
- "<(OS) <!(node -p process.arch)",
9
- # See https://gregoryszorc.com/docs/python-build-standalone/main/running.html.
10
- # We use `gnu` (rather than `musl`) because we need a libc that we can install
11
- # our native python extension on.
12
- #
13
- # NOTE: Although that page recommends using `x86_64_v3` for Linux, we have
14
- # encountered CPUs and/or GCC installs which do not support `x86-64-v3` (or v2)
15
- # as the `-march`. Consequently, we use `x86_64` instead.
16
- "pbs_base_url":
17
- "https://github.com/indygreg/python-build-standalone/releases/download/20240814/cpython-3.10.14+20240814",
6
+ "REBOOT_BAZEL_TEST_FOR_BINDING":
7
+ "<!(echo $REBOOT_BAZEL_TEST_FOR_BINDING)",
18
8
  },
19
9
  "conditions":
20
10
  [
@@ -24,62 +14,26 @@
24
14
  "conditions":
25
15
  [
26
16
  [
27
- "os_and_arch=='mac arm64' and python3==''", {
28
- "variables":
29
- {
30
- "python3":
31
- "<!(curl -s -L <(pbs_base_url)-aarch64-apple-darwin-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
32
- },
33
- }
34
- ],
35
- [
36
- "os_and_arch=='mac x64' and python3==''", {
37
- "variables":
38
- {
39
- "python3":
40
- "<!(curl -s -L <(pbs_base_url)-x86_64-apple-darwin-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
41
- },
42
- }
43
- ],
44
- [
45
- "os_and_arch=='linux arm64' and python3==''", {
46
- "variables":
47
- {
48
- "python3":
49
- "<!(curl -s -L <(pbs_base_url)-aarch64-unknown-linux-gnu-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
50
- },
51
- }
52
- ],
53
- [
54
- "os_and_arch=='linux x64' and python3==''", {
55
- "variables":
56
- {
57
- "python3":
58
- "<!(curl -s -L <(pbs_base_url)-x86_64-unknown-linux-gnu-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
59
- },
60
- }
61
- ],
62
- [
63
- "OS=='mac' and python3==''",
17
+ "OS=='mac' and REBOOT_BAZEL_TEST_FOR_BINDING==''",
64
18
  {
19
+ # NOTE: On macOS, the `rpath` is not respected, and the dependency name of the
20
+ # downloaded Python is based on what it self-reports. We adjust what it will
21
+ # self-report in order to ensure that it is located at runtime.
22
+ #
23
+ # In theory, `gyp` supports Actions and dependencies between Targets. But
24
+ # in practice, `node-gyp` makes (undocumented) adjustments to both Actions and
25
+ # Targets that make it very challenging to use it for either fetching or
26
+ # updating the interpreter. We use private/dummy variables here to trigger
27
+ # side-effects instead.
65
28
  "variables":
66
29
  {
67
- # NOTE: On macOS, the `rpath` is not respected, and the dependency name of the
68
- # downloaded Python is based on what it self-reports. We adjust what it will
69
- # self-report in order to ensure that it is located at runtime.
70
- #
71
- # In theory, `gyp` supports Actions and dependencies between Targets. But
72
- # in practice, `node-gyp` makes (undocumented) adjustments to both Actions and
73
- # Targets that make it very challenging to use it for either fetching or
74
- # updating the interpreter. We use private/dummy variables here to trigger
75
- # side-effects instead.
76
30
  "_absolute_lib_path":
77
31
  "<!(echo $(pwd)/python/lib/libpython3.10.dylib)",
78
32
  "_dummy":
79
33
  "<!(install_name_tool -id <(_absolute_lib_path) <(_absolute_lib_path))"
80
34
  }
81
35
  }
82
- ],
36
+ ]
83
37
  ],
84
38
  "targets":
85
39
  [
package/dummy.cc ADDED
@@ -0,0 +1,7 @@
1
+ #include <cstddef>
2
+ #include <iostream>
3
+ #include <string>
4
+
5
+ int main() {
6
+ return 0;
7
+ }
package/install.cjs ADDED
@@ -0,0 +1,46 @@
1
+ // Using that file to improve the readability in the package.json.
2
+ const { execSync } = require("child_process");
3
+ const fs = require("fs");
4
+
5
+ if (process.platform === "win32") {
6
+ // Do nothing on Windows.
7
+ process.exit(0);
8
+ }
9
+
10
+ function removeEnvFile(fileName) {
11
+ if (fs.existsSync(fileName)) {
12
+ fs.unlinkSync(fileName);
13
+ }
14
+ }
15
+
16
+ try {
17
+ const downloadedPythonPath = fs
18
+ .readFileSync(".reboot_python_env", "utf8")
19
+ .trim();
20
+ const env = {
21
+ ...process.env,
22
+ CC: process.env.CC || fs.readFileSync(".reboot_cc_env", "utf8").trim(),
23
+ CXX: process.env.CXX || fs.readFileSync(".reboot_cxx_env", "utf8").trim(),
24
+ RBT_PYTHON3_USE: process.env.RBT_PYTHON3_USE || downloadedPythonPath,
25
+ REBOOT_BAZEL_TEST_FOR_BINDING: "",
26
+ };
27
+
28
+ // For the Bazel tests we are using a specific Python installed on the
29
+ // runners. So we need to provide that info to node-gyp to avoid
30
+ // making extra steps, which may break the installation.
31
+ if (env.RBT_PYTHON3_USE != downloadedPythonPath) {
32
+ env.REBOOT_BAZEL_TEST_FOR_BINDING = "1";
33
+ }
34
+
35
+ const cmd = `node-gyp rebuild --python=${env.RBT_PYTHON3_USE}`;
36
+ console.log(`\n📦 Running: ${cmd}`);
37
+ execSync(cmd, { stdio: "inherit", env });
38
+ } catch (err) {
39
+ console.error("❌ install.js failed:", err);
40
+ process.exit(1);
41
+ } finally {
42
+ // Clean up the environment files.
43
+ removeEnvFile(".reboot_cc_env");
44
+ removeEnvFile(".reboot_cxx_env");
45
+ removeEnvFile(".reboot_python_env");
46
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "@bufbuild/protobuf": "1.3.2",
4
4
  "@bufbuild/protoplugin": "1.3.2",
5
5
  "@bufbuild/protoc-gen-es": "1.3.2",
6
- "@reboot-dev/reboot-api": "0.26.0",
6
+ "@reboot-dev/reboot-api": "0.27.0",
7
7
  "chalk": "^4.1.2",
8
8
  "node-addon-api": "^7.0.0",
9
9
  "node-gyp": ">=10.2.0",
@@ -16,9 +16,11 @@
16
16
  },
17
17
  "type": "module",
18
18
  "name": "@reboot-dev/reboot",
19
- "version": "0.26.0",
19
+ "version": "0.27.0",
20
20
  "description": "npm package for Reboot",
21
21
  "scripts": {
22
+ "preinstall": "node preinstall.cjs",
23
+ "install": "node install.cjs",
22
24
  "postinstall": "rbt || exit 0",
23
25
  "test": "echo \"Error: no test specified\" && exit 1",
24
26
  "prepack": "tsc"
@@ -64,7 +66,11 @@
64
66
  "venv.js",
65
67
  "version.d.ts",
66
68
  "version.js",
67
- "workspaces.js"
69
+ "workspaces.js",
70
+ "prepare_environment.sh",
71
+ "dummy.cc",
72
+ "preinstall.cjs",
73
+ "install.cjs"
68
74
  ],
69
75
  "exports": {
70
76
  "./package.json": "./package.json",
package/preinstall.cjs ADDED
@@ -0,0 +1,10 @@
1
+ // Using that file to improve the readability in the package.json.
2
+
3
+ const { execSync } = require("child_process");
4
+
5
+ if (process.platform === "win32") {
6
+ // Skip on Windows.
7
+ process.exit(0);
8
+ }
9
+
10
+ execSync("./prepare_environment.sh", { stdio: "inherit" });
@@ -0,0 +1,90 @@
1
+ #!/bin/bash
2
+
3
+ OS=$(node -p "require('os').platform()")
4
+ ARCH=$(node -p "process.arch")
5
+
6
+ if [[ "$OS" != "darwin" && "$OS" != "linux" ]]; then
7
+ echo "❌ Unsupported OS: $OS. Only 'darwin' and 'linux' are supported."
8
+ exit 1
9
+ fi
10
+
11
+ # See https://gregoryszorc.com/docs/python-build-standalone/main/running.html.
12
+ # We use `gnu` (rather than `musl`) because we need a libc that we can install
13
+ # our native python extension on.
14
+ #
15
+ # NOTE: Although that page recommends using `x86_64_v3` for Linux, we have
16
+ # encountered CPUs and/or GCC installs which do not support `x86-64-v3` (or v2)
17
+ # as the `-march`. Consequently, we use `x86_64` instead.
18
+ BASE_URL="https://github.com/indygreg/python-build-standalone/releases/download/20240814/cpython-3.10.14+20240814"
19
+
20
+ case "${OS}-${ARCH}" in
21
+ 'darwin-arm64')
22
+ TAR_URL="${BASE_URL}-aarch64-apple-darwin-install_only.tar.gz"
23
+ ;;
24
+ 'darwin-x64')
25
+ TAR_URL="${BASE_URL}-x86_64-apple-darwin-install_only.tar.gz"
26
+ ;;
27
+ 'linux-arm64')
28
+ TAR_URL="${BASE_URL}-aarch64-unknown-linux-gnu-install_only.tar.gz"
29
+ ;;
30
+ 'linux-x64')
31
+ TAR_URL="${BASE_URL}-x86_64-unknown-linux-gnu-install_only.tar.gz"
32
+ ;;
33
+ *)
34
+ echo "❌ Unsupported OS/ARCH: ${OS}-${ARCH}"
35
+ exit 1
36
+ ;;
37
+ esac
38
+
39
+ # The 'node-gyp' requirements check.
40
+ # https://github.com/nodejs/node-gyp?tab=readme-ov-file#installation
41
+
42
+ # Make sure 'make' is installed.
43
+ if ! command -v make &> /dev/null; then
44
+ echo "❌ 'make' is not installed. Please install it to continue."
45
+ exit 1
46
+ fi
47
+
48
+ # Make sure proper C/C++ compilers are installed.
49
+ # 'node-gyp' configure generates the Makefile which is used by make later.
50
+ # https://github.com/nodejs/node-gyp/blob/7d883b5cf4c26e76065201f85b0be36d5ebdcc0e/gyp/pylib/gyp/generator/make.py
51
+ #
52
+ # Only perform toolchain autodetect if CC or CXX are not already set.
53
+ if [ -z "${CC:-}" ] || [ -z "${CXX:-}" ]; then
54
+ if command -v gcc &> /dev/null && command -v g++ &> /dev/null; then
55
+ export CC=gcc
56
+ export CXX=g++
57
+ elif command -v clang &> /dev/null && command -v clang++ &> /dev/null; then
58
+ export CC=clang
59
+ export CXX=clang++
60
+ else
61
+ if [[ "$OS" == "linux" ]]; then
62
+ echo "❌ Neither 'clang' nor 'gcc' are installed. Please install a C/C++ compiler to continue."
63
+ else
64
+ echo "❌ Neither 'clang' nor 'gcc' are installed. Please install Xcode Command Line Tools to continue."
65
+ fi
66
+ exit 1
67
+ fi
68
+
69
+ # Try to compile a simple C++ program which imports some standard libraries
70
+ # to ensure that the compiler is working correctly.
71
+ $CXX dummy.cc || {
72
+ echo "❌ Failed to find the standard C++ library. Make sure you have a working C++ compiler installed."
73
+ exit 1
74
+ }
75
+
76
+ # To be available in the 'install' phase.
77
+ # node-gyp will use these environment variables to generate the
78
+ # correct Makefile.
79
+ rm -f .reboot_cc_env .reboot_cxx_env
80
+ echo "$CC" >> .reboot_cc_env
81
+ echo "$CXX" >> .reboot_cxx_env
82
+ fi
83
+
84
+ curl -s -L "$TAR_URL" | tar -xzf -
85
+
86
+ DOWNLOADED_PYTHON=$(echo $(pwd)/python/bin/python3)
87
+
88
+ # To be available in the 'install' phase.
89
+ rm -f .reboot_python_env
90
+ echo "$DOWNLOADED_PYTHON" >> .reboot_python_env
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const REBOOT_VERSION = "0.26.0";
1
+ export declare const REBOOT_VERSION = "0.27.0";
package/version.js CHANGED
@@ -1 +1 @@
1
- export const REBOOT_VERSION = "0.26.0";
1
+ export const REBOOT_VERSION = "0.27.0";