@@ -96,62 +96,98 @@ def _install_dependencies(self, *, update: bool = False) -> None:
9696
9797 # Initialize Conan API
9898 conan_api = ConanAPI ()
99+ logger .debug ('Conan API initialized successfully' )
99100
100101 # Get project paths
101102 project_root = self .core_data .project_data .project_root
102103 conanfile_path = project_root / 'conanfile.py'
104+ logger .debug ('Project root: %s, Conanfile path: %s' , project_root , conanfile_path )
103105
104106 if not conanfile_path .exists ():
105107 raise ProviderInstallationError ('conan' , 'Generated conanfile.py not found' )
106108
107109 # Get all remotes
108- all_remotes = conan_api .remotes .list ()
109- logger .debug ('Available remotes: %s' , [remote .name for remote in all_remotes ])
110+ try :
111+ all_remotes = conan_api .remotes .list ()
112+ logger .debug ('Available remotes: %s' , [remote .name for remote in all_remotes ])
113+ except Exception as e :
114+ logger .error ('Failed to list remotes: %s' , e )
115+ raise
110116
111117 # Get profiles from resolved data
112118 profile_host , profile_build = self .data .host_profile , self .data .build_profile
119+ logger .debug ('Using profiles - host: %s, build: %s' , profile_host , profile_build )
113120
114121 path = str (conanfile_path )
115122 remotes = all_remotes
116123 update_flag = None if not update else True
117124 check_updates_flag = update
118125
119- deps_graph = conan_api .graph .load_graph_consumer (
120- path = path ,
121- name = None ,
122- version = None ,
123- user = None ,
124- channel = None ,
125- lockfile = None ,
126- remotes = remotes ,
127- update = update_flag ,
128- check_updates = check_updates_flag ,
129- is_build_require = False ,
130- profile_host = profile_host ,
131- profile_build = profile_build ,
132- )
133-
134- logger .debug ('Dependency graph loaded with %d nodes' , len (deps_graph .nodes ))
126+ logger .debug ('Loading dependency graph with parameters: path=%s, remotes=%d, update=%s, check_updates=%s' ,
127+ path , len (remotes ), update_flag , check_updates_flag )
128+
129+ try :
130+ deps_graph = conan_api .graph .load_graph_consumer (
131+ path = path ,
132+ name = None ,
133+ version = None ,
134+ user = None ,
135+ channel = None ,
136+ lockfile = None ,
137+ remotes = remotes ,
138+ update = update_flag ,
139+ check_updates = check_updates_flag ,
140+ is_build_require = False ,
141+ profile_host = profile_host ,
142+ profile_build = profile_build ,
143+ )
144+ logger .debug ('Dependency graph loaded successfully, type: %s' , type (deps_graph ))
145+ if hasattr (deps_graph , 'nodes' ):
146+ logger .debug ('Graph has %d nodes' , len (deps_graph .nodes ))
147+ else :
148+ logger .warning ('Dependency graph does not have nodes attribute' )
149+ except Exception as e :
150+ logger .error ('Failed to load dependency graph: %s' , e )
151+ raise
135152
136153 # Analyze binaries to determine what needs to be built/downloaded
137- conan_api .graph .analyze_binaries (
138- graph = deps_graph ,
139- build_mode = ['missing' ], # Only build what's missing
140- remotes = all_remotes ,
141- update = None if not update else True ,
142- lockfile = None ,
143- )
154+ logger .debug ('Starting binary analysis with build_mode=["missing"], update=%s' , update )
155+ try :
156+ conan_api .graph .analyze_binaries (
157+ graph = deps_graph ,
158+ build_mode = ['missing' ], # Only build what's missing
159+ remotes = all_remotes ,
160+ update = None if not update else True ,
161+ lockfile = None ,
162+ )
163+ logger .debug ('Binary analysis completed successfully' )
164+ except Exception as e :
165+ logger .error ('Failed to analyze binaries: %s' , e )
166+ raise
144167
145168 # Install all dependencies
146- conan_api .install .install_binaries (deps_graph = deps_graph , remotes = all_remotes )
169+ logger .debug ('Starting binary installation' )
170+ try :
171+ conan_api .install .install_binaries (deps_graph = deps_graph , remotes = all_remotes )
172+ logger .debug ('Binary installation completed successfully' )
173+ except Exception as e :
174+ logger .error ('Failed to install binaries: %s' , e )
175+ raise
147176
148177 # Generate files for the consumer (conandata.yml, conan_toolchain.cmake, etc.)
149- conan_api .install .install_consumer (
150- deps_graph = deps_graph ,
151- generators = ['CMakeToolchain' , 'CMakeDeps' ],
152- source_folder = str (project_root ),
153- output_folder = str (self .core_data .cppython_data .build_path ),
154- )
178+ logger .debug ('Generating consumer files with generators=["CMakeToolchain", "CMakeDeps"]' )
179+ logger .debug ('Source folder: %s, Output folder: %s' , project_root , self .core_data .cppython_data .build_path )
180+ try :
181+ conan_api .install .install_consumer (
182+ deps_graph = deps_graph ,
183+ generators = ['CMakeToolchain' , 'CMakeDeps' ],
184+ source_folder = str (project_root ),
185+ output_folder = str (self .core_data .cppython_data .build_path ),
186+ )
187+ logger .debug ('Consumer file generation completed successfully' )
188+ except Exception as e :
189+ logger .error ('Failed to install consumer files: %s' , e )
190+ raise
155191
156192 logger .debug ('Successfully installed dependencies using Conan API' )
157193
@@ -208,22 +244,38 @@ async def download_tooling(cls, directory: Path) -> None:
208244
209245 def publish (self ) -> None :
210246 """Publishes the package using conan create workflow."""
247+ logger = logging .getLogger ('cppython.conan' )
248+ logger .debug ('Starting package publish workflow' )
249+
211250 # Get the project root directory where conanfile.py should be located
212251 project_root = self .core_data .project_data .project_root
213252 conanfile_path = project_root / 'conanfile.py'
253+ logger .debug ('Project root: %s, Conanfile path: %s' , project_root , conanfile_path )
214254
215255 if not conanfile_path .exists ():
216256 raise FileNotFoundError (f'conanfile.py not found at { conanfile_path } ' )
217257
218258 # Initialize Conan API
219- conan_api = ConanAPI ()
259+ try :
260+ conan_api = ConanAPI ()
261+ logger .debug ('Conan API initialized successfully for publish' )
262+ except Exception as e :
263+ logger .error ('Failed to initialize Conan API for publish: %s' , e )
264+ raise
220265
221266 # Get configured remotes from Conan API and filter by our configuration
222267 # TODO: We want to replace the global conan remotes with the ones configured in CPPython.
223- all_remotes = conan_api .remotes .list ()
268+ try :
269+ all_remotes = conan_api .remotes .list ()
270+ logger .debug ('Retrieved %d remotes for publish' , len (all_remotes ))
271+ except Exception as e :
272+ logger .error ('Failed to list remotes for publish: %s' , e )
273+ raise
274+
224275 if not self .data .local_only :
225276 # Filter remotes to only include those specified in configuration
226277 configured_remotes = [remote for remote in all_remotes if remote .name in self .data .remotes ]
278+ logger .debug ('Configured remotes: %s' , [r .name for r in configured_remotes ])
227279
228280 if not configured_remotes :
229281 available_remotes = [remote .name for remote in all_remotes ]
@@ -235,72 +287,122 @@ def publish(self) -> None:
235287 )
236288 else :
237289 configured_remotes = []
290+ logger .debug ('Local only mode - no remotes configured' )
238291
239292 # Step 1: Export the recipe to the cache
240293 # This is equivalent to the export part of `conan create`
241- ref , conanfile = conan_api .export .export (
242- path = str (conanfile_path ),
243- name = None ,
244- version = None ,
245- user = None ,
246- channel = None ,
247- lockfile = None ,
248- remotes = all_remotes , # Use all remotes for dependency resolution during export
249- )
294+ logger .debug ('Starting export step with path: %s' , conanfile_path )
295+ try :
296+ ref , conanfile = conan_api .export .export (
297+ path = str (conanfile_path ),
298+ name = None ,
299+ version = None ,
300+ user = None ,
301+ channel = None ,
302+ lockfile = None ,
303+ remotes = all_remotes , # Use all remotes for dependency resolution during export
304+ )
305+ logger .debug ('Export completed successfully. Ref: %s, Conanfile type: %s' , ref , type (conanfile ))
306+ if conanfile is None :
307+ logger .error ('Export returned None for conanfile!' )
308+ else :
309+ conanfile_attrs = dir (conanfile ) if hasattr (conanfile , '__dict__' ) else 'No attributes'
310+ logger .debug ('Conanfile attributes: %s' , conanfile_attrs )
311+ except Exception as e :
312+ logger .error ('Export failed: %s' , e )
313+ raise
250314
251315 # Step 2: Get profiles from resolved data
252316 profile_host , profile_build = self .data .host_profile , self .data .build_profile
317+ logger .debug ('Using profiles for publish - host: %s, build: %s' , profile_host , profile_build )
253318
254319 # Step 3: Build dependency graph for the package - prepare parameters
255320 path = str (conanfile_path )
256321 remotes = all_remotes # Use all remotes for dependency resolution
322+ logger .debug ('Loading dependency graph for publish with path: %s' , path )
257323
258- deps_graph = conan_api .graph .load_graph_consumer (
259- path = path ,
260- name = None ,
261- version = None ,
262- user = None ,
263- channel = None ,
264- lockfile = None ,
265- remotes = remotes ,
266- update = None ,
267- check_updates = False ,
268- is_build_require = False ,
269- profile_host = profile_host ,
270- profile_build = profile_build ,
271- )
324+ try :
325+ deps_graph = conan_api .graph .load_graph_consumer (
326+ path = path ,
327+ name = None ,
328+ version = None ,
329+ user = None ,
330+ channel = None ,
331+ lockfile = None ,
332+ remotes = remotes ,
333+ update = None ,
334+ check_updates = False ,
335+ is_build_require = False ,
336+ profile_host = profile_host ,
337+ profile_build = profile_build ,
338+ )
339+ logger .debug ('Dependency graph loaded successfully for publish' )
340+ except Exception as e :
341+ logger .error ('Failed to load dependency graph for publish: %s' , e )
342+ raise
272343
273344 # Step 4: Analyze binaries and install/build them if needed
274- conan_api .graph .analyze_binaries (
275- graph = deps_graph ,
276- build_mode = ['*' ], # Build from source (equivalent to the create behavior)
277- remotes = all_remotes , # Use all remotes for dependency resolution
278- update = None ,
279- lockfile = None ,
280- )
345+ logger .debug ('Starting binary analysis for publish' )
346+ try :
347+ conan_api .graph .analyze_binaries (
348+ graph = deps_graph ,
349+ build_mode = ['*' ], # Build from source (equivalent to the create behavior)
350+ remotes = all_remotes , # Use all remotes for dependency resolution
351+ update = None ,
352+ lockfile = None ,
353+ )
354+ logger .debug ('Binary analysis completed for publish' )
355+ except Exception as e :
356+ logger .error ('Failed to analyze binaries for publish: %s' , e )
357+ raise
281358
282359 # Step 5: Install all dependencies and build the package
283- conan_api .install .install_binaries (deps_graph = deps_graph , remotes = all_remotes )
360+ logger .debug ('Starting binary installation for publish' )
361+ try :
362+ conan_api .install .install_binaries (deps_graph = deps_graph , remotes = all_remotes )
363+ logger .debug ('Binary installation completed for publish' )
364+ except Exception as e :
365+ logger .error ('Failed to install binaries for publish: %s' , e )
366+ raise
284367
285368 # If not local only, upload the package
286369 if not self .data .local_only :
370+ logger .debug ('Starting package upload (not local only)' )
287371 # Get all packages matching the created reference
288- ref_pattern = ListPattern (f'{ ref .name } /*' , package_id = '*' , only_recipe = False )
289- package_list = conan_api .list .select (ref_pattern )
372+ try :
373+ logger .debug ('Creating ref pattern with ref.name: %s (ref type: %s)' , ref .name , type (ref ))
374+ ref_pattern = ListPattern (f'{ ref .name } /*' , package_id = '*' , only_recipe = False )
375+ package_list = conan_api .list .select (ref_pattern )
376+ recipe_count = len (package_list .recipes ) if package_list .recipes else 0
377+ logger .debug ('Package list retrieved: %s recipes found' , recipe_count )
378+ except AttributeError as e :
379+ logger .error ('Failed to access ref.name - ref object: %s, error: %s' , ref , e )
380+ raise
381+ except Exception as e :
382+ logger .error ('Failed to get package list for upload: %s' , e )
383+ raise
290384
291385 if package_list .recipes :
292386 # Use the first configured remote for upload
293387 remote = configured_remotes [0 ]
294-
295- # Upload the package to configured remotes
296- conan_api .upload .upload_full (
297- package_list = package_list ,
298- remote = remote ,
299- enabled_remotes = configured_remotes , # Only upload to configured remotes
300- check_integrity = False ,
301- force = False ,
302- metadata = None ,
303- dry_run = False ,
304- )
388+ logger .debug ('Uploading to remote: %s' , remote .name )
389+
390+ try :
391+ # Upload the package to configured remotes
392+ conan_api .upload .upload_full (
393+ package_list = package_list ,
394+ remote = remote ,
395+ enabled_remotes = configured_remotes , # Only upload to configured remotes
396+ check_integrity = False ,
397+ force = False ,
398+ metadata = None ,
399+ dry_run = False ,
400+ )
401+ logger .debug ('Package upload completed successfully' )
402+ except Exception as e :
403+ logger .error ('Failed to upload package: %s' , e )
404+ raise
305405 else :
306406 raise ProviderInstallationError ('conan' , 'No packages found to upload' )
407+ else :
408+ logger .debug ('Local only mode - skipping upload' )
0 commit comments