BinDeps.jl icon indicating copy to clipboard operation
BinDeps.jl copied to clipboard

Dependency on executables

Open iamed2 opened this issue 8 years ago • 10 comments

Sometimes a package depends on an executable file, not a library.

While package providers can install dependencies in the same manner, find_library would need to be substituted with an appropriate find_executable function (e.g. "an executable is installed if which or where <exec_name> returns a file or it's in deps/usr/bin" or something like that). deps.jl would maybe also set the path of the executable in a variable. There would then be executable_dependency in place of library_dependency.

I'm keen to write this and submit a PR unless anyone has any suggestions or objections.

iamed2 avatar Apr 27 '16 16:04 iamed2

Makes sense to me. Like for libraries, you may also want to accept a validate function which would be called with the path to the executable, and return a boolean indicating whether the executable fits the bill.

nalimilan avatar Apr 27 '16 17:04 nalimilan

  1. I didn't know that existed, cool
  2. Definitely!

iamed2 avatar Apr 27 '16 17:04 iamed2

Sounds like a good idea, would be happy to review something like this. One thing to note is that which isn't always installed by default on e.g. minimal Fedora containers, so ideally there should be some sort of fallback - "find_executable cannot work without having which installed" or something. Manually crawling PATH sounds like more trouble than it's worth.

tkelman avatar Apr 27 '16 17:04 tkelman

Would find be installed? Could use that to crawl PATH.

iamed2 avatar Apr 27 '16 17:04 iamed2

If which isn't available, do we at least have a way of trying to run the command using only its name, e.g. via /bin/sh? Else, we could simply act as if the executable was missing, i.e. build the sources, so that we know where the binary is.

nalimilan avatar Apr 27 '16 17:04 nalimilan

/usr/bin/env foo maybe? depends whether executing with no arguments is expected to work meaningfully

tkelman avatar Apr 27 '16 17:04 tkelman

We could have the validate function run even if which wasn't installed, and let the user determine what is a valid "no-op" call.

iamed2 avatar Apr 27 '16 17:04 iamed2

We could have the validate function run even if which wasn't installed, and let the user determine what is a valid "no-op" call.

The problem is, validate should be able to run the executable very easily, without a special cases. Else, package authors won't test that path (since they don't use weird systems) and it will be broken too often. So validate should always be passed one argument which can be handled in a single code path, e.g. by calling run on it after adding some additional arguments.

nalimilan avatar Apr 27 '16 18:04 nalimilan

I booted a VM with a minimal Fedora install (no extras, not even the Standard ones) and it came with which in /usr/bin.

iamed2 avatar Apr 28 '16 16:04 iamed2

It's docker containers where I've seen it missing and need to be manually installed (to be able to build Julia).

tkelman avatar Apr 28 '16 16:04 tkelman