packadges get mounted badly

In my game i have a data packadge. The data package has one folder called data. I would expect that data package to mount in the root directory of my p3d app ( /home/me/.panda3d/start/data ) or maybe at the root of whole file system ( /data ) but it mounts to the same dir its located in:
( /home/me/.panda3d/hosts/localhost_5733f35ab2ed94d2/data ).

Is there a way to force it to mount in the same folder as the app? Or is this a bug and it should mount how i describe?

No, this is the expected behavior. But note that your data directory is placed in the model-path, PYTHONPATH, ((DY)LD_LIBRARY_)PATH, etc. so mounting in the same directory should not be necessary.

The problem is that I want to walk the directory. To see what files I got and stuff. If this makes it hard search for files in the mounted data folder. Why are we doing it this way opposed to the logical way of mounting at the pwd?

Also, you can query appRunner.installedPackages to get a list of the installed packages as PackageInfo objects. PackageInfo has a getPackageDir() method that returns the directory in which it is installed. So, here’s an example:

vfs = VirtualFileSystem.getGlobalPtr()

for pkg in appRunner.installedPackages:
  if pkg.packageName == "data":
    myfile = Filename(pkg.getPackageDir(), "myfile.txt")
    if vfs.exists(myfile):
        print "Found a 'data' package with 'myfile.txt'"
        break

Maybe there’s a setting to mount it at the current directory, I wouldn’t know. I’m sure David knows if that’s possible.

I think the way its done now is to reduce name collisions. Maybe packages should have an option to mount them at pwd or pwd/directry.

I think the problem is that some files can’t be read from VFS, but must be extracted. Libraries and binaries are examples of that.

Note that the runtime defines an environment variable for each mounted package that defines its path. So you can use $PACKAGENAME_ROOT to reference the path in, e.g., a prc file, or in your application with Filename.expandFrom(’$PACKAGENAME_ROOT’) or even os.environ[‘PACKAGENAME_ROOT’].

The name of the environment variable is the name of the package, converted to uppercase, with _ROOT appended.

David

Right now I get list of all my mounted packages, and remount them to the pwd. That seems to work. Do you think that would cause any unknown bad things?

Hmm, it seems clumsy. Is it really that hard to search from the package root instead of from the current directory?

David

I have couple of places that search the directory structure. It just looks cleaner doing one fix at the start of the program then doing it many of times in different places.

Could also be problematic if I wanted to search across packages.

This setup also mimics how i have it setup in development to limit surprises like this was.