change_prefix should ignore case on case-insensitive file systems #815

mjpieters opened this Issue Nov 3, 2015 · 2 comments


None yet

3 participants


On Windows, people can end up with a PYTHONPATH that leads to:

Traceback (most recent call last):
  File "C:\Python27\Scripts\", line 9, in <module>
    load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
  File "C:\Python27\lib\site-packages\", line 558, in main
  File "C:\Python27\lib\site-packages\", line 647, in create_environment
    site_packages=site_packages, clear=clear))
  File "C:\Python27\lib\site-packages\", line 771, in install_python
  File "C:\Python27\lib\site-packages\", line 725, in copy_required_modules
    dst_filename = change_prefix(filename, dst_prefix)
  File "C:\Python27\lib\site-packages\", line 710, in change_prefix
    (filename, prefixes)
AssertionError: Filename c:\Python27\Lib\ does not start with any of these prefixes: ['C:\\Python27']

where PYTHONPATH is set to c:\Python27;c:\Python27\Lib (lowercase c). The function should really use os.path.normcase() on the prefixes and the filename.

Ivoz commented Jan 29, 2016

@mjpieters unfortunately normcase will lowercase everything, which is actually not what you want. Python 2 will actually manage to error out on an incorrect filepath case, somehow.

@Ivoz Ivoz added a commit that referenced this issue Jan 29, 2016
@Ivoz Ivoz Revert ac4ea65; only correct drive letter case.
Fixes #856, #815
@Ivoz Ivoz closed this Jan 29, 2016
tlynn commented Feb 2, 2016

This fix looks incomplete, i.e. the problem looks likely to still be present when the case difference happens after the drive letter. normcase is the right thing to use for the comparison, but the normcased version of the filename should then be discarded.

How Windows actually compares paths (allegedly):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment