We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[package] all: "Access is denied" in os.rename() on Windows
### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **almost all packages affected**
  * Operating System+version: **Windows 10**
  * Compiler+version: **MSVC 16**
  * Conan version: **conan 1.35.2**
  * Python version: **Python 3.8.7**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
os_build=Windows
os=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
compiler.runtime=MD
build_type=Release
```

### Steps to reproduce (Include if Applicable)

This is a known issue. Solution provided by https://github.com/conan-io/conan/pull/6774
However most recipes still use `os.rename()` and not `tools.rename()`. 

### Log
```
b2/4.2.0: Configuring sources in C:\Users\xxx\.conan\data\b2\4.2.0\_\_\source
ERROR: b2/4.2.0: Error in source() method, line 58
os.rename(extracted_dir, "source")
PermissionError: [WinError 5] Access is denied: 'build-4.2.0' -> 'source'
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `recipes/zlib/1.2.11/conanfile.py`
Content:
```
1 import os
2 from conans import ConanFile, tools, CMake
3 from conans.errors import ConanException
4 
5 
6 class ZlibConan(ConanFile):
7     name = "zlib"
8     version = "1.2.11"
9     url = "https://github.com/conan-io/conan-center-index"
10     homepage = "https://zlib.net"
11     license = "Zlib"
12     description = ("A Massively Spiffy Yet Delicately Unobtrusive Compression Library "
13                    "(Also Free, Not to Mention Unencumbered by Patents)")
14     settings = "os", "arch", "compiler", "build_type"
15     options = {"shared": [True, False], "fPIC": [True, False], "minizip": [True, False, "deprecated"]}
16     default_options = {"shared": False, "fPIC": True, "minizip": "deprecated"}
17     exports_sources = ["CMakeLists.txt", "CMakeLists_minizip.txt", "patches/**"]
18     generators = "cmake"
19     topics = ("conan", "zlib", "compression")
20 
21     @property
22     def _source_subfolder(self):
23         return "source_subfolder"
24 
25     @property
26     def _build_subfolder(self):
27         return "build_subfolder"
28 
29     def config_options(self):
30         if self.settings.os == "Windows":
31             del self.options.fPIC
32 
33     def configure(self):
34         del self.settings.compiler.libcxx
35         del self.settings.compiler.cppstd
36 
37         if self.options.shared:
38             del self.options.fPIC
39 
40         if self.options.minizip != "deprecated":
41             self.output.warn("minizip option is deprecated. Please use the new minizip/1.2.11 package")
42 
43     def package_id(self):
44         del self.info.options.minizip
45 
46     def source(self):
47         tools.get(**self.conan_data["sources"][self.version])
48         os.rename("{}-{}".format(self.name, self.version), self._source_subfolder)
49 
50     def _patch_sources(self):
51         for patch in self.conan_data["patches"][self.version]:
52             tools.patch(**patch)
53 
54         with tools.chdir(self._source_subfolder):
55             # https://github.com/madler/zlib/issues/268
56             tools.replace_in_file('gzguts.h',
57                                   '#if defined(_WIN32) || defined(__CYGWIN__)',
58                                   '#if defined(_WIN32) || defined(__MINGW32__)')
59 
60             is_apple_clang12 = self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12.0"
61             if not is_apple_clang12:
62                 for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']:
63                     tools.replace_in_file(filename,
64                                           '#ifdef HAVE_UNISTD_H    '
65                                           '/* may be set to #if 1 by ./configure */',
66                                           '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)')
67                     tools.replace_in_file(filename,
68                                           '#ifdef HAVE_STDARG_H    '
69                                           '/* may be set to #if 1 by ./configure */',
70                                           '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)')
71 
72     def build(self):
73         self._patch_sources()
74         make_target = "zlib" if self.options.shared else "zlibstatic"
75         cmake = CMake(self)
76         cmake.configure(build_folder=self._build_subfolder)
77         cmake.build(target=make_target)
78 
79     def _rename_libraries(self):
80         if self.settings.os == "Windows":
81             lib_path = os.path.join(self.package_folder, "lib")
82             suffix = "d" if self.settings.build_type == "Debug" else ""
83 
84             if self.options.shared:
85                 if self.settings.compiler == "Visual Studio":
86                     current_lib = os.path.join(lib_path, "zlib%s.lib" % suffix)
87                     os.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
88             else:
89                 if self.settings.compiler == "Visual Studio":
90                     current_lib = os.path.join(lib_path, "zlibstatic%s.lib" % suffix)
91                     os.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
92                 elif self.settings.compiler == "gcc":
93                     if self.settings.os != "Windows" or not self.settings.os.subsystem:
94                         current_lib = os.path.join(lib_path, "libzlibstatic.a")
95                         os.rename(current_lib, os.path.join(lib_path, "libzlib.a"))
96                 elif self.settings.compiler == "clang":
97                     current_lib = os.path.join(lib_path, "zlibstatic.lib")
98                     os.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
99 
100     def _extract_license(self):
101         with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)):
102             tmp = tools.load("zlib.h")
103             license_contents = tmp[2:tmp.find("*/", 1)]
104             tools.save("LICENSE", license_contents)
105 
106     def package(self):
107         self._extract_license()
108         self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
109 
110         # Copy headers
111         for header in ["*zlib.h", "*zconf.h"]:
112             self.copy(pattern=header, dst="include", src=self._source_subfolder, keep_path=False)
113             self.copy(pattern=header, dst="include", src=self._build_subfolder, keep_path=False)
114 
115         # Copying static and dynamic libs
116         if self.options.shared:
117             self.copy(pattern="*.dylib*", dst="lib", src=self._build_subfolder, keep_path=False, symlinks=True)
118             self.copy(pattern="*.so*", dst="lib", src=self._build_subfolder, keep_path=False, symlinks=True)
119             self.copy(pattern="*.dll", dst="bin", src=self._build_subfolder, keep_path=False)
120             self.copy(pattern="*.dll.a", dst="lib", src=self._build_subfolder, keep_path=False)
121         else:
122             self.copy(pattern="*.a", dst="lib", src=self._build_subfolder, keep_path=False)
123         self.copy(pattern="*.lib", dst="lib", src=self._build_subfolder, keep_path=False)
124 
125         self._rename_libraries()
126 
127     def package_info(self):
128         self.cpp_info.libs.append("zlib" if self.settings.os == "Windows" and not self.settings.os.subsystem else "z")
129         self.cpp_info.names["cmake_find_package"] = "ZLIB"
130         self.cpp_info.names["cmake_find_package_multi"] = "ZLIB"
131
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/recipes/zlib/1.2.11/conanfile.py b/recipes/zlib/1.2.11/conanfile.py
--- a/recipes/zlib/1.2.11/conanfile.py
+++ b/recipes/zlib/1.2.11/conanfile.py
@@ -44,8 +44,7 @@
         del self.info.options.minizip
 
     def source(self):
-        tools.get(**self.conan_data["sources"][self.version])
-        os.rename("{}-{}".format(self.name, self.version), self._source_subfolder)
+        tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True)
 
     def _patch_sources(self):
         for patch in self.conan_data["patches"][self.version]:
@@ -82,20 +81,20 @@
             suffix = "d" if self.settings.build_type == "Debug" else ""
 
             if self.options.shared:
-                if self.settings.compiler == "Visual Studio":
+                if self.settings.compiler == "Visual Studio" and suffix:
                     current_lib = os.path.join(lib_path, "zlib%s.lib" % suffix)
-                    os.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
+                    tools.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
             else:
                 if self.settings.compiler == "Visual Studio":
                     current_lib = os.path.join(lib_path, "zlibstatic%s.lib" % suffix)
-                    os.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
+                    tools.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
                 elif self.settings.compiler == "gcc":
                     if self.settings.os != "Windows" or not self.settings.os.subsystem:
                         current_lib = os.path.join(lib_path, "libzlibstatic.a")
-                        os.rename(current_lib, os.path.join(lib_path, "libzlib.a"))
+                        tools.rename(current_lib, os.path.join(lib_path, "libzlib.a"))
                 elif self.settings.compiler == "clang":
                     current_lib = os.path.join(lib_path, "zlibstatic.lib")
-                    os.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
+                    tools.rename(current_lib, os.path.join(lib_path, "zlib.lib"))
 
     def _extract_license(self):
         with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)):

{"golden_diff": "diff --git a/recipes/zlib/1.2.11/conanfile.py b/recipes/zlib/1.2.11/conanfile.py\n--- a/recipes/zlib/1.2.11/conanfile.py\n+++ b/recipes/zlib/1.2.11/conanfile.py\n@@ -44,8 +44,7 @@\n         del self.info.options.minizip\n \n     def source(self):\n-        tools.get(**self.conan_data[\"sources\"][self.version])\n-        os.rename(\"{}-{}\".format(self.name, self.version), self._source_subfolder)\n+        tools.get(**self.conan_data[\"sources\"][self.version], destination=self._source_subfolder, strip_root=True)\n \n     def _patch_sources(self):\n         for patch in self.conan_data[\"patches\"][self.version]:\n@@ -82,20 +81,20 @@\n             suffix = \"d\" if self.settings.build_type == \"Debug\" else \"\"\n \n             if self.options.shared:\n-                if self.settings.compiler == \"Visual Studio\":\n+                if self.settings.compiler == \"Visual Studio\" and suffix:\n                     current_lib = os.path.join(lib_path, \"zlib%s.lib\" % suffix)\n-                    os.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n+                    tools.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n             else:\n                 if self.settings.compiler == \"Visual Studio\":\n                     current_lib = os.path.join(lib_path, \"zlibstatic%s.lib\" % suffix)\n-                    os.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n+                    tools.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n                 elif self.settings.compiler == \"gcc\":\n                     if self.settings.os != \"Windows\" or not self.settings.os.subsystem:\n                         current_lib = os.path.join(lib_path, \"libzlibstatic.a\")\n-                        os.rename(current_lib, os.path.join(lib_path, \"libzlib.a\"))\n+                        tools.rename(current_lib, os.path.join(lib_path, \"libzlib.a\"))\n                 elif self.settings.compiler == \"clang\":\n                     current_lib = os.path.join(lib_path, \"zlibstatic.lib\")\n-                    os.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n+                    tools.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n \n     def _extract_license(self):\n         with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)):\n", "issue": "[package] all: \"Access is denied\" in os.rename() on Windows\n### Package and Environment Details (include every applicable attribute)\r\n  * Package Name/Version: **almost all packages affected**\r\n  * Operating System+version: **Windows 10**\r\n  * Compiler+version: **MSVC 16**\r\n  * Conan version: **conan 1.35.2**\r\n  * Python version: **Python 3.8.7**\r\n\r\n\r\n### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)\r\n```\r\n[settings]\r\nos_build=Windows\r\nos=Windows\r\narch=x86_64\r\narch_build=x86_64\r\ncompiler=Visual Studio\r\ncompiler.version=16\r\ncompiler.runtime=MD\r\nbuild_type=Release\r\n```\r\n\r\n### Steps to reproduce (Include if Applicable)\r\n\r\nThis is a known issue. Solution provided by https://github.com/conan-io/conan/pull/6774\r\nHowever most recipes still use `os.rename()` and not `tools.rename()`. \r\n\r\n### Log\r\n```\r\nb2/4.2.0: Configuring sources in C:\\Users\\xxx\\.conan\\data\\b2\\4.2.0\\_\\_\\source\r\nERROR: b2/4.2.0: Error in source() method, line 58\r\nos.rename(extracted_dir, \"source\")\r\nPermissionError: [WinError 5] Access is denied: 'build-4.2.0' -> 'source'\r\n```\r\n\n", "before_files": [{"content": "import os\nfrom conans import ConanFile, tools, CMake\nfrom conans.errors import ConanException\n\n\nclass ZlibConan(ConanFile):\n    name = \"zlib\"\n    version = \"1.2.11\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://zlib.net\"\n    license = \"Zlib\"\n    description = (\"A Massively Spiffy Yet Delicately Unobtrusive Compression Library \"\n                   \"(Also Free, Not to Mention Unencumbered by Patents)\")\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\"shared\": [True, False], \"fPIC\": [True, False], \"minizip\": [True, False, \"deprecated\"]}\n    default_options = {\"shared\": False, \"fPIC\": True, \"minizip\": \"deprecated\"}\n    exports_sources = [\"CMakeLists.txt\", \"CMakeLists_minizip.txt\", \"patches/**\"]\n    generators = \"cmake\"\n    topics = (\"conan\", \"zlib\", \"compression\")\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    @property\n    def _build_subfolder(self):\n        return \"build_subfolder\"\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n\n    def configure(self):\n        del self.settings.compiler.libcxx\n        del self.settings.compiler.cppstd\n\n        if self.options.shared:\n            del self.options.fPIC\n\n        if self.options.minizip != \"deprecated\":\n            self.output.warn(\"minizip option is deprecated. Please use the new minizip/1.2.11 package\")\n\n    def package_id(self):\n        del self.info.options.minizip\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version])\n        os.rename(\"{}-{}\".format(self.name, self.version), self._source_subfolder)\n\n    def _patch_sources(self):\n        for patch in self.conan_data[\"patches\"][self.version]:\n            tools.patch(**patch)\n\n        with tools.chdir(self._source_subfolder):\n            # https://github.com/madler/zlib/issues/268\n            tools.replace_in_file('gzguts.h',\n                                  '#if defined(_WIN32) || defined(__CYGWIN__)',\n                                  '#if defined(_WIN32) || defined(__MINGW32__)')\n\n            is_apple_clang12 = self.settings.compiler == \"apple-clang\" and tools.Version(self.settings.compiler.version) >= \"12.0\"\n            if not is_apple_clang12:\n                for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']:\n                    tools.replace_in_file(filename,\n                                          '#ifdef HAVE_UNISTD_H    '\n                                          '/* may be set to #if 1 by ./configure */',\n                                          '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)')\n                    tools.replace_in_file(filename,\n                                          '#ifdef HAVE_STDARG_H    '\n                                          '/* may be set to #if 1 by ./configure */',\n                                          '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)')\n\n    def build(self):\n        self._patch_sources()\n        make_target = \"zlib\" if self.options.shared else \"zlibstatic\"\n        cmake = CMake(self)\n        cmake.configure(build_folder=self._build_subfolder)\n        cmake.build(target=make_target)\n\n    def _rename_libraries(self):\n        if self.settings.os == \"Windows\":\n            lib_path = os.path.join(self.package_folder, \"lib\")\n            suffix = \"d\" if self.settings.build_type == \"Debug\" else \"\"\n\n            if self.options.shared:\n                if self.settings.compiler == \"Visual Studio\":\n                    current_lib = os.path.join(lib_path, \"zlib%s.lib\" % suffix)\n                    os.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n            else:\n                if self.settings.compiler == \"Visual Studio\":\n                    current_lib = os.path.join(lib_path, \"zlibstatic%s.lib\" % suffix)\n                    os.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n                elif self.settings.compiler == \"gcc\":\n                    if self.settings.os != \"Windows\" or not self.settings.os.subsystem:\n                        current_lib = os.path.join(lib_path, \"libzlibstatic.a\")\n                        os.rename(current_lib, os.path.join(lib_path, \"libzlib.a\"))\n                elif self.settings.compiler == \"clang\":\n                    current_lib = os.path.join(lib_path, \"zlibstatic.lib\")\n                    os.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n\n    def _extract_license(self):\n        with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)):\n            tmp = tools.load(\"zlib.h\")\n            license_contents = tmp[2:tmp.find(\"*/\", 1)]\n            tools.save(\"LICENSE\", license_contents)\n\n    def package(self):\n        self._extract_license()\n        self.copy(\"LICENSE\", src=self._source_subfolder, dst=\"licenses\")\n\n        # Copy headers\n        for header in [\"*zlib.h\", \"*zconf.h\"]:\n            self.copy(pattern=header, dst=\"include\", src=self._source_subfolder, keep_path=False)\n            self.copy(pattern=header, dst=\"include\", src=self._build_subfolder, keep_path=False)\n\n        # Copying static and dynamic libs\n        if self.options.shared:\n            self.copy(pattern=\"*.dylib*\", dst=\"lib\", src=self._build_subfolder, keep_path=False, symlinks=True)\n            self.copy(pattern=\"*.so*\", dst=\"lib\", src=self._build_subfolder, keep_path=False, symlinks=True)\n            self.copy(pattern=\"*.dll\", dst=\"bin\", src=self._build_subfolder, keep_path=False)\n            self.copy(pattern=\"*.dll.a\", dst=\"lib\", src=self._build_subfolder, keep_path=False)\n        else:\n            self.copy(pattern=\"*.a\", dst=\"lib\", src=self._build_subfolder, keep_path=False)\n        self.copy(pattern=\"*.lib\", dst=\"lib\", src=self._build_subfolder, keep_path=False)\n\n        self._rename_libraries()\n\n    def package_info(self):\n        self.cpp_info.libs.append(\"zlib\" if self.settings.os == \"Windows\" and not self.settings.os.subsystem else \"z\")\n        self.cpp_info.names[\"cmake_find_package\"] = \"ZLIB\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"ZLIB\"\n", "path": "recipes/zlib/1.2.11/conanfile.py"}], "after_files": [{"content": "import os\nfrom conans import ConanFile, tools, CMake\nfrom conans.errors import ConanException\n\n\nclass ZlibConan(ConanFile):\n    name = \"zlib\"\n    version = \"1.2.11\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://zlib.net\"\n    license = \"Zlib\"\n    description = (\"A Massively Spiffy Yet Delicately Unobtrusive Compression Library \"\n                   \"(Also Free, Not to Mention Unencumbered by Patents)\")\n    settings = \"os\", \"arch\", \"compiler\", \"build_type\"\n    options = {\"shared\": [True, False], \"fPIC\": [True, False], \"minizip\": [True, False, \"deprecated\"]}\n    default_options = {\"shared\": False, \"fPIC\": True, \"minizip\": \"deprecated\"}\n    exports_sources = [\"CMakeLists.txt\", \"CMakeLists_minizip.txt\", \"patches/**\"]\n    generators = \"cmake\"\n    topics = (\"conan\", \"zlib\", \"compression\")\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    @property\n    def _build_subfolder(self):\n        return \"build_subfolder\"\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n\n    def configure(self):\n        del self.settings.compiler.libcxx\n        del self.settings.compiler.cppstd\n\n        if self.options.shared:\n            del self.options.fPIC\n\n        if self.options.minizip != \"deprecated\":\n            self.output.warn(\"minizip option is deprecated. Please use the new minizip/1.2.11 package\")\n\n    def package_id(self):\n        del self.info.options.minizip\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version], destination=self._source_subfolder, strip_root=True)\n\n    def _patch_sources(self):\n        for patch in self.conan_data[\"patches\"][self.version]:\n            tools.patch(**patch)\n\n        with tools.chdir(self._source_subfolder):\n            # https://github.com/madler/zlib/issues/268\n            tools.replace_in_file('gzguts.h',\n                                  '#if defined(_WIN32) || defined(__CYGWIN__)',\n                                  '#if defined(_WIN32) || defined(__MINGW32__)')\n\n            is_apple_clang12 = self.settings.compiler == \"apple-clang\" and tools.Version(self.settings.compiler.version) >= \"12.0\"\n            if not is_apple_clang12:\n                for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']:\n                    tools.replace_in_file(filename,\n                                          '#ifdef HAVE_UNISTD_H    '\n                                          '/* may be set to #if 1 by ./configure */',\n                                          '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)')\n                    tools.replace_in_file(filename,\n                                          '#ifdef HAVE_STDARG_H    '\n                                          '/* may be set to #if 1 by ./configure */',\n                                          '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)')\n\n    def build(self):\n        self._patch_sources()\n        make_target = \"zlib\" if self.options.shared else \"zlibstatic\"\n        cmake = CMake(self)\n        cmake.configure(build_folder=self._build_subfolder)\n        cmake.build(target=make_target)\n\n    def _rename_libraries(self):\n        if self.settings.os == \"Windows\":\n            lib_path = os.path.join(self.package_folder, \"lib\")\n            suffix = \"d\" if self.settings.build_type == \"Debug\" else \"\"\n\n            if self.options.shared:\n                if self.settings.compiler == \"Visual Studio\" and suffix:\n                    current_lib = os.path.join(lib_path, \"zlib%s.lib\" % suffix)\n                    tools.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n            else:\n                if self.settings.compiler == \"Visual Studio\":\n                    current_lib = os.path.join(lib_path, \"zlibstatic%s.lib\" % suffix)\n                    tools.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n                elif self.settings.compiler == \"gcc\":\n                    if self.settings.os != \"Windows\" or not self.settings.os.subsystem:\n                        current_lib = os.path.join(lib_path, \"libzlibstatic.a\")\n                        tools.rename(current_lib, os.path.join(lib_path, \"libzlib.a\"))\n                elif self.settings.compiler == \"clang\":\n                    current_lib = os.path.join(lib_path, \"zlibstatic.lib\")\n                    tools.rename(current_lib, os.path.join(lib_path, \"zlib.lib\"))\n\n    def _extract_license(self):\n        with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)):\n            tmp = tools.load(\"zlib.h\")\n            license_contents = tmp[2:tmp.find(\"*/\", 1)]\n            tools.save(\"LICENSE\", license_contents)\n\n    def package(self):\n        self._extract_license()\n        self.copy(\"LICENSE\", src=self._source_subfolder, dst=\"licenses\")\n\n        # Copy headers\n        for header in [\"*zlib.h\", \"*zconf.h\"]:\n            self.copy(pattern=header, dst=\"include\", src=self._source_subfolder, keep_path=False)\n            self.copy(pattern=header, dst=\"include\", src=self._build_subfolder, keep_path=False)\n\n        # Copying static and dynamic libs\n        if self.options.shared:\n            self.copy(pattern=\"*.dylib*\", dst=\"lib\", src=self._build_subfolder, keep_path=False, symlinks=True)\n            self.copy(pattern=\"*.so*\", dst=\"lib\", src=self._build_subfolder, keep_path=False, symlinks=True)\n            self.copy(pattern=\"*.dll\", dst=\"bin\", src=self._build_subfolder, keep_path=False)\n            self.copy(pattern=\"*.dll.a\", dst=\"lib\", src=self._build_subfolder, keep_path=False)\n        else:\n            self.copy(pattern=\"*.a\", dst=\"lib\", src=self._build_subfolder, keep_path=False)\n        self.copy(pattern=\"*.lib\", dst=\"lib\", src=self._build_subfolder, keep_path=False)\n\n        self._rename_libraries()\n\n    def package_info(self):\n        self.cpp_info.libs.append(\"zlib\" if self.settings.os == \"Windows\" and not self.settings.os.subsystem else \"z\")\n        self.cpp_info.names[\"cmake_find_package\"] = \"ZLIB\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"ZLIB\"\n", "path": "recipes/zlib/1.2.11/conanfile.py"}]}