ashvardanian / SimSIMD

Up to 200x Faster Inner Products and Vector Similarity — for Python, JavaScript, Rust, C, and Swift, supporting f64, f32, f16 real & complex, i8, and binary vectors using SIMD for both x86 AVX2 & AVX-512 and Arm NEON & SVE 📐
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
806 stars 42 forks source link

simsimd does not work with bun #46

Closed sroussey closed 5 months ago

sroussey commented 6 months ago

What version of Bun is running?

❯ bun -v 1.0.21

What platform is your computer?

❯ uname -mprs Darwin 23.2.0 arm64 arm

What steps can reproduce the bug?

install bun

bun i simsimd

test.ts:

import { inner, cosine } from "simsimd";
console.log({ inner, cosine });

bun run test.ts

What is the expected behavior?

In this simple example, show that the functions exist

What do you see instead?

❯ bun run test.ts
83 |         throw e
84 |       }
85 |     }
86 |   }
87 | 
88 |   err = new Error('Could not locate the bindings file. Tried:\n'
             ^
error: Could not locate the bindings file. Tried:
 → /Users/steve/Code/elmers/node_modules/simsimd/build/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/build/Debug/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/build/Release/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/out/Debug/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/Debug/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/out/Release/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/Release/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/build/default/simsimd.node
 → /Users/steve/Code/elmers/node_modules/simsimd/compiled/20.8.0/darwin/arm64/simsimd.node
      at bindings (/Users/steve/Code/elmers/node_modules/bindings/bindings.js:88:9)
      at /Users/steve/Code/elmers/node_modules/simsimd/javascript/simsimd.js:1:7
sroussey commented 6 months ago

See https://github.com/oven-sh/bun/issues/7986

ashvardanian commented 6 months ago

Hi @sroussey! I've heard great things about Bun, but never interacted with it. Is it supposed to run Node modules out of the box? Anything we need to change in package.json or binding.gyp?

sroussey commented 6 months ago

For now change your instructions on installation.

Add simsimd to “dependencies” AND “trustedDependencies” in package.json before bun i.

ashvardanian commented 6 months ago

@sroussey Do I understand correctly that the package becomes a dependency of itself? Could you please open a PR?

sroussey commented 6 months ago

I'm a bit sick at the moment.

Basically, bun does not run post install scripts (that would build for the current system) for security reasons, but the user can override that.

See https://bun.sh/guides/install/trusted

(Written from bed)

sroussey commented 6 months ago

I longer term solution is to pre-build using this:

https://github.com/prebuild/prebuildify (and https://github.com/prebuild/node-gyp-build).