Help: "expression failed to parse, unknown error" when importing

I’m trying to import sox, an audio library. I’ve created a directory SwiftSox in dev_swift that’s almost identical to SwiftCV. However, SwiftCV works, whilst SwiftSox gives “expression failed to parse, unknown error”. You can see this if you try to run sox_integration_example.ipynb. There’s also tests in the package, and swift test works just fine. It’s only importing that fails.

@pcuenq has looked too and noticed that taking the working module from SPM and loading it manually into the notebook fails with the same error.

Can anyone try to see what’s going on here? @marcrasi @saeta I think someone has already reported a similar issue with Vapor. I’d really like to show this in the next lesson but this is blocking me from progress.

Yup I had same error with Vapor and fixed it, but this is swift-jupyter fix, please see details here.
Let me check SwiftSox, maybe it has different problem, though.

UPD: Yes, it works with this swift-juputer fix. I can import SwiftSox and call InitSox() w/o error (had to make it public, though :slight_smile:) Try patching your swift_kernel.py with my fix as a temporary workaround?

2 Likes

Awesome, @vova. I didn’t think about trying to decode the .swiftmodule file, turns out it’s just an sqlite database?

.build/build.db is sqlite db, yes!
I think another possibility is to parse all *.swiftdeps files to figure out required modulemaps… but I don’t see how one can get list of all *.swiftdeps files other than with glob (which I don’t like).

What’s wrong with glob ?

Nothing really wrong… just doesn’t feel right or safe enough to me :slight_smile: It feels better to have a way to derive a file path from some rule or config than just to search files.
Hmm, the rule seems to be that .swiftdeps is generated for each .swift file.
Anywat, processing each .swiftdeps file and combining the final deps list will be a bit harder than just looking up in build.db, and .swiftdeps contain system dependencies too, so it’s not better :frowning: