88from pathlib import Path
99from typing import Any
1010
11- import requests
1211from conan .api .conan_api import ConanAPI
1312from conan .api .model import ListPattern
1413
2726class ConanProvider (Provider ):
2827 """Conan Provider"""
2928
30- _provider_url = 'https://raw.githubusercontent.com/conan-io/cmake-conan/refs/heads/develop2/conan_provider.cmake'
31-
3229 def __init__ (
3330 self , group_data : ProviderPluginGroupData , core_data : CorePluginData , configuration_data : dict [str , Any ]
3431 ) -> None :
@@ -39,15 +36,6 @@ def __init__(
3936
4037 self .builder = Builder ()
4138
42- @staticmethod
43- def _download_file (url : str , file : Path ) -> None :
44- """Replaces the given file with the contents of the url"""
45- file .parent .mkdir (parents = True , exist_ok = True )
46-
47- with open (file , 'wb' ) as out_file :
48- content = requests .get (url , stream = True ).content
49- out_file .write (content )
50-
5139 @staticmethod
5240 def features (directory : Path ) -> SupportedFeatures :
5341 """Queries conan support
@@ -197,6 +185,13 @@ def _generate_consumer_files(self, conan_api: ConanAPI, deps_graph) -> None:
197185 output_folder = str (self .core_data .cppython_data .build_path ),
198186 )
199187
188+ # Rename the generated toolchain file so our wrapper can include it
189+ original_toolchain = self .core_data .cppython_data .build_path / 'conan_toolchain.cmake'
190+ renamed_toolchain = self .core_data .cppython_data .build_path / 'conan_toolchain.cmake.real'
191+
192+ if original_toolchain .exists () and not renamed_toolchain .exists ():
193+ original_toolchain .rename (renamed_toolchain )
194+
200195 def install (self ) -> None :
201196 """Installs the provider"""
202197 self ._install_dependencies (update = False )
@@ -231,17 +226,25 @@ def sync_data(self, consumer: SyncConsumer) -> SyncData:
231226 """
232227 for sync_type in consumer .sync_types ():
233228 if sync_type == CMakeSyncData :
229+ # Use the CMakeToolchain file directly as the toolchain
230+ toolchain_path = self .core_data .cppython_data .build_path / 'conan_toolchain.cmake'
231+
234232 return CMakeSyncData (
235233 provider_name = TypeName ('conan' ),
236- top_level_includes = self . core_data . cppython_data . install_path / 'conan_provider.cmake' ,
234+ toolchain = toolchain_path ,
237235 )
238236
239237 raise NotSupportedError (f'Unsupported sync types: { consumer .sync_types ()} ' )
240238
241239 @classmethod
242240 async def download_tooling (cls , directory : Path ) -> None :
243- """Downloads the conan provider file"""
244- cls ._download_file (cls ._provider_url , directory / 'conan_provider.cmake' )
241+ """Download external tooling required by the Conan provider.
242+
243+ Since we're using CMakeToolchain generator instead of cmake-conan provider,
244+ no external tooling needs to be downloaded.
245+ """
246+ # No external tooling required when using CMakeToolchain
247+ pass
245248
246249 def publish (self ) -> None :
247250 """Publishes the package using conan create workflow."""
0 commit comments