Findlib

Name

Findlib -- [Module for package management]

SIGNATURE

module Findlib :
  sig
    val package_directory : string -> string
    val package_property : string list -> string -> string -> string
    val package_ancestors : string list -> string -> string list
    val package_deep_ancestors : string list -> string list -> string list
    val default_location : unit -> string

    (* Note: This signature is incomplete. See findlib.mli for the
     * full signature.
     *)

  end

PACKAGING

The Findlib module is part of the "findlib" package. In order to link it in, it is sufficient to link "findlib" in, e.g.

ocamlfind ocamlc options -package findlib -linkpkg options

There are archives for the bytecode compiler and for the native compiler; for single-threaded and for multi-threaded applications, and there is a special addition for toploops.

DESCRIPTION

The Findlib module is the primary interface of the findlib library. It contains functions to lookup packages, to interpret META[File that specifies metainformation of OCaml packages] files, and to determine the ancestors of packages.

Findlib.package_directory pkg

val package_directory : string -> string

Gets the absolute path of the directory where the package pkg is stored. The exception Not_found is raised if the package could not be found. Other exceptions may occur as file I/O is done.

Findlib.package_property predicates pkg variable

val package_property : string list -> string -> string -> string

Determines the value of the variable defined in the META[File that specifies metainformation of OCaml packages] file of package pkg with the given set of predicates. The exception Not_found is raised if the package or the variable could not be found. Other exceptions may occur as file I/O is done.

Examples

Get the value of the "requires" variable of package "p" with an empty set of predicates:

Findlib.package_property [] "p" "requires"

Get the value of the "archive" variable of package "p" for multi-threaded bytecode applications:

Findlib.package_property [ "mt"; "byte" ] "p" "archive"

Findlib.package_ancestors predicates pkg

val package_ancestors : string list -> string -> string list

Determines the direct ancestors of package pkg for the set of predicates. The returned list has no specific order. The exception Not_found is raised if the package could not be found. The exception Failure is raised if one of the ancestors could not be found, or if a circular dependency has been detected. Other exceptions may occur as file I/O is done.

Findlib.package_deep_ancestors predicates pkglist

val package_deep_ancestors : string list -> string list -> string list

Determines the list of direct or indirect ancestors of the packages in pkglist for the set of predicates. The returned list is topologically sorted. The exception Not_found is raised if the package could not be found. The exception Failure is raised if one of the ancestors could not be found, or if a circular dependency has been detected. Other exceptions may occur as file I/O is done.

Findlib.default_location ()

val default_location : unit -> string

Gets the default location where new packages will be installed.