From 12556514d770ff7ece88688408820377abe74504 Mon Sep 17 00:00:00 2001 From: danimtb Date: Thu, 20 May 2021 17:34:47 +0200 Subject: [PATCH 1/3] Docs for tools.rename() --- reference/conanfile/tools/files.rst | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/reference/conanfile/tools/files.rst b/reference/conanfile/tools/files.rst index 8c493c4c55f..a96f50d95a8 100644 --- a/reference/conanfile/tools/files.rst +++ b/reference/conanfile/tools/files.rst @@ -11,7 +11,7 @@ conan.tools.files.patch() .. code-block:: python def patch(conanfile, base_path=None, patch_file=None, patch_string=None, - strip=0, fuzz=False, **kwargs): + strip=0, fuzz=False, **kwargs): Applies a diff from file (*patch_file*) or string (*patch_string*) in *base_path* directory. If *base_path* is not passed it is applied in the current directory. @@ -67,3 +67,23 @@ Example of ``conandata.yml`` with different patches for different versions: "1.12.0": - patch_file: "patches/0001-buildflatbuffers-cmake.patch" base_path: "source_subfolder" + +conan.tools.rename() +-------------------- + +.. code-block:: python + + def rename(conanfile, src, dst) + +Utility functions to rename a file or folder *src* to *dst* with retrying. ``os.rename()`` frequently raises "Access is denied" exception on +windows. This function renames file or folder using :command:`robocopy` to avoid the exception on Windows. + +.. code-block:: python + + def source(self): + tools.rename(self, "lib-sources-abe2h9fe", "sources") # renaming a folder + +Parameters: + - **conanfile**: Conanfile object. + - **src** (Required): Path to be renamed. + - **dst** (Required): Path to be renamed to. From 6f3360cbff626587939bf7d656ceb9ba6226cbae Mon Sep 17 00:00:00 2001 From: danimtb Date: Thu, 20 May 2021 17:36:12 +0200 Subject: [PATCH 2/3] fix --- reference/conanfile/tools/files.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/conanfile/tools/files.rst b/reference/conanfile/tools/files.rst index a96f50d95a8..4078ec7bd7f 100644 --- a/reference/conanfile/tools/files.rst +++ b/reference/conanfile/tools/files.rst @@ -84,6 +84,6 @@ windows. This function renames file or folder using :command:`robocopy` to avoid tools.rename(self, "lib-sources-abe2h9fe", "sources") # renaming a folder Parameters: - - **conanfile**: Conanfile object. - - **src** (Required): Path to be renamed. - - **dst** (Required): Path to be renamed to. + - **conanfile**: Conanfile object. + - **src** (Required): Path to be renamed. + - **dst** (Required): Path to be renamed to. From b9be5609e8d0a1313e92068597d7c1fd6e5f7e48 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 21 May 2021 12:46:27 +0200 Subject: [PATCH 3/3] Update reference/conanfile/tools/files.rst --- reference/conanfile/tools/files.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reference/conanfile/tools/files.rst b/reference/conanfile/tools/files.rst index 4078ec7bd7f..225bba28e72 100644 --- a/reference/conanfile/tools/files.rst +++ b/reference/conanfile/tools/files.rst @@ -75,8 +75,7 @@ conan.tools.rename() def rename(conanfile, src, dst) -Utility functions to rename a file or folder *src* to *dst* with retrying. ``os.rename()`` frequently raises "Access is denied" exception on -windows. This function renames file or folder using :command:`robocopy` to avoid the exception on Windows. +Utility functions to rename a file or folder *src* to *dst*. On Windows, it is very common that ``os.rename()`` raises an "Access is denied" exception, so this tool uses:command:`robocopy` if available. If that is not the case, or the rename is done in a non-Windows machine, it falls back to the ``os.rename()`` implementation. .. code-block:: python