lwille/node-gphoto2

Include gphoto2 binary as dependency

positlabs opened this issue · 9 comments

I've seen other libs that bundle binary dependencies in npm packages. This makes it much simpler to build distributable apps (e.g. electron)

https://www.npmjs.com/package/bin-wrapper

Once binwrapper is configured, you can call the bin like this:

bin.run(['--version'], function (err) {
    console.log('gphoto is working');
});

This change would require removing this detection script, since installation would be handled internally:

Also, the script tries to detect wether libgphoto2 is correctly installed

It would still be nice to have the option to use a locally installed instance of gphoto, so we should expose a method to set the bin path at runtime.

Gphoto.setBinPath('/path/to/bin')

I’m not sure if I understand correctly.
How does it help to detect whether libgphoto2 (a build dependency) is installed?
Feel free to implement and submit a pull request.

Ideally it would pull the bins from a list of precompiled packages (which include everything needed to run gphoto2). Now that I look, I'm not sure that's out there.

For example, ffmpeg has precompiled bins for various environments, https://ffmpeg.zeranoe.com/builds/

I did find this repo, but it's not ready for production: https://github.com/gphoto/gphoto-suite

Sija commented

@positlabs this lib was build specifically to avoid using binary distribution and concentrate on native bindings instead, what's the point of having gphoto binary when you can use bindings? And if so, what's the problem of installing gphoto manually?

I have no issue installing ghoto manually, except it limits me to only using it on my own machines. If I want to distribute an app for other users, I can't expect them to go through that process.

Sija commented

Well, IMO it's out of scope of this library either. It provides binding to libgphoto2, that's its sole purpose and responsibility.

Got it.

Do you have any advice about how I could package the binaries for distribution?

Sija commented

@positlabs bundle them along with your project and use the appropriate during runtime ;) seriously though, I have no one-stop, have-it-all-done solution, sorry.

... or distribute your app with an installer that installs dependencies for all possible platforms.

Good idea though to pre-build the bindings for a set of platforms; this saves install time but won’t help with the libgphoto2 dependency (and its dependencies, like libusb). Also would it invite all sorts of issues with incompatible versions, thus opening the gates to dependency hell.

Would be nice if I could use a docker container for this...