Personal tools

Capri

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (Typos)
(Explained the private build mode)
Line 3: Line 3:
 
Capri (abbreviation of CAbal PRIvate) is a wrapper program on top of [http://hackage.haskell.org/package/cabal-install cabal-install] to operate it in project-private mode. In this mode, there is no global or user package databases; only one package database is defined, private to the project, located under the root directory of a project.
 
Capri (abbreviation of CAbal PRIvate) is a wrapper program on top of [http://hackage.haskell.org/package/cabal-install cabal-install] to operate it in project-private mode. In this mode, there is no global or user package databases; only one package database is defined, private to the project, located under the root directory of a project.
   
Capri is mainly intended for use with projects organized as Cabal packages targeting executables rather than just libraries.
+
Capri is mainly intended for use with projects organized as Cabal packages targeting executables rather than just libraries. Capri is intended for use with [http://haskell.org/ghc Glasgow Haskell Compiler] only as it depends on certain its features. It is also recommended to use [http://hackage.haskell.org/package/cabal-install cabal-install] of recent versions (as of July 2010, the most recent version is 0.8.2).
  +
  +
==Introduction==
  +
  +
A situation is possible, when a local (global or user or both) Cabal packages database contains a package of the same name, but of several versions. Over time, other packages may be installed, depending on various versions of that package. Bad things happen when a new package is to be built, depending on other packages which in turn depend on different versions of the package mentioned first.
  +
  +
While such situation may be cured by careful tracing of dependencies, removal of old versions of packages, and rebuilding of new packages, there is a way to avoid it from the beginning. For each package, create a private database of packages it depends upon. This makes practical sense mainly for packages targeting statically linked executables, ensuring a clean build environment. Other than this, private building may be used for test builds of library packages as well, but it is not recommended to use libraries built privately together in other packages.
  +
  +
The [http://haskell.org/ghc Glasgow Haskell Compiler] uses the [http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/packages.html#ghc-package-path GHC_PACKAGE_PATH] environment variable to describe the location of Haskell packages database. A typical configuration of such database consists of global and user databases. Default locations of these databases are known to the compiler even when the variable is not set.
  +
  +
It is however possible to make GHC not to use any of these databases, and point it to an alternative location instead. In order to do this, the variable has to contain a single path, and not to be terminated with a path delimiter (colon or semicolon, depending on Unix/Windows platrorm). This is how project-private build is achieved at GHC level. Cabal-install in turn requires several options to be specified, to restrict itself to using only private packages database to look for installed packages, and the installation directory prefix which is also local to a project.
   
 
==Source Location==
 
==Source Location==

Revision as of 12:41, 5 July 2010

Contents

1 Synopsis

Capri (abbreviation of CAbal PRIvate) is a wrapper program on top of cabal-install to operate it in project-private mode. In this mode, there is no global or user package databases; only one package database is defined, private to the project, located under the root directory of a project.

Capri is mainly intended for use with projects organized as Cabal packages targeting executables rather than just libraries. Capri is intended for use with Glasgow Haskell Compiler only as it depends on certain its features. It is also recommended to use cabal-install of recent versions (as of July 2010, the most recent version is 0.8.2).

2 Introduction

A situation is possible, when a local (global or user or both) Cabal packages database contains a package of the same name, but of several versions. Over time, other packages may be installed, depending on various versions of that package. Bad things happen when a new package is to be built, depending on other packages which in turn depend on different versions of the package mentioned first.

While such situation may be cured by careful tracing of dependencies, removal of old versions of packages, and rebuilding of new packages, there is a way to avoid it from the beginning. For each package, create a private database of packages it depends upon. This makes practical sense mainly for packages targeting statically linked executables, ensuring a clean build environment. Other than this, private building may be used for test builds of library packages as well, but it is not recommended to use libraries built privately together in other packages.

The Glasgow Haskell Compiler uses the GHC_PACKAGE_PATH environment variable to describe the location of Haskell packages database. A typical configuration of such database consists of global and user databases. Default locations of these databases are known to the compiler even when the variable is not set.

It is however possible to make GHC not to use any of these databases, and point it to an alternative location instead. In order to do this, the variable has to contain a single path, and not to be terminated with a path delimiter (colon or semicolon, depending on Unix/Windows platrorm). This is how project-private build is achieved at GHC level. Cabal-install in turn requires several options to be specified, to restrict itself to using only private packages database to look for installed packages, and the installation directory prefix which is also local to a project.

3 Source Location

Haskell source: http://hs-ogl-misc.googlecode.com/hg/capri/Main.hs

Hackage: TBD

4 Commands Summary

$ capri help
This program provides a wrapper over cabal-install to operate in project-private mode.

Usage: capri COMMAND [FLAGS]
   or: capri [GLOBAL FLAGS]

Global flags:
 -h --help            Show this help text
 -V --version         Print version information
    --numeric-version Print just the version number

Commands:
  bootstrap    Bootstrap private packages configuration
  list         List packages installed privately
  clone        Clone package(s) installed publicly into the private packages database
  ghc-pkg      Invoke the ghc-pkg program to run arbitrary action on private packages
  cabal        Invoke the cabal-install program to run arbitrary action on private packages
  install      Short-cut for cabal install command
  configure    Short-cut for cabal configure command
  build        Short-cut for cabal build command
  help         Help about commands

For more information about a command use
  capri COMMAND --help

Typical steps for installing Cabal packages:
  capri bootstrap
  capri clone
  capri configure
  capri build
  capri install

5 Building Executables with Capri

5.1 Bootstrapping Private Packages Database

5.2 Building and Installation

5.3 Cloning Already Compiled Packages

5.4 Importing Local Source Packages

6 Advanced Topics

6.1 Running ghc-pkg and cabal-install