Skip to content

Commit 554fb3d

Browse files
committed
feat: add more output related to debugging issues with finding metadata
1 parent 3a0c62b commit 554fb3d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

version_query/py_query.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def query_package_folder(path: pathlib.Path, search_parent_directories: bool = F
3232
paths = [path]
3333
if search_parent_directories:
3434
paths += path.parents
35-
metadata_json_paths, pkg_info_paths = None, None
35+
global_metadata_json_paths, global_pkg_info_paths = [], []
3636
for pth in paths:
3737
metadata_json_paths = list(pth.parent.glob(f'{pth.name}*.dist-info/metadata.json'))
3838
pkg_info_paths = list(pth.parent.glob(f'{pth.name}*.egg-info/PKG-INFO'))
@@ -41,4 +41,13 @@ def query_package_folder(path: pathlib.Path, search_parent_directories: bool = F
4141
return query_metadata_json(metadata_json_paths[0])
4242
if not metadata_json_paths and len(pkg_info_paths) == 1:
4343
return query_pkg_info(pkg_info_paths[0])
44-
raise ValueError(paths, metadata_json_paths, pkg_info_paths)
44+
_LOG.debug(
45+
'in %s found %i JSON metadata: %s and %i PKG-INFO metadata: %s'
46+
' - unable to infer package metadata, continuing search',
47+
pth, len(metadata_json_paths), metadata_json_paths, len(pkg_info_paths), pkg_info_paths)
48+
global_metadata_json_paths.extend(metadata_json_paths)
49+
global_pkg_info_paths.extend(pkg_info_paths)
50+
raise ValueError(
51+
f'unable to infer package metadata from the following paths {paths} '
52+
f'- found {len(global_metadata_json_paths)} JSON metadata: {global_metadata_json_paths}'
53+
f' and {len(global_pkg_info_paths)} PKG-INFO metadata: {global_pkg_info_paths}')

0 commit comments

Comments
 (0)