@@ -279,7 +279,7 @@ def convert_numeric_keys(data: Dict) -> Dict:
279279 return data
280280
281281
282- def get_code_version_info (project_path : str = None ) -> Dict [str , Any ]:
282+ def get_code_version_info (project_path : str = None , package_name : str = None ) -> Dict [str , Any ]:
283283 """Determine version information for a project directory.
284284
285285 Checks git hash first, then PyPI version, then returns None.
@@ -300,8 +300,8 @@ def get_code_version_info(project_path: str = None) -> Dict[str, Any]:
300300 # two_folders_back = project_path.parents[1]
301301 result = {
302302 "project_path" : os .path .abspath (project_path ),
303- "source_type" : None ,
304- "version" : None ,
303+ "source_type" : ' None' ,
304+ "version" : '' ,
305305 "repository_url" : '' ,
306306 "is_dirty" : False ,
307307 }
@@ -379,16 +379,16 @@ def get_code_version_info(project_path: str = None) -> Dict[str, Any]:
379379 log .debug (f"Not a git repository or git error: { e } " )
380380
381381 # Check if it's installed via PyPI
382- try :
383- # Try to get package metadata
384- package_name = "ethopy"
385- package_version = importlib .metadata .version (package_name )
386-
387- result ["source_type" ] = "pypi"
388- result ["version" ] = package_version
389- return result
390- except (importlib .metadata .PackageNotFoundError , ImportError ) as e :
391- log .debug (f"Not a PyPI package or error: { e } " )
382+ if package_name is not None :
383+ try :
384+ # Try to get package metadata
385+ package_version = importlib .metadata .version (package_name )
386+
387+ result ["source_type" ] = "pypi"
388+ result ["version" ] = package_version
389+ return result
390+ except (importlib .metadata .PackageNotFoundError , ImportError ) as e :
391+ log .debug (f"Not a PyPI package or error: { e } " )
392392
393393 # If we get here, we couldn't determine version info
394394 return result
0 commit comments