Skip to content

Commit

Permalink
Merge branch 'issue64' into 'master'
Browse files Browse the repository at this point in the history
Add an important note about Python < 3.7

Closes python#64

See merge request python-devs/importlib_resources!65
  • Loading branch information
warsaw committed Sep 7, 2018
2 parents 1bee4dd + 6f880d6 commit e6e4e46
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions importlib_resources/docs/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,27 @@ manager that you can use in a ``with``-statement::
You can use all the standard :py:mod:`contextlib` APIs to manage this context
manager.

.. attention::

There is an odd interaction with Python 3.4, 3.5, and 3.6 regarding adding
zip or wheel file paths to ``sys.path``. Due to limitations in `zipimport
<https://docs.python.org/3/library/zipimport.html>`_, which can't be
changed without breaking backward compatibility, you **must** use an
absolute path to the zip/wheel file. If you use a relative path, you will
not be able to find resources inside these zip files. E.g.:

**No**::

sys.path.append('relative/path/to/foo.whl')
resource_bytes('foo/data.dat') # This will fail!

**Yes**::

sys.path.append(os.path.abspath('relative/path/to/foo.whl'))
resource_bytes('foo/data.dat')

Both relative and absolute paths work for Python 3.7 and newer.


.. rubric:: Footnotes

Expand Down

0 comments on commit e6e4e46

Please sign in to comment.