Skip to content

Commit bd728b9

Browse files
committed
Update Profile Gather
1 parent bcb18f2 commit bd728b9

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

cppython/plugins/conan/plugin.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import requests
1313
from conan.api.conan_api import ConanAPI
1414
from conan.api.model import ListPattern
15+
from conan.internal.model.profile import Profile
1516

1617
from cppython.core.plugin_schema.generator import SyncConsumer
1718
from cppython.core.plugin_schema.provider import Provider, ProviderPluginGroupData, SupportedProviderFeatures
@@ -305,7 +306,7 @@ def publish(self) -> None:
305306
else:
306307
raise ProviderInstallationError('conan', 'No packages found to upload')
307308

308-
def _get_profiles(self, conan_api: ConanAPI) -> tuple[Any, Any]:
309+
def _get_profiles(self, conan_api: ConanAPI) -> tuple[Profile, Profile]:
309310
"""Get Conan profiles with fallback to auto-detection.
310311
311312
Args:
@@ -317,29 +318,20 @@ def _get_profiles(self, conan_api: ConanAPI) -> tuple[Any, Any]:
317318
logger = logging.getLogger('cppython.conan')
318319

319320
try:
321+
# Gather default profile paths, these can raise exceptions if not available
320322
profile_host_path = conan_api.profiles.get_default_host()
321323
profile_build_path = conan_api.profiles.get_default_build()
322324

323-
# Check if profile paths exist
324-
if profile_host_path is None or profile_build_path is None:
325-
logger.warning('Default profile paths not available, using auto-detection')
326-
raise ValueError('Profile paths are None')
327-
328-
# Load the actual profile objects
325+
# Load the actual profile objects, can raise if data is invalid
329326
profile_host = conan_api.profiles.get_profile([profile_host_path])
330327
profile_build = conan_api.profiles.get_profile([profile_build_path])
331328

332-
# Check if profiles are valid (not None)
333-
if profile_host is None or profile_build is None:
334-
logger.warning('Default profiles are corrupted/invalid, using auto-detection')
335-
raise ValueError('Profile loading returned None')
336-
337329
logger.debug('Using existing default profiles')
338330
return profile_host, profile_build
339331

340332
except Exception as e:
341-
logger.warning('Default profiles not available (%s), using auto-detection', str(e))
342-
# Use Conan's auto-detection to create minimal profiles
333+
logger.warning('Default profiles not available, using auto-detection. Conan message: %s', str(e))
334+
343335
profile_host = conan_api.profiles.detect()
344336
profile_build = conan_api.profiles.detect()
345337
return profile_host, profile_build

0 commit comments

Comments
 (0)