silx.resources: Project resources access

Access project’s data and documentation files.

All access to data and documentation files MUST be made through the functions of this modules to ensure access across different distribution schemes:

  • Installing from source or from wheel

  • Installing package as a zip (through the use of pkg_resources)

  • Linux packaging willing to install data files (and doc files) in alternative folders. In this case, this file must be patched.

  • Frozen fat binary application using silx (frozen with cx_Freeze or py2app). This needs special care for the resource files in the setup:

    • With cx_Freeze, add silx/resources to include_files:

      import silx.resources
      silx_include_files = (os.path.dirname(silx.resources.__file__),
                            os.path.join('silx', 'resources'))
      setup(...
            options={'build_exe': {'include_files': [silx_include_files]}}
            )
      
    • With py2app, add silx in the packages list of the py2app options:

      setup(...
            options={'py2app': {'packages': ['silx']}}
            )
      
silx.resources.resource_filename(resource)[source]

Return filename corresponding to resource.

resource can be the name of either a file or a directory. The existence of the resource is not checked.

Parameters:resource (str) – Resource path relative to resource directory using ‘/’ path separator.
Returns:Absolute resource path in the file system
class silx.resources.ExternalResources(project, url_base, env_key=None, timeout=60)[source]

Utility class which allows to download test-data from www.silx.org and manage the temporary data during the tests.

clean_up()[source]

Removes the temporary directory (and all its content !)

getfile(filename)[source]

Downloads the requested file from web-server available at https://www.silx.org/pub/silx/

Param:relative name of the image.
Returns:full path of the locally saved file.
getdir(dirname)[source]

Downloads the requested tarball from the server https://www.silx.org/pub/silx/ and unzips it into the data directory

Param:relative name of the image.
Returns:full path of the locally saved file.
download_all(imgs=None)[source]

Download all data needed for the test/benchmarks

Parameters:imgs – list of files to download, by default all
Returns:list of path with all files

Previous topic

silx.math.combo: Statistics combo functions

Next topic

silx.utils:

This Page