Skip to content
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

Add docs for trim_conandata #3373

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions reference/conanfile/tools/files/basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,39 @@ Example:
def source(self):
data = self.conan_data["sources"]["mydata"]

conan.tools.files.trim_conandata()
----------------------------------

Available since: `1.61.0 <https://github.com/conan-io/conan/releases/tag/1.61.0>`_

.. code-block:: python

def trim_conandata(conanfile)


This function modifies the ``conandata.yml`` inside the exported folder in the conan
cache, if it exists, and keeps only the information related to the currently built
version.

This helper can only be used within the ``export()`` method, it raises an exception otherwise. One
application is to ensure changes in the ``conandata.yml`` file related to some versions do
not affect the generated recipe revisions of the rest.

Usage:

.. code-block:: python

from conan import ConanFile
from conan.tools.files import trim_conandata

class Pkg(ConanFile):
name = "pkg"

def export(self):
# any change to other versions in the conandata.yml
# won't affect the revision of the version that is built
trim_conandata(self)


conan.tools.files.collect_libs()
--------------------------------
Expand Down