- Omit sentinel values from a namespace path. (#311)
No significant changes.
- When inferring the caller in
files()
correctly detect one's own module even when the resources package source is not present. (python/cpython#123085)
- Merged fix for UTF-16 BOM handling in functional tests. (#312)
- When constructing ZipReader, only append the name if the indicated module is a package. (python/cpython#121735)
- The functions
is_resource()
,open_binary()
,open_text()
,path()
,read_binary()
, andread_text()
are un-deprecated, and support subdirectories via multiple positional arguments. Thecontents()
function also allows subdirectories, but remains deprecated. (#303) - Deferred select imports in for a speedup (python/cpython#109829).
- Restored expectation that local standard readers are preferred over degenerate readers. (#298)
- Restored expectation that stdlib readers are suppressed on Python 3.10. (#257)
- Add
Anchor
toimportlib.resources
(in order for the code to comply with the documentation)
- Future compatibility adapters now ensure that standard library readers are replaced without overriding non-standard readers. (#295)
No significant changes.
- Fixed NotADirectoryError when calling files on a subdirectory of a namespace package. (#293)
- Added missed stream argument in simple.ResourceHandle. Ref python/cpython#111775.
- MultiplexedPath now expects Traversable paths. String arguments to MultiplexedPath are now deprecated.
- Enabled support for resources in namespace packages in zip files. (#287)
- Restored Apache license. (#285)
- Removed legacy functions deprecated in 5.3. (#80)
- Require Python 3.8 or later.
- #257:
importlib_resources
(backport) now gives precedence to built-in readers (file system, zip, namespace packages), providing forward-compatibility of behaviors likeMultiplexedPath
.
- #280: Fixed one more
EncodingWarning
in test suite.
- #265:
MultiplexedPath
now honors multiple subdirectories initerdir
andjoinpath
.
- Packaging refresh, including fixing EncodingWarnings and some tests cleanup.
- #274: Prefer
write_bytes
to context manager as proposed in gh-100586.
- #274: Fixed
ResourceWarning
in_common
.
- #203: Lifted restriction on modules passed to
files
. Now modules need not be a package and if a non-package module is passed, resources will be resolved adjacent to those modules, even for modules not found in any package. For example,files(import_module('mod.py'))
will resolve resources found at the root. The parameter to files was renamed from 'package' to 'anchor', with a compatibility shim for those passing by keyword. - #259:
files
no longer requires the anchor to be specified and can infer the anchor from the caller's scope (defaults to the caller's module).
- #228:
as_file
now also supports aTraversable
representing a directory and (when needed) renders the full tree to a temporary directory.
- #253: In
MultiplexedPath
, restore expectation that a compound path with a non-existent directory does not raise an exception.
- #250: Now
Traversable.joinpath
provides a concrete implementation, replacing the implementation in.simple
and converging with the behavior inMultiplexedPath
.
- #249: In
simple.ResourceContainer.joinpath
, honor names split byposixpath.sep
.
#248:
abc.Traversable.joinpath
now allows for multiple arguments and specifies thatposixpath.sep
is allowed in any argument to accept multiple arguments, matching the behavior found inzipfile.Path
andpathlib.Path
.simple.ResourceContainer
now honors this behavior.
- #244: Add type declarations in ABCs.
- Require Python 3.7 or later.
- #243: Fix error when no
__pycache__
directories exist when testingupdate-zips
.
- #80: Test suite now relies entirely on the traversable API.
- #80: Now raise a
DeprecationWarning
for all legacy functions. Instead, users should rely on thefiles()
API introduced in importlib_resources 1.3. See Migrating from Legacy for guidance on avoiding the deprecated functions.
- Updated readme to reflect current behavior and show which versions correspond to which behavior in CPython.
- bpo-45419: Correct
DegenerateFiles.Path
.name
and.open()
interfaces to matchTraversable
.
- #234: Fix refleak in
as_file
caught by CPython tests.
- bpo-38291: Avoid DeprecationWarning on
typing.io
.
- #80 via #221: Legacy API (
path
,contents
, ...) is now supported entirely by the.files()
API with a compatibility shim supplied for resource loaders without that functionality.
- bpo-38693: Prefer f-strings to
.format
calls.
- #225: Require zipp 3.1.0 or later on Python prior to 3.10 to incorporate those fixes.
- #216: Make MultiplexedPath.name a property per the spec.
- Refresh packaging and improve tests.
- #216: Make MultiplexedPath.name a property per the spec.
- Re-release with changes from 5.0.4.
- Fixed non-hermetic test in test_reader, revealed by GH-24670.
- Re-release with changes from 5.0.3.
- Simplified DegenerateFiles.Path.
- #214: Added
_adapters
module to ensure that degeneratefiles
behavior can be made available for legacy loaders whose resource readers don't implement it. Fixes issue where backport compatibility module was masking this fallback behavior only to discover the defect when applying changes to CPython.
- Added
simple
module implementing adapters from a low-level resource reader interface to aTraversableResources
interface. Closes #90.
- Remove pyinstaller hook for hidden 'trees' module.
- Removed
importlib_resources.trees
, deprecated since 1.3.0.
- Fixed badges in README.
- #209: Adopt jaraco/skeleton.
- Cleaned up some straggling Python 2 compatibility code.
- Refreshed test zip files without .pyc and .pyo files.
- #108: Drop support for Python 2.7. Now requires Python 3.6+.
- Minor cleanup.
- #107: Drop support for Python 3.5. Now requires Python 2.7 or 3.6+.
- #200: Minor fixes and improved tests for namespace package support.
- #68: Resources in PEP 420 Namespace packages are now supported.
- bpo-41490:
contents
is now also more aggressive about consuming any iterator from theReader
.
- #110 and bpo-41490:
path
method is more aggressive about releasing handles to zipfile objects early, enabling use-cases likecertifi
to leave the context open but delete the underlying zip file.
- Package no longer exposes
importlib_resources.__version__
. Users that wish to inspect the version ofimportlib_resources
should instead invoke.version('importlib_resources')
fromimportlib-metadata
( stdlib or backport) directly. This change eliminates the dependency onimportlib_metadata
. Closes #100. - Package now always includes its data. Closes #93.
- Declare hidden imports for PyInstaller. Closes #101.
- Select pathlib and contextlib imports based on Python version and avoid pulling in deprecated [pathlib](https://pypi.org/project/pathlib). Closes #97.
- Loaders are no longer expected to implement the
abc.TraversableResources
interface, but are instead expected to returnTraversableResources
from theirget_resource_reader
method.
- Traversable is now a Protocol instead of an Abstract Base Class (Python 2.7 and Python 3.8+).
- Traversable objects now require a
.name
property.
- #79: Temporary files created will now reflect the filename of their origin.
- For improved compatibility,
importlib_resources.trees
is now imported implicitly. Closes #88.
- Add extensibility support for non-standard loaders to supply
Traversable
resources. Introduces a new abstract base classabc.TraversableResources
that supersedes (but implements for compatibility)abc.ResourceReader
. Any loader that implements (implicitly or explicitly) theTraversableResources.files
method will be capable of supplying resources with subdirectory support. Closes #77. - Preferred way to access
as_file
is now from top-level module.importlib_resources.trees.as_file
is deprecated and discouraged. Closes #86. - Moved
Traversable
abc toabc
module. Closes #87.
- Traversable now requires an
open
method. Closes #81. - Fixed error on
Python 3.5.{0,3}
. Closes #83. - Updated packaging to resolve version from package metadata. Closes #82.
Add support for retrieving resources from subdirectories of packages through the new
files()
function, which returns aTraversable
object withjoinpath
andread_*
interfaces matching those ofpathlib.Path
objects. This new function supersedes all of the previous functionality as it provides a more general-purpose access to a package's resources.With this function, subdirectories are supported (Closes #58).
The documentation has been updated to reflect that this function is now the preferred interface for loading package resources. It does not, however, support resources from arbitrary loaders. It currently only supports resources from file system path and zipfile packages (a consequence of the ResourceReader interface only operating on Python packages).
- Fix
setup_requires
andinstall_requires
metadata insetup.cfg
. Given by Anthony Sottile.
- Update Trove classifiers. Closes #63
- Backport fix for test isolation from Python 3.8/3.7. Closes #61
- Strip
importlib_resources.__version__
. Closes #56 - Fix a metadata problem with older setuptools. Closes #57
- Add an
__all__
toimportlib_resources
. Closes #59
- Fix
setup.cfg
metadata bug. Closes #55
- Move everything from
pyproject.toml
tosetup.cfg
, with the added benefit of fixing the PyPI metadata. Closes #54 - Turn off mypy's
strict_optional
setting for now.
- Resynchronize with Python 3.7; changes the return type of
contents()
to be anIterable
. Closes #52
- Correctly find resources in subpackages inside a zip file. Closes #51
- The API, implementation, and documentation is synchronized with the Python 3.7 standard library. Closes #47
- When run under Python 3.7 this API shadows the stdlib versions. Closes #50
- Backward incompatible change. Split the
open()
andread()
calls into separate binary and text versions, i.e.open_binary()
,open_text()
,read_binary()
, andread_text()
. Closes #41 - Fix a bug where unrelated resources could be returned from
contents()
. Closes #44 - Correctly prevent namespace packages from containing resources. Closes #20
- Initial release.