New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mjpieters opened this Issue Nov 3, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@mjpieters

mjpieters commented Nov 3, 2015

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

Traceback (most recent call last):
  File "C:\Python27\Scripts\virtualenv-script.py", line 9, in <module>
    load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
  File "C:\Python27\lib\site-packages\virtualenv.py", line 558, in main
    prompt=options.prompt)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 647, in create_environment
    site_packages=site_packages, clear=clear))
  File "C:\Python27\lib\site-packages\virtualenv.py", line 771, in install_python
    copy_required_modules(home_dir)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 725, in copy_required_modules
    dst_filename = change_prefix(filename, dst_prefix)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 710, in change_prefix
    (filename, prefixes)
AssertionError: Filename c:\Python27\Lib\os.py 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

This comment has been minimized.

Show comment
Hide comment
@Ivoz

Ivoz Jan 29, 2016

Member

@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.

Member

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.

@tlynn

This comment has been minimized.

Show comment
Hide comment
@tlynn

tlynn 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): http://stackoverflow.com/a/8900148

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): http://stackoverflow.com/a/8900148

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