Python package data cache

I have a python module that generates large data files that I want to cache on disk for future use. The cache will probably end up being several hundred MB for the average user, but it will save a lot of computation time.

Files are not distributed with the module, but are generated the first time the code is run with a given set of parameters.

So far, I have only used one file module myself and put them in a hardcoded path relative to the module (data /). But now I need to distribute this module in a Python package with distutils, and I was wondering if there is a standard way to do this.

I was thinking of something like the compiled scipy.weave cache, but wondered if there is a more modern supported way to do this. On * nix platforms, I would expect it to go in ~/.something, but I'm not sure what the Windows equivalent is. It should also be configured so that users can specify it somewhere else, if it was more convenient, or share the cache between users. How should such a configuration file work? Where should he go?

Or do I just need to install it as an installation, either through the configuration file next to setup.py, or by manually editing setup.py, and then hard-code the directory in the module before installation?

Any pointers appreciated ...

+3
source share
2

ConfigParser ini ( .rc ). , os.path.expanduser - , , "~/.mytoolrc". , os.environ.

+3

Source: https://habr.com/ru/post/1725173/


All Articles