Skip to content

Commit

Permalink
fix prereleases (#3454)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Nov 7, 2023
1 parent d8c7929 commit 562b017
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
22 changes: 20 additions & 2 deletions reference/conanfile/attributes/requirements.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,28 @@ Accepted expressions would be:
- 1.1, 1.2, 2.0


If pre-releases are activated, like defining configuration ``core.version_ranges:resolve_prereleases=True``:

.. list-table::
:widths: 25 25 50
:header-rows: 1

* - Expression
- Versions in range
- Versions outside of range
* - [>=1.0 <2]
- 1.0.0-pre.1, 1.0.0, 1.0.1, 1.1, 1.2.3
- 0.2, 2.0-pre.1, 2.0, 2.1, 3.0
* - [<3.2.1]
- 0.1, 1.2, 1.8-beta.1, 2.0-alpha.2, 2.4, 3.1.1
- 3.2.1-pre.1, 3.2.1, 3.2.2, 3.3
* - [>2.0]
- 2.1-pre.1, 2.1, 2.2, 3.1, 14.2
- 1.1, 1.2, 2.0-pre.1, 2.0

.. seealso::

- Check <MISSING PAGE> version_ranges if you want to learn more about version ranges.
- Check <MISSING PAGE> requires() conanfile.py method.
- Check :ref:`tutorial_version_ranges_expressions` version_ranges tutorial section


tool_requires
Expand Down
7 changes: 5 additions & 2 deletions tutorial/versioning/version_ranges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ It is also possible to apply multiple conditions with the OR operator, like ``re
but this kind of complex expressions is not recommended in practice and should only be used in very extreme cases.

Finally, note that pre-releases are not resolved by default. The way to include them in the range is to
explicitly define it like: ``requires = "pkg/[>1- <2.0]"`` or more explicitly with
``requires = "pkg/[>1 <2, include_prerelease=True]"``. This will include 1.5.1-pre1, but exclude 2.0-pre1.
explicitly define it like ``requires = "pkg/[>=1 <2, include_prerelease]"``. This will include 1.0-pre.1 and 1.5.1-pre1, but exclude 2.0-pre1.

While it is possible to hardcode the ``include_prerelease`` in the ``requires`` version, it is not recommended in the general
case. Pre-releases should be opt-in, and it should be controlled by the user, who is the one to decide if they want to
use pre-releases or not. This can be done defining the configuration ``core.version_ranges:resolve_prereleases``.


For more information about valid range expressions go to :ref:`Requires reference <version_ranges_reference>`

0 comments on commit 562b017

Please sign in to comment.