Error when a package stores the license file in a subdirectory
See original GitHub issueMy project started pulling version 2.5.2 for platformdirs. This platformdirs version started storing the LICENSE.txt file in a subdir (.\venv\Lib\site-packages\platformdirs-2.5.2.dist-info\license_files).
On line 171, (piplicense.py) pip-licenses tries to open the path (that it’s a dir) as a “regular” file and it fails with a “PermissionError: [Errno 13] Permission denied” error:
Traceback (most recent call last): File "c:\pablo\python\python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\pablo\python\python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Proyectos\AttackIQ\agent\aiq_agent_go\attackgraph\venv\Scripts\pip-licenses.exe\__main__.py", line 7, in <module> File "C:\Proyectos\AttackIQ\agent\aiq_agent_go\attackgraph\venv\lib\site-packages\piplicenses.py", line 893, in main output_string = create_output_string(args) File "C:\Proyectos\AttackIQ\agent\aiq_agent_go\attackgraph\venv\lib\site-packages\piplicenses.py", line 551, in create_output_string table = create_licenses_table(args, output_fields) File "C:\Proyectos\AttackIQ\agent\aiq_agent_go\attackgraph\venv\lib\site-packages\piplicenses.py", line 296, in create_licenses_table for pkg in get_packages(args): File "C:\Proyectos\AttackIQ\agent\aiq_agent_go\attackgraph\venv\lib\site-packages\piplicenses.py", line 258, in get_packages pkg_info = get_pkg_info(pkg) File "C:\Proyectos\AttackIQ\agent\aiq_agent_go\attackgraph\venv\lib\site-packages\piplicenses.py", line 178, in get_pkg_info (license_file, license_text) = get_pkg_included_file( File "C:\Proyectos\AttackIQ\agent\aiq_agent_go\attackgraph\venv\lib\site-packages\piplicenses.py", line 171, in get_pkg_included_file with open(test_file, encoding='utf-8', PermissionError: [Errno 13] Permission denied: 'c:\\proyectos\\attackiq\\agent\\aiq_agent_go\\attackgraph\\venv\\lib\\site-packages\\platformdirs-2.5.2.dist-info\\license_files'
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
@raimon49 Fixed!
Thank you!
Best!
Hi raimon49! Thank you so much for your quick feedback.
Yes, it’s a Windows-only issue (I mean the error… the logic not being able to find the license file in *nix is another related issue)…
You are calling get_pkg_included_file with (‘LICENSE*’, ‘LICENCE*’, ‘COPYING*’) as an argument for file_names.
In *nix (filesystem names are case sensitive) there is no match against the license_files subdirectory (so we get no error), but in Windows (filesystem names are case insensitive), there is a match and the logic is trying to open the subdirectory as a regular file (open call).
Best!
Pablo