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/sqlite3/all/conanfile.py`
Content:
```
1 from conans import ConanFile, CMake, tools
2 from conans.errors import ConanInvalidConfiguration
3 import os
4 import textwrap
5 
6 required_conan_version = ">=1.33.0"
7 
8 
9 class ConanSqlite3(ConanFile):
10     name = "sqlite3"
11     description = "Self-contained, serverless, in-process SQL database engine."
12     url = "https://github.com/conan-io/conan-center-index"
13     homepage = "https://www.sqlite.org"
14     topics = ("conan", "sqlite", "database", "sql", "serverless")
15     license = "Unlicense"
16     generators = "cmake"
17     settings = "os", "compiler", "arch", "build_type"
18     exports_sources = ["CMakeLists.txt"]
19     options = {
20         "shared": [True, False],
21         "fPIC": [True, False],
22         "threadsafe": [0, 1, 2],
23         "enable_column_metadata": [True, False],
24         "enable_dbstat_vtab": [True, False],
25         "enable_explain_comments": [True, False],
26         "enable_fts3": [True, False],
27         "enable_fts3_parenthesis": [True, False],
28         "enable_fts4": [True, False],
29         "enable_fts5": [True, False],
30         "enable_json1": [True, False],
31         "enable_soundex": [True, False],
32         "enable_preupdate_hook": [True, False],
33         "enable_rtree": [True, False],
34         "use_alloca": [True, False],
35         "omit_load_extension": [True, False],
36         "enable_math_functions": [True, False],
37         "enable_unlock_notify": [True, False],
38         "enable_default_secure_delete": [True, False],
39         "disable_gethostuuid": [True, False],
40         "max_blob_size": "ANY",
41         "build_executable": [True, False],
42         "enable_default_vfs": [True, False],
43     }
44     default_options = {
45         "shared": False,
46         "fPIC": True,
47         "threadsafe": 1,
48         "enable_column_metadata": True,
49         "enable_dbstat_vtab": False,
50         "enable_explain_comments": False,
51         "enable_fts3": False,
52         "enable_fts3_parenthesis": False,
53         "enable_fts4": False,
54         "enable_fts5": False,
55         "enable_json1": False,
56         "enable_soundex": False,
57         "enable_preupdate_hook": False,
58         "enable_rtree": True,
59         "use_alloca": False,
60         "omit_load_extension": False,
61         "enable_math_functions": True,
62         "enable_unlock_notify": True,
63         "enable_default_secure_delete": False,
64         "disable_gethostuuid": False,
65         "max_blob_size": 1000000000,
66         "build_executable": True,
67         "enable_default_vfs": True,
68     }
69 
70     _cmake = None
71 
72     @property
73     def _source_subfolder(self):
74         return "source_subfolder"
75 
76     @property
77     def _has_enable_math_function_option(self):
78         return tools.Version(self.version) >= "3.35.0"
79 
80     def config_options(self):
81         if self.settings.os == "Windows":
82             del self.options.fPIC
83         if not self._has_enable_math_function_option:
84             del self.options.enable_math_functions
85 
86     def configure(self):
87         if self.options.shared:
88             del self.options.fPIC
89         del self.settings.compiler.libcxx
90         del self.settings.compiler.cppstd
91 
92     def validate(self):
93         if not self.options.enable_default_vfs and self.options.build_executable:
94             # Need to provide custom VFS code: https://www.sqlite.org/custombuild.html
95             raise ConanInvalidConfiguration("build_executable=True cannot be combined with enable_default_vfs=False")
96 
97     def source(self):
98         tools.get(**self.conan_data["sources"][self.version])
99         url = self.conan_data["sources"][self.version]["url"]
100         archive_name = os.path.basename(url)
101         archive_name = os.path.splitext(archive_name)[0]
102         os.rename(archive_name, self._source_subfolder)
103 
104     def _configure_cmake(self):
105         if self._cmake:
106             return self._cmake
107         self._cmake = CMake(self)
108         self._cmake.definitions["SQLITE3_VERSION"] = self.version
109         self._cmake.definitions["SQLITE3_BUILD_EXECUTABLE"] = self.options.build_executable
110         self._cmake.definitions["THREADSAFE"] = self.options.threadsafe
111         self._cmake.definitions["ENABLE_COLUMN_METADATA"] = self.options.enable_column_metadata
112         self._cmake.definitions["ENABLE_DBSTAT_VTAB"] = self.options.enable_dbstat_vtab
113         self._cmake.definitions["ENABLE_EXPLAIN_COMMENTS"] = self.options.enable_explain_comments
114         self._cmake.definitions["ENABLE_FTS3"] = self.options.enable_fts3
115         self._cmake.definitions["ENABLE_FTS3_PARENTHESIS"] = self.options.enable_fts3_parenthesis
116         self._cmake.definitions["ENABLE_FTS4"] = self.options.enable_fts4
117         self._cmake.definitions["ENABLE_FTS5"] = self.options.enable_fts5
118         self._cmake.definitions["ENABLE_JSON1"] = self.options.enable_json1
119         self._cmake.definitions["ENABLE_PREUPDATE_HOOK"] = self.options.enable_preupdate_hook
120         self._cmake.definitions["ENABLE_SOUNDEX"] = self.options.enable_soundex
121         self._cmake.definitions["ENABLE_RTREE"] = self.options.enable_rtree
122         self._cmake.definitions["ENABLE_UNLOCK_NOTIFY"] = self.options.enable_unlock_notify
123         self._cmake.definitions["ENABLE_DEFAULT_SECURE_DELETE"] = self.options.enable_default_secure_delete
124         self._cmake.definitions["USE_ALLOCA"] = self.options.use_alloca
125         self._cmake.definitions["OMIT_LOAD_EXTENSION"] = self.options.omit_load_extension
126         if self._has_enable_math_function_option:
127             self._cmake.definitions["ENABLE_MATH_FUNCTIONS"] = self.options.enable_math_functions
128         self._cmake.definitions["HAVE_FDATASYNC"] = True
129         self._cmake.definitions["HAVE_GMTIME_R"] = True
130         self._cmake.definitions["HAVE_LOCALTIME_R"] = self.settings.os != "Windows"
131         self._cmake.definitions["HAVE_POSIX_FALLOCATE"] = not (self.settings.os in ["Windows", "Android"] or tools.is_apple_os(self.settings.os))
132         self._cmake.definitions["HAVE_STRERROR_R"] = True
133         self._cmake.definitions["HAVE_USLEEP"] = True
134         self._cmake.definitions["DISABLE_GETHOSTUUID"] = self.options.disable_gethostuuid
135         self._cmake.definitions["MAX_BLOB_SIZE"] = self.options.max_blob_size
136         self._cmake.definitions["DISABLE_DEFAULT_VFS"] = not self.options.enable_default_vfs
137         self._cmake.configure()
138         return self._cmake
139 
140     def build(self):
141         cmake = self._configure_cmake()
142         cmake.build()
143 
144     def package(self):
145         header = tools.load(os.path.join(self._source_subfolder, "sqlite3.h"))
146         license_content = header[3:header.find("***", 1)]
147         tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), license_content)
148         cmake = self._configure_cmake()
149         cmake.install()
150         self._create_cmake_module_variables(
151             os.path.join(self.package_folder, self._module_file_rel_path)
152         )
153 
154     @staticmethod
155     def _create_cmake_module_variables(module_file):
156         content = textwrap.dedent("""\
157             if(DEFINED SQLite_INCLUDE_DIRS)
158                 set(SQLite3_INCLUDE_DIRS ${SQLite_INCLUDE_DIRS})
159             endif()
160             if(DEFINED SQLite_LIBRARIES)
161                 set(SQLite3_LIBRARIES ${SQLite_LIBRARIES})
162             endif()
163         """)
164         tools.save(module_file, content)
165 
166     @property
167     def _module_subfolder(self):
168         return os.path.join("lib", "cmake")
169 
170     @property
171     def _module_file_rel_path(self):
172         return os.path.join(self._module_subfolder,
173                             "conan-official-{}-variables.cmake".format(self.name))
174 
175     def package_info(self):
176         self.cpp_info.filenames["cmake_find_package"] = "SQLite3"
177         self.cpp_info.filenames["cmake_find_package_multi"] = "SQLite3"
178         self.cpp_info.names["cmake_find_package"] = "SQLite"
179         self.cpp_info.names["cmake_find_package_multi"] = "SQLite"
180         self.cpp_info.components["sqlite"].names["cmake_find_package"] = "SQLite3"
181         self.cpp_info.components["sqlite"].names["cmake_find_package_multi"] = "SQLite3"
182         self.cpp_info.components["sqlite"].builddirs.append(self._module_subfolder)
183         self.cpp_info.components["sqlite"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
184         self.cpp_info.components["sqlite"].libs = tools.collect_libs(self)
185         if self.settings.os in ["Linux", "FreeBSD"]:
186             if self.options.threadsafe:
187                 self.cpp_info.components["sqlite"].system_libs.append("pthread")
188             if not self.options.omit_load_extension:
189                 self.cpp_info.components["sqlite"].system_libs.append("dl")
190             if self.options.enable_fts5 or self.options.get_safe("enable_math_functions"):
191                 self.cpp_info.components["sqlite"].system_libs.append("m")
192 
193         if self.options.build_executable:
194             bin_path = os.path.join(self.package_folder, "bin")
195             self.output.info("Appending PATH env var with : {}".format(bin_path))
196             self.env_info.PATH.append(bin_path)
197
```
--- 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/sqlite3/all/conanfile.py b/recipes/sqlite3/all/conanfile.py
--- a/recipes/sqlite3/all/conanfile.py
+++ b/recipes/sqlite3/all/conanfile.py
@@ -87,11 +87,7 @@
         del self.settings.compiler.cppstd
 
     def source(self):
-        tools.get(**self.conan_data["sources"][self.version])
-        url = self.conan_data["sources"][self.version]["url"]
-        archive_name = os.path.basename(url)
-        archive_name = os.path.splitext(archive_name)[0]
-        os.rename(archive_name, self._source_subfolder)
+        tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True)
 
     def _configure_cmake(self):
         if self._cmake:

{"golden_diff": "diff --git a/recipes/sqlite3/all/conanfile.py b/recipes/sqlite3/all/conanfile.py\n--- a/recipes/sqlite3/all/conanfile.py\n+++ b/recipes/sqlite3/all/conanfile.py\n@@ -87,11 +87,7 @@\n         del self.settings.compiler.cppstd\n \n     def source(self):\n-        tools.get(**self.conan_data[\"sources\"][self.version])\n-        url = self.conan_data[\"sources\"][self.version][\"url\"]\n-        archive_name = os.path.basename(url)\n-        archive_name = os.path.splitext(archive_name)[0]\n-        os.rename(archive_name, self._source_subfolder)\n+        tools.get(**self.conan_data[\"sources\"][self.version], destination=self._source_subfolder, strip_root=True)\n \n     def _configure_cmake(self):\n         if self._cmake:\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": "from conans import ConanFile, CMake, tools\nfrom conans.errors import ConanInvalidConfiguration\nimport os\nimport textwrap\n\nrequired_conan_version = \">=1.33.0\"\n\n\nclass ConanSqlite3(ConanFile):\n    name = \"sqlite3\"\n    description = \"Self-contained, serverless, in-process SQL database engine.\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://www.sqlite.org\"\n    topics = (\"conan\", \"sqlite\", \"database\", \"sql\", \"serverless\")\n    license = \"Unlicense\"\n    generators = \"cmake\"\n    settings = \"os\", \"compiler\", \"arch\", \"build_type\"\n    exports_sources = [\"CMakeLists.txt\"]\n    options = {\n        \"shared\": [True, False],\n        \"fPIC\": [True, False],\n        \"threadsafe\": [0, 1, 2],\n        \"enable_column_metadata\": [True, False],\n        \"enable_dbstat_vtab\": [True, False],\n        \"enable_explain_comments\": [True, False],\n        \"enable_fts3\": [True, False],\n        \"enable_fts3_parenthesis\": [True, False],\n        \"enable_fts4\": [True, False],\n        \"enable_fts5\": [True, False],\n        \"enable_json1\": [True, False],\n        \"enable_soundex\": [True, False],\n        \"enable_preupdate_hook\": [True, False],\n        \"enable_rtree\": [True, False],\n        \"use_alloca\": [True, False],\n        \"omit_load_extension\": [True, False],\n        \"enable_math_functions\": [True, False],\n        \"enable_unlock_notify\": [True, False],\n        \"enable_default_secure_delete\": [True, False],\n        \"disable_gethostuuid\": [True, False],\n        \"max_blob_size\": \"ANY\",\n        \"build_executable\": [True, False],\n        \"enable_default_vfs\": [True, False],\n    }\n    default_options = {\n        \"shared\": False,\n        \"fPIC\": True,\n        \"threadsafe\": 1,\n        \"enable_column_metadata\": True,\n        \"enable_dbstat_vtab\": False,\n        \"enable_explain_comments\": False,\n        \"enable_fts3\": False,\n        \"enable_fts3_parenthesis\": False,\n        \"enable_fts4\": False,\n        \"enable_fts5\": False,\n        \"enable_json1\": False,\n        \"enable_soundex\": False,\n        \"enable_preupdate_hook\": False,\n        \"enable_rtree\": True,\n        \"use_alloca\": False,\n        \"omit_load_extension\": False,\n        \"enable_math_functions\": True,\n        \"enable_unlock_notify\": True,\n        \"enable_default_secure_delete\": False,\n        \"disable_gethostuuid\": False,\n        \"max_blob_size\": 1000000000,\n        \"build_executable\": True,\n        \"enable_default_vfs\": True,\n    }\n\n    _cmake = None\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    @property\n    def _has_enable_math_function_option(self):\n        return tools.Version(self.version) >= \"3.35.0\"\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n        if not self._has_enable_math_function_option:\n            del self.options.enable_math_functions\n\n    def configure(self):\n        if self.options.shared:\n            del self.options.fPIC\n        del self.settings.compiler.libcxx\n        del self.settings.compiler.cppstd\n\n    def validate(self):\n        if not self.options.enable_default_vfs and self.options.build_executable:\n            # Need to provide custom VFS code: https://www.sqlite.org/custombuild.html\n            raise ConanInvalidConfiguration(\"build_executable=True cannot be combined with enable_default_vfs=False\")\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version])\n        url = self.conan_data[\"sources\"][self.version][\"url\"]\n        archive_name = os.path.basename(url)\n        archive_name = os.path.splitext(archive_name)[0]\n        os.rename(archive_name, self._source_subfolder)\n\n    def _configure_cmake(self):\n        if self._cmake:\n            return self._cmake\n        self._cmake = CMake(self)\n        self._cmake.definitions[\"SQLITE3_VERSION\"] = self.version\n        self._cmake.definitions[\"SQLITE3_BUILD_EXECUTABLE\"] = self.options.build_executable\n        self._cmake.definitions[\"THREADSAFE\"] = self.options.threadsafe\n        self._cmake.definitions[\"ENABLE_COLUMN_METADATA\"] = self.options.enable_column_metadata\n        self._cmake.definitions[\"ENABLE_DBSTAT_VTAB\"] = self.options.enable_dbstat_vtab\n        self._cmake.definitions[\"ENABLE_EXPLAIN_COMMENTS\"] = self.options.enable_explain_comments\n        self._cmake.definitions[\"ENABLE_FTS3\"] = self.options.enable_fts3\n        self._cmake.definitions[\"ENABLE_FTS3_PARENTHESIS\"] = self.options.enable_fts3_parenthesis\n        self._cmake.definitions[\"ENABLE_FTS4\"] = self.options.enable_fts4\n        self._cmake.definitions[\"ENABLE_FTS5\"] = self.options.enable_fts5\n        self._cmake.definitions[\"ENABLE_JSON1\"] = self.options.enable_json1\n        self._cmake.definitions[\"ENABLE_PREUPDATE_HOOK\"] = self.options.enable_preupdate_hook\n        self._cmake.definitions[\"ENABLE_SOUNDEX\"] = self.options.enable_soundex\n        self._cmake.definitions[\"ENABLE_RTREE\"] = self.options.enable_rtree\n        self._cmake.definitions[\"ENABLE_UNLOCK_NOTIFY\"] = self.options.enable_unlock_notify\n        self._cmake.definitions[\"ENABLE_DEFAULT_SECURE_DELETE\"] = self.options.enable_default_secure_delete\n        self._cmake.definitions[\"USE_ALLOCA\"] = self.options.use_alloca\n        self._cmake.definitions[\"OMIT_LOAD_EXTENSION\"] = self.options.omit_load_extension\n        if self._has_enable_math_function_option:\n            self._cmake.definitions[\"ENABLE_MATH_FUNCTIONS\"] = self.options.enable_math_functions\n        self._cmake.definitions[\"HAVE_FDATASYNC\"] = True\n        self._cmake.definitions[\"HAVE_GMTIME_R\"] = True\n        self._cmake.definitions[\"HAVE_LOCALTIME_R\"] = self.settings.os != \"Windows\"\n        self._cmake.definitions[\"HAVE_POSIX_FALLOCATE\"] = not (self.settings.os in [\"Windows\", \"Android\"] or tools.is_apple_os(self.settings.os))\n        self._cmake.definitions[\"HAVE_STRERROR_R\"] = True\n        self._cmake.definitions[\"HAVE_USLEEP\"] = True\n        self._cmake.definitions[\"DISABLE_GETHOSTUUID\"] = self.options.disable_gethostuuid\n        self._cmake.definitions[\"MAX_BLOB_SIZE\"] = self.options.max_blob_size\n        self._cmake.definitions[\"DISABLE_DEFAULT_VFS\"] = not self.options.enable_default_vfs\n        self._cmake.configure()\n        return self._cmake\n\n    def build(self):\n        cmake = self._configure_cmake()\n        cmake.build()\n\n    def package(self):\n        header = tools.load(os.path.join(self._source_subfolder, \"sqlite3.h\"))\n        license_content = header[3:header.find(\"***\", 1)]\n        tools.save(os.path.join(self.package_folder, \"licenses\", \"LICENSE\"), license_content)\n        cmake = self._configure_cmake()\n        cmake.install()\n        self._create_cmake_module_variables(\n            os.path.join(self.package_folder, self._module_file_rel_path)\n        )\n\n    @staticmethod\n    def _create_cmake_module_variables(module_file):\n        content = textwrap.dedent(\"\"\"\\\n            if(DEFINED SQLite_INCLUDE_DIRS)\n                set(SQLite3_INCLUDE_DIRS ${SQLite_INCLUDE_DIRS})\n            endif()\n            if(DEFINED SQLite_LIBRARIES)\n                set(SQLite3_LIBRARIES ${SQLite_LIBRARIES})\n            endif()\n        \"\"\")\n        tools.save(module_file, content)\n\n    @property\n    def _module_subfolder(self):\n        return os.path.join(\"lib\", \"cmake\")\n\n    @property\n    def _module_file_rel_path(self):\n        return os.path.join(self._module_subfolder,\n                            \"conan-official-{}-variables.cmake\".format(self.name))\n\n    def package_info(self):\n        self.cpp_info.filenames[\"cmake_find_package\"] = \"SQLite3\"\n        self.cpp_info.filenames[\"cmake_find_package_multi\"] = \"SQLite3\"\n        self.cpp_info.names[\"cmake_find_package\"] = \"SQLite\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"SQLite\"\n        self.cpp_info.components[\"sqlite\"].names[\"cmake_find_package\"] = \"SQLite3\"\n        self.cpp_info.components[\"sqlite\"].names[\"cmake_find_package_multi\"] = \"SQLite3\"\n        self.cpp_info.components[\"sqlite\"].builddirs.append(self._module_subfolder)\n        self.cpp_info.components[\"sqlite\"].build_modules[\"cmake_find_package\"] = [self._module_file_rel_path]\n        self.cpp_info.components[\"sqlite\"].libs = tools.collect_libs(self)\n        if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n            if self.options.threadsafe:\n                self.cpp_info.components[\"sqlite\"].system_libs.append(\"pthread\")\n            if not self.options.omit_load_extension:\n                self.cpp_info.components[\"sqlite\"].system_libs.append(\"dl\")\n            if self.options.enable_fts5 or self.options.get_safe(\"enable_math_functions\"):\n                self.cpp_info.components[\"sqlite\"].system_libs.append(\"m\")\n\n        if self.options.build_executable:\n            bin_path = os.path.join(self.package_folder, \"bin\")\n            self.output.info(\"Appending PATH env var with : {}\".format(bin_path))\n            self.env_info.PATH.append(bin_path)\n", "path": "recipes/sqlite3/all/conanfile.py"}], "after_files": [{"content": "from conans import ConanFile, CMake, tools\nimport os\nimport textwrap\n\nrequired_conan_version = \">=1.33.0\"\n\n\nclass ConanSqlite3(ConanFile):\n    name = \"sqlite3\"\n    description = \"Self-contained, serverless, in-process SQL database engine.\"\n    url = \"https://github.com/conan-io/conan-center-index\"\n    homepage = \"https://www.sqlite.org\"\n    topics = (\"conan\", \"sqlite\", \"database\", \"sql\", \"serverless\")\n    license = \"Unlicense\"\n    generators = \"cmake\"\n    settings = \"os\", \"compiler\", \"arch\", \"build_type\"\n    exports_sources = [\"CMakeLists.txt\"]\n    options = {\n        \"shared\": [True, False],\n        \"fPIC\": [True, False],\n        \"threadsafe\": [0, 1, 2],\n        \"enable_column_metadata\": [True, False],\n        \"enable_dbstat_vtab\": [True, False],\n        \"enable_explain_comments\": [True, False],\n        \"enable_fts3\": [True, False],\n        \"enable_fts3_parenthesis\": [True, False],\n        \"enable_fts4\": [True, False],\n        \"enable_fts5\": [True, False],\n        \"enable_json1\": [True, False],\n        \"enable_soundex\": [True, False],\n        \"enable_preupdate_hook\": [True, False],\n        \"enable_rtree\": [True, False],\n        \"use_alloca\": [True, False],\n        \"omit_load_extension\": [True, False],\n        \"enable_math_functions\": [True, False],\n        \"enable_unlock_notify\": [True, False],\n        \"enable_default_secure_delete\": [True, False],\n        \"disable_gethostuuid\": [True, False],\n        \"max_blob_size\": \"ANY\",\n        \"build_executable\": [True, False],\n    }\n    default_options = {\n        \"shared\": False,\n        \"fPIC\": True,\n        \"threadsafe\": 1,\n        \"enable_column_metadata\": True,\n        \"enable_dbstat_vtab\": False,\n        \"enable_explain_comments\": False,\n        \"enable_fts3\": False,\n        \"enable_fts3_parenthesis\": False,\n        \"enable_fts4\": False,\n        \"enable_fts5\": False,\n        \"enable_json1\": False,\n        \"enable_soundex\": False,\n        \"enable_preupdate_hook\": False,\n        \"enable_rtree\": True,\n        \"use_alloca\": False,\n        \"omit_load_extension\": False,\n        \"enable_math_functions\": True,\n        \"enable_unlock_notify\": True,\n        \"enable_default_secure_delete\": False,\n        \"disable_gethostuuid\": False,\n        \"max_blob_size\": 1000000000,\n        \"build_executable\": True,\n    }\n\n    _cmake = None\n\n    @property\n    def _source_subfolder(self):\n        return \"source_subfolder\"\n\n    @property\n    def _has_enable_math_function_option(self):\n        return tools.Version(self.version) >= \"3.35.0\"\n\n    def config_options(self):\n        if self.settings.os == \"Windows\":\n            del self.options.fPIC\n        if not self._has_enable_math_function_option:\n            del self.options.enable_math_functions\n\n    def configure(self):\n        if self.options.shared:\n            del self.options.fPIC\n        del self.settings.compiler.libcxx\n        del self.settings.compiler.cppstd\n\n    def source(self):\n        tools.get(**self.conan_data[\"sources\"][self.version], destination=self._source_subfolder, strip_root=True)\n\n    def _configure_cmake(self):\n        if self._cmake:\n            return self._cmake\n        self._cmake = CMake(self)\n        self._cmake.definitions[\"SQLITE3_VERSION\"] = self.version\n        self._cmake.definitions[\"SQLITE3_BUILD_EXECUTABLE\"] = self.options.build_executable\n        self._cmake.definitions[\"THREADSAFE\"] = self.options.threadsafe\n        self._cmake.definitions[\"ENABLE_COLUMN_METADATA\"] = self.options.enable_column_metadata\n        self._cmake.definitions[\"ENABLE_DBSTAT_VTAB\"] = self.options.enable_dbstat_vtab\n        self._cmake.definitions[\"ENABLE_EXPLAIN_COMMENTS\"] = self.options.enable_explain_comments\n        self._cmake.definitions[\"ENABLE_FTS3\"] = self.options.enable_fts3\n        self._cmake.definitions[\"ENABLE_FTS3_PARENTHESIS\"] = self.options.enable_fts3_parenthesis\n        self._cmake.definitions[\"ENABLE_FTS4\"] = self.options.enable_fts4\n        self._cmake.definitions[\"ENABLE_FTS5\"] = self.options.enable_fts5\n        self._cmake.definitions[\"ENABLE_JSON1\"] = self.options.enable_json1\n        self._cmake.definitions[\"ENABLE_PREUPDATE_HOOK\"] = self.options.enable_preupdate_hook\n        self._cmake.definitions[\"ENABLE_SOUNDEX\"] = self.options.enable_soundex\n        self._cmake.definitions[\"ENABLE_RTREE\"] = self.options.enable_rtree\n        self._cmake.definitions[\"ENABLE_UNLOCK_NOTIFY\"] = self.options.enable_unlock_notify\n        self._cmake.definitions[\"ENABLE_DEFAULT_SECURE_DELETE\"] = self.options.enable_default_secure_delete\n        self._cmake.definitions[\"USE_ALLOCA\"] = self.options.use_alloca\n        self._cmake.definitions[\"OMIT_LOAD_EXTENSION\"] = self.options.omit_load_extension\n        if self._has_enable_math_function_option:\n            self._cmake.definitions[\"ENABLE_MATH_FUNCTIONS\"] = self.options.enable_math_functions\n        self._cmake.definitions[\"HAVE_FDATASYNC\"] = True\n        self._cmake.definitions[\"HAVE_GMTIME_R\"] = True\n        self._cmake.definitions[\"HAVE_LOCALTIME_R\"] = self.settings.os != \"Windows\"\n        self._cmake.definitions[\"HAVE_POSIX_FALLOCATE\"] = not (self.settings.os in [\"Windows\", \"Android\"] or tools.is_apple_os(self.settings.os))\n        self._cmake.definitions[\"HAVE_STRERROR_R\"] = True\n        self._cmake.definitions[\"HAVE_USLEEP\"] = True\n        self._cmake.definitions[\"DISABLE_GETHOSTUUID\"] = self.options.disable_gethostuuid\n        self._cmake.definitions[\"MAX_BLOB_SIZE\"] = self.options.max_blob_size\n        self._cmake.configure()\n        return self._cmake\n\n    def build(self):\n        cmake = self._configure_cmake()\n        cmake.build()\n\n    def package(self):\n        header = tools.load(os.path.join(self._source_subfolder, \"sqlite3.h\"))\n        license_content = header[3:header.find(\"***\", 1)]\n        tools.save(os.path.join(self.package_folder, \"licenses\", \"LICENSE\"), license_content)\n        cmake = self._configure_cmake()\n        cmake.install()\n        self._create_cmake_module_variables(\n            os.path.join(self.package_folder, self._module_file_rel_path)\n        )\n\n    @staticmethod\n    def _create_cmake_module_variables(module_file):\n        content = textwrap.dedent(\"\"\"\\\n            if(DEFINED SQLite_INCLUDE_DIRS)\n                set(SQLite3_INCLUDE_DIRS ${SQLite_INCLUDE_DIRS})\n            endif()\n            if(DEFINED SQLite_LIBRARIES)\n                set(SQLite3_LIBRARIES ${SQLite_LIBRARIES})\n            endif()\n        \"\"\")\n        tools.save(module_file, content)\n\n    @property\n    def _module_subfolder(self):\n        return os.path.join(\"lib\", \"cmake\")\n\n    @property\n    def _module_file_rel_path(self):\n        return os.path.join(self._module_subfolder,\n                            \"conan-official-{}-variables.cmake\".format(self.name))\n\n    def package_info(self):\n        self.cpp_info.filenames[\"cmake_find_package\"] = \"SQLite3\"\n        self.cpp_info.filenames[\"cmake_find_package_multi\"] = \"SQLite3\"\n        self.cpp_info.names[\"cmake_find_package\"] = \"SQLite\"\n        self.cpp_info.names[\"cmake_find_package_multi\"] = \"SQLite\"\n        self.cpp_info.components[\"sqlite\"].names[\"cmake_find_package\"] = \"SQLite3\"\n        self.cpp_info.components[\"sqlite\"].names[\"cmake_find_package_multi\"] = \"SQLite3\"\n        self.cpp_info.components[\"sqlite\"].builddirs.append(self._module_subfolder)\n        self.cpp_info.components[\"sqlite\"].build_modules[\"cmake_find_package\"] = [self._module_file_rel_path]\n        self.cpp_info.components[\"sqlite\"].libs = tools.collect_libs(self)\n        if self.settings.os in [\"Linux\", \"FreeBSD\"]:\n            if self.options.threadsafe:\n                self.cpp_info.components[\"sqlite\"].system_libs.append(\"pthread\")\n            if not self.options.omit_load_extension:\n                self.cpp_info.components[\"sqlite\"].system_libs.append(\"dl\")\n            if self.options.enable_fts5 or self.options.get_safe(\"enable_math_functions\"):\n                self.cpp_info.components[\"sqlite\"].system_libs.append(\"m\")\n\n        if self.options.build_executable:\n            bin_path = os.path.join(self.package_folder, \"bin\")\n            self.output.info(\"Appending PATH env var with : {}\".format(bin_path))\n            self.env_info.PATH.append(bin_path)\n", "path": "recipes/sqlite3/all/conanfile.py"}]}