pip-check-reqs
pip-check-reqs copied to clipboard
ValueError "path is on mount 'C:', start on mount 'D:'" raised by os.path.relpath() on Windows
I am getting the subject ValueError on Windows, when the directory to inspect is on C: and the current directory is on D:, which happens to be the default on GitHub Actions in my project.
From the GitHub Actions run https://github.com/zhmcclient/zhmc-prometheus-exporter/runs/3269690424?check_suite_focus=true:
$ pip-missing-reqs C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\site-packages\pytest --requirements-file=minimum-constraints.txt
Traceback (most recent call last):
File "C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\hostedtoolcache\windows\Python\3.9.6\x64\Scripts\pip-missing-reqs.exe\__main__.py", line 7, in <module>
File "C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\site-packages\pip_check_reqs\find_missing_reqs.py", line 171, in main
missing = find_missing_reqs(
File "C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\site-packages\pip_check_reqs\find_missing_reqs.py", line 26, in find_missing_reqs
used_modules = common.find_imported_modules(options)
File "C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\site-packages\pip_check_reqs\common.py", line 121, in find_imported_modules
log.debug('scanning: %s', os.path.relpath(filename))
File "C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\ntpath.py", line 703, in relpath
raise ValueError("path is on mount %r, start on mount %r" % (
ValueError: path is on mount 'C:', start on mount 'D:'
This is a documented limitation of os.path.relpath()
on Windows, see https://docs.python.org/3/library/os.path.html#os.path.relpath.
I found the following uses of that function:
pip_check_reqs/common.py: log.info('ignoring: %s', os.path.relpath(filename))
pip_check_reqs/common.py: log.debug('scanning: %s', os.path.relpath(filename))
pip_check_reqs/common.py: elif fnmatch.fnmatch(os.path.relpath(candidate), ignore):
pip_check_reqs/common.py: file_list = [os.path.relpath(p, dist.location) for p in paths]
pip_check_reqs/common.py: file_list = [os.path.relpath(p, dist.location) for p in paths]
pip_check_reqs/find_missing_reqs.py: os.path.relpath(filename), lineno, name, use.modname)
I'm considering this as a bug, since adhering to this limitation creates unnecessary pain points.
I cannot investigate further until I integrate Windows into my workflow though.