Capitalization bugs with VFSImporters on WinXP

I am trying to pack all of my .py and .pyc files in a Multifile package and importing them using the VFSImporter.register() process. Everything is more or less working, but I’m running into funny capitilization problems with the filesystem on a WinXp machine.

I get error messages such as

:express(warning): Filename is incorrect case: /c/Python26/lib/weakref.py instead of /c/Python26/Lib/weakref.py

File “C:\Panda3D-1.7.0\direct\stdpy\threading.py”, line 32, in
import weakref
ImportError: No module named weakref

There is a discrepency with capitalization of the native ‘Lib’ folder versus what Panda thinks is ‘lib’. This problem also occurs when I use the Panda’s prebuilt python which also uses the standard capital ‘Lib’. I renamed all of the native ‘Lib’ to ‘lib’ and things like numpy still imports ok, but it’s somewhat of wierd problem as ‘Lib’ is the standard capitalization of that python directory on windows.

Also, the system is senstive to whether or I initiate the .py file with either

c:/python26/python main.py
c:/Python26/python main.py

Panda’s default behavior is to reflect a case-sensitive file system in the vfs. This is strange for Windows developers who are used to ignoring case. Windows developers often have the wrong-case filename in some environment variable–for instance, PYTHONPATH–without noticing it, until vfs starts complaining about it. So, maybe you should investigate your PYTHONPATH and your Python’s .pth files and such. But, generally, this particular directory name is indeed named “Lib”, not “lib”.

If you’d rather not deal with case-sensitivity issues, you can add:

vfs-case-sensitive 0

to your Config.prc file. Note that your application may be less portable to case-sensitive operating systems then.

David

Hi David,

I understand that Panda's internal filenames are case sensitive, but I think the confusion in this particular case is that process associated with VFSImporter.register() are looking for a 'lib' (lower case directory), while as far as I can tell the native capitalization of that directory for a normal Python installation as well as for Panda's Python installation are by default capitalized. Thus to get it to work, I had to manually change the default 'Lib' directory to 'lib'. So what I'm trying to say is that VFSImporter.register() + import doesn't appear to be working straight out of the box for windows user (or at least for me.)

I looked at the VFSImporter.py but couldn't spot the problem so I assume the bug is somewhere in the C++ portion of the code. Unfortunately, I don't know C++ very well so I'm unable to fix the problem aside from presenting this workaround and mentioning this problem in case someone else runs into it as well.

Zhao

No, there’s nothing in VFSImporter that looks for “Lib” or “lib” or anything else specific like that. If it’s looking for “lib”, that means that “lib” is on your sys.path, which means it’s either that way from $PYTHONPATH or from a .pth file somewhere.

David

You’re right David. For reasons unclear to me, my native installations of python all use ‘lib’ pathnames on sys.path; I’m not sure why this is happening to me, but you’ve given me enough clues to track down the problem.

Thanks.