Skip to content

Commit a9a1841

Browse files
authored
Merge pull request #3989 from conan-io/release/2.12
Sync develop2 with Release/2.12
2 parents 505cdf9 + 0bd1219 commit a9a1841

File tree

9 files changed

+101
-11
lines changed

9 files changed

+101
-11
lines changed

changelog.rst

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Changelog
33

44
For a more detailed description of the major changes that Conan 2 brings, compared with Conan 1.X, please read :ref:`whatsnew`
55

6+
2.12.2 (12-Feb-2025)
7+
--------------------
8+
9+
- Fix: Fix default name and let cycloneDX define a custom name. `#17760 <https://github.com/conan-io/conan/pull/17760>`_ . Docs `here <https://github.com/conan-io/docs/pull/3983>`__
10+
- Fix: Add cycloneDX `add_tests` and `add_build` parameters. `#17760 <https://github.com/conan-io/conan/pull/17760>`_ . Docs `here <https://github.com/conan-io/docs/pull/3983>`__
11+
- Bugfix: Fix cycloneDX tool parameters. `#17760 <https://github.com/conan-io/conan/pull/17760>`_ . Docs `here <https://github.com/conan-io/docs/pull/3983>`__
12+
613
2.12.1 (28-Jan-2025)
714
--------------------
815

conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
# The short X.Y version.
6868
version = "2.12"
6969
# The full version, including alpha/beta/rc tags.
70-
release = u'2.12.1'
70+
release = u'2.12.2'
7171

7272
dir_path = os.path.dirname(os.path.realpath(__file__))
7373
if not os.path.exists(os.path.join(dir_path, "versions.json")):

examples/tools.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ Conan recipe tools examples
1313
tools/autotools/autotools
1414
tools/scm/git/capture_scm/git_capture_scm
1515
tools/microsoft/msbuild
16-
tools/system/package_manager
16+
tools/system/system

examples/tools/system/system.rst

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. _examples_system:
2+
3+
4+
System Packages
5+
===============
6+
7+
8+
.. toctree::
9+
:maxdepth: 2
10+
11+
12+
system_package/package_manager
13+
system_package/consuming_system_packages
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.. _examples_tools_system_consuming_system_packages:
2+
3+
Consuming system requirements only when building a package
4+
==========================================================
5+
6+
In some cases, you may want to consume system requirements only when building a package, but not when installing it.
7+
It can be useful when you want to build a package in a CI/CD pipeline, but you don't want to run the system package
8+
manager when installing the Conan package in a different environment.
9+
For those cases, there are few approaches that can be used to achieve this goal.
10+
11+
12+
Consume a Conan package wrapper for a system package as build requirement
13+
-------------------------------------------------------------------------
14+
15+
In this approach, you can use a Conan package for a :ref:`wrapped system package<examples_tools_system_package_manager>`.
16+
Then, the package can be consumed regularly by the method
17+
:ref:`build_requirements()<reference_conanfile_methods_build_requirements>`.
18+
19+
.. code-block:: python
20+
21+
from conan import ConanFile
22+
23+
class MyPackage(ConanFile):
24+
name = "mypackage"
25+
settings = "os", "compiler", "build_type", "arch"
26+
27+
def build_requirements(self):
28+
self.tool_requires("ncurses/system")
29+
30+
...
31+
32+
This ensures that downstream consumers of the package *mypackage* will not directly invoke the system
33+
package manager (e.g., apt-get). Only the direct package consumer of the system wrap package for ``ncurses``
34+
will execute the system package manager when building the package.
35+
36+
Centralizing and wrapping ``ncurses`` in a separated recipe makes it reusable across multiple cases and is
37+
good practice to avoid code duplication.
38+
39+
40+
Consume the system package directly in the build() method
41+
---------------------------------------------------------
42+
43+
In case wanting to run the system package manager only when building the package, but not having a Conan package to
44+
wrap the system library information, it's possible to run the system package manager in the **build()** method:
45+
46+
.. code-block:: python
47+
48+
from conan import ConanFile
49+
from conan.tools.system import package_manager
50+
51+
class MyPackage(ConanFile):
52+
settings = "os", "compiler", "build_type", "arch"
53+
...
54+
55+
def build(self):
56+
if self.settings.os == "Linux":
57+
apt = package_manager.Apt(self)
58+
apt.install(["libncurses-dev"], update=True, check=True)
59+
60+
This way, the system package manager will be called only when building the package, not when installing it.
61+
There is the advantage of not needed to create a separated Conan package to wrap the system library information,
62+
this is a much simpler case, when only a single recipe need to install the system package.
63+
64+
Still, this approach may lead to code duplication if multiple recipes consume the same system package.
65+
It is recommended to use this method sparingly and only for well-contained cases.

reference/binary_model/custom_compatibility.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,14 @@ The ``core.package_id:default_xxx`` configurations defined in ``global.conf`` ca
103103
core.package_id:default_python_mode: By default, 'minor_mode'
104104
core.package_id:default_unknown_mode: By default, 'semver_mode'
105105
106+
These confs affect how :ref:`the package id<reference_binary_model_package_id>` is calculated, so changing them will affect
107+
your generated binaries. It's thus recommended that they stay consistent across your organization.
108+
106109
.. note::
107110

108111
**Best practices**
109112

110-
It is strongly recommended that the ``core.package_id:default_xxx`` should be global, consistent and immutable accross organizations. It can be confusing to change these defaults for different projects or teams, because it will result in missing binaries.
113+
It is strongly recommended that the ``core.package_id:default_xxx`` should be global, consistent and immutable across organizations. It can be confusing to change these defaults for different projects or teams, because it will result in missing binaries.
111114

112115
It should also be consistent and shared with the consumers of generated packages if those packages are
113116
shared outside the organization, in that case sharing the ``global.conf`` file via ``conan config install``

reference/commands/install.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ It is possible to also invoke the package recipes ``deploy()`` method with the `
148148
# Execute deploy() method only for "pkg" (any version) recipes
149149
$ conan install --requires=pkg/0.1 --deployer-package=pkg/*
150150
151-
The ``--deployer-package`` argument is a pattern and accept multiple values, all package references matching any of the defined patterns will execute its ``deploy()`` method. The ``--deployer-folder`` argument will also affect the output location of this deployment. See the :ref:`deploy() method<reference_conanfile_methods_deploy>`.
151+
The ``--deployer-package`` argument is a pattern and accepts multiple values, all package references matching any of the defined patterns will execute its ``deploy()`` method.
152+
This includes negated patterns, where for example ``--deployer-package=~pkg/*`` will execute the ``deploy()`` method for all packages except for that of the ``pkg`` recipe.
153+
The ``--deployer-folder`` argument will also affect the output location of this deployment. See the :ref:`deploy() method<reference_conanfile_methods_deploy>`.
152154

153155
If multiple deployed packages deploy to the same location, it is their responsibility to not mutually overwrite their binaries if they have the same filenames. For example if multiple packages ``deploy()`` a file called "License.txt", each recipe is responsible for creating an intermediate folder with the package name and/or version that makes it unique, so other recipes ``deploy()`` method do not overwrite previously deployed "License.txt" files.
154156

reference/tools/sbom.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ CycloneDX
2525
Conan supports `CycloneDX <https://cyclonedx.org/>`_ out-of-the-box, which is one of the most widely used standards for SBOMs.
2626

2727
The CycloneDX tool is available in the ``conan.tools.sbom.cyclonedx`` module.
28-
It provides the ``cyclonedx_1_4`` function which receives a Conan dependency graph
29-
(usually a :ref:`conanfile.subgraph <conan_conanfile_attribute_other_subgraph>`) and returns a dictionary with the SBOM data in the CycloneDX 1.4 format.
28+
It provides the ``cyclonedx_1_4`` function which receives a ``conanfile`` and returns a dictionary with the SBOM data in
29+
the CycloneDX 1.4 JSON format.
3030

3131
.. currentmodule:: conan.tools.sbom.cyclonedx
3232
.. autofunction:: cyclonedx_1_4
@@ -35,7 +35,7 @@ Using this feature is as simple as implementing a :ref:`hook <reference_extensio
3535
which uses this tool to create the SBOM and stores it in the appropriate location.
3636

3737
Usage examples
38-
^^^^^^^^^^^^^^
38+
~~~~~~~~~~~~~~
3939

4040
Let's look at two examples:
4141

@@ -52,7 +52,7 @@ In the example, we save the generated sbom in the package metadata folder to kee
5252
from conan.tools.sbom.cyclonedx import cyclonedx_1_4
5353
5454
def post_package(conanfile, **kwargs):
55-
sbom_cyclonedx_1_4 = cyclonedx_1_4(conanfile.subgraph)
55+
sbom_cyclonedx_1_4 = cyclonedx_1_4(conanfile)
5656
metadata_folder = conanfile.package_metadata_folder
5757
file_name = "sbom.cdx.json"
5858
with open(os.path.join(metadata_folder, file_name), 'w') as f:
@@ -77,7 +77,7 @@ has easy access to the SBOM.
7777
from conan.tools.sbom.cyclonedx import cyclonedx_1_4
7878
7979
def post_generate(conanfile, **kwargs):
80-
sbom_cyclonedx_1_4 = cyclonedx_1_4(conanfile.subgraph)
80+
sbom_cyclonedx_1_4 = cyclonedx_1_4(conanfile)
8181
generators_folder = conanfile.generators_folder
8282
file_name = "sbom.cdx.json"
8383
os.mkdir(os.path.join(generators_folder, "sbom"))
@@ -89,8 +89,8 @@ has easy access to the SBOM.
8989
Both hooks can coexist in such a way that we can generate the SBOMs for our application and our dependencies separately.
9090
This can greatly assist us in conducting continuous analysis of our development process and ensuring software quality.
9191

92-
Conan
93-
^^^^^
92+
Generating a Conan-based SBOM
93+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9494

9595
Instead of using a standard, we can take a "Conan-based approach". Thanks to the ``conanfile.subgraph.serialize()``
9696
function, we can directly obtain information about the dependencies of our package.

0 commit comments

Comments
 (0)