Skip to content

Commit e6e4e46

Browse files
committed
Merge branch 'issue64' into 'master'
Add an important note about Python < 3.7 Closes python#64 See merge request python-devs/importlib_resources!65
2 parents 1bee4dd + 6f880d6 commit e6e4e46

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

importlib_resources/docs/using.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,27 @@ manager that you can use in a ``with``-statement::
150150
You can use all the standard :py:mod:`contextlib` APIs to manage this context
151151
manager.
152152

153+
.. attention::
154+
155+
There is an odd interaction with Python 3.4, 3.5, and 3.6 regarding adding
156+
zip or wheel file paths to ``sys.path``. Due to limitations in `zipimport
157+
<https://docs.python.org/3/library/zipimport.html>`_, which can't be
158+
changed without breaking backward compatibility, you **must** use an
159+
absolute path to the zip/wheel file. If you use a relative path, you will
160+
not be able to find resources inside these zip files. E.g.:
161+
162+
**No**::
163+
164+
sys.path.append('relative/path/to/foo.whl')
165+
resource_bytes('foo/data.dat') # This will fail!
166+
167+
**Yes**::
168+
169+
sys.path.append(os.path.abspath('relative/path/to/foo.whl'))
170+
resource_bytes('foo/data.dat')
171+
172+
Both relative and absolute paths work for Python 3.7 and newer.
173+
153174

154175
.. rubric:: Footnotes
155176

0 commit comments

Comments
 (0)