-
Notifications
You must be signed in to change notification settings - Fork 710
Qualified constraints: documentation and unit tests (issue #3502) #4236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
53e3501
7bfb03c
606b160
8b74b63
32e7f28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1255,18 +1255,76 @@ Miscellaneous options | |
|
||
.. option:: --constraint=constraint | ||
|
||
Restrict solutions involving a package to a given version range. For | ||
example, ``cabal install --constraint="bar==2.1"`` will only | ||
consider install plans that do not use ``bar`` at all, or ``bar`` of | ||
version 2.1. | ||
|
||
As a special case, ``cabal install --constraint="bar -none"`` | ||
prevents ``bar`` from being used at all (``-none`` abbreviates | ||
``> 1 && < 1``); ``cabal install --constraint="bar installed"`` | ||
prevents reinstallation of the ``bar`` package; | ||
``cabal install --constraint="bar +foo -baz"`` specifies that the | ||
flag ``foo`` should be turned on and the ``baz`` flag should be | ||
turned off. | ||
Restrict solutions involving a package to given version | ||
bounds, flag settings, and other properties. For example, to | ||
consider only install plans that use version 2.1 of ``bar`` | ||
or do not use ``bar`` at all, write: | ||
|
||
:: | ||
|
||
$ cabal install --constraint="bar == 2.1" | ||
|
||
Version bounds have the same syntax as ``build-depends``. As | ||
a special case, the following prevents ``bar`` from being | ||
used at all: | ||
|
||
:: | ||
|
||
# Note: this is just syntax sugar for '> 1 && < 1', and is | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, why do we use this arbitrary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Patches accepted :) But
We could change this as long as it is actually impossible to have negative version numbers :) |
||
# supported by build-depends. | ||
$ cabal install --constraint="bar -none" | ||
|
||
You can also specify flag assignments: | ||
|
||
:: | ||
|
||
# Require bar to be installed with the foo flag turned on and | ||
# the baz flag turned off. | ||
$ cabal install --constraint="bar +foo -baz" | ||
|
||
To specify multiple constraints, you may pass the | ||
``constraint`` option multiple times. | ||
|
||
There are also some more specialized constraints, which most people | ||
don't generally need: | ||
|
||
:: | ||
|
||
# Require that a version of bar be used that is already installed in | ||
# the global package database. | ||
$ cabal install --constraint="bar installed" | ||
|
||
# Require the local source copy of bar to be used. | ||
# (Note: By default, if we have a local package we will | ||
# automatically use it, so it will generally not be necessary to | ||
# specify this.) | ||
$ cabal install --constraint="bar source" | ||
|
||
# Require that bar have test suites and benchmarks enabled. | ||
$ cabal install --constraint="bar test" --constraint="bar bench" | ||
|
||
By default, constraints only apply to build dependencies | ||
(``build-depends``), build dependencies of build | ||
dependencies, and so on. Constraints normally do not apply to | ||
dependencies of the ``Setup.hs`` script of any package | ||
(``setup-depends``) nor do they apply to build tools | ||
(``build-tool-depends``) or the dependencies of build | ||
tools. To explicitly apply a constraint to a setup or build | ||
tool dependency, you can add a qualifier to the constraint as | ||
follows: | ||
|
||
:: | ||
|
||
# Example use of the 'setup' qualifier. This constraint | ||
# applies to package bar when it is a dependency of the | ||
# Setup.hs script of package foo. | ||
$ cabal install --constraint="foo:setup.bar == 1.0" | ||
|
||
# Example use of the 'exe' (executable build tool) | ||
# qualifier. This constraint applies to package baz when it | ||
# is a dependency of the build tool bar being used to | ||
# build package foo. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to build |
||
$ cabal install --constraint="foo:bar:exe.baz == 1.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I have to say, if I saw this in a source code file, I would definitely have a hard time telling what the bar is supposed to mean. |
||
|
||
.. option:: --preference=preference | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -361,7 +361,7 @@ dontUpgradeNonUpgradeablePackages params = | |
where | ||
extraConstraints = | ||
[ LabeledPackageConstraint | ||
(PackageConstraint (scopeToplevel pkgname) PackagePropertyInstalled) | ||
(PackageConstraint (ScopeAnyQualifier pkgname) PackagePropertyInstalled) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, did we seriously apply this to top-level only before? Worth a comment! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ConstraintSourceNonUpgradeablePackage | ||
| Set.notMember (mkPackageName "base") (depResolverTargets params) | ||
-- If you change this enumeration, make sure to update the list in | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs another newline after the "::" to form a code block.