On Mon, Apr 26, 2010 at 11:56 PM, Robert Kern <robert.k...@gmail.com> wrote: [..] > > I don't think the OP is really speaking against using __file__ per se, but > rather putting data into the package however it is accessed. The > Linux-packager preferred practice is to install into the appropriate > /usr/shared/ subdirectory. Writing portable libraries (with portable > setup.py files!) is difficult to do that way, though.
Well, the only portable way to read a resource file these days in Python is to put it in your project source tree so you know for sure you can access it the same way no matter what the platform is. Thus, using __file__. The key to fix this is to have a registered list of paths for each platform at Python level. Roughly summarized : the work we are doing will consist of defining variables that points to target paths for each platform (like /usr/shared in linux) at Python level, and let the developers define that a file is under a path defined by a variable (like "shared"). For example, a project will be able to read/write the "foo.txt" file using: pkgutil.open('shared', 'foo.txt') pkgutil will look in Python for the path corresponding to "shared" and expand it. The result will vary depending on the platform, and the os packagers will be able to change that path globally in Python or locally in the project. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com