classification
Title: Update zipimport to support importlib.invalidate_caches()
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, crwilcox, eric.araujo, eric.smith, eric.snow, gregory.p.smith, ncoghlan, serhiy.storchaka, superluser
Priority: normal Keywords: easy

Created on 2012-04-26 17:41 by brett.cannon, last changed 2020-02-10 19:34 by crwilcox.

Messages (8)
msg159404 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-04-26 17:41
zipimport's finders that get cached in sys.path_importer_cache should probably be updated to support importlib.invalidate_caches() (else the module should get re-implemented in pure Python in importlib and then be tossed).
msg159406 - (view) Author: √Čric Araujo (eric.araujo) * (Python committer) Date: 2012-04-26 17:48
zipimport in Python sounds good to me.
msg159948 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-05-04 17:34
I should mention I have a version from importers that is probably out-of-date: http://code.google.com/p/importers/source/browse/importers/zip.py
msg159979 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-05-05 06:51
Moving zipimporter to Python code is harder than it sounds: we don't want to break the ability to ship the standard library itself inside a zipfile.

If you try to move zipimporter to pure Python, you could easily end up with a *very* ugly bootstrapping problem, on par with that already encountered when hacking on importlib._bootstrap.

In fact, the path of least resistance here might actually be to implement zipimporter directly *in* importlib._bootstrap.
msg160022 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-05-05 19:06
The real problem becomes the issue of what zipfile depends on, which complicates bootstrapping. I mean things could go as far as to write a script that takes in anchor points in the stdlib and freezes all code they depend on, but that seems like potential overkill and executable bloat.

But something needs to happen as zipimporter has major shortcomings thanks to to its re-implementation of zip handling (e.g. no ZIP64 support, etc.). Plus no one ever wants to touch that code.
msg197551 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2013-09-13 05:24
Brett wrote a pure python zipimporter in http://bugs.python.org/issue17630 :)

FWIW, the zipimport.c implementation (in 2.7) causes us serious pain when we've got the stdlib in a .zip file and need to update that while there are running python processes (which have cached the central directory of that .zip file but do not also keep a fd to the zip file open or even attempt to stat the file to see if it has changed [racy but it'd still be better than the nothing that is done now]).
msg325715 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-19 07:11
zipimport have been rewritten in pure Python (issue25711).
msg361711 - (view) Author: Chris Wilcox (crwilcox) * Date: 2020-02-10 19:34
What work remains to be done for this issue?
History
Date User Action Args
2020-02-10 19:34:40crwilcoxsetnosy: + crwilcox
messages: + msg361711
2020-01-29 00:50:15brett.cannonsetkeywords: + easy
2018-09-19 07:11:29serhiy.storchakasetversions: + Python 3.8, - Python 3.6
nosy: + serhiy.storchaka

messages: + msg325715

type: behavior -> enhancement
2015-08-05 15:59:43eric.snowsetnosy: + superluser

versions: + Python 3.6, - Python 3.3
2013-09-13 05:24:31gregory.p.smithsetnosy: + gregory.p.smith
messages: + msg197551
2012-05-05 19:19:42eric.snowsetnosy: + eric.snow
2012-05-05 19:06:49brett.cannonsetmessages: + msg160022
2012-05-05 06:51:01ncoghlansetnosy: + ncoghlan
messages: + msg159979
2012-05-04 17:34:36brett.cannonsetmessages: + msg159948
2012-04-26 18:02:33eric.smithsetnosy: + eric.smith
2012-04-26 17:48:47eric.araujosetnosy: + eric.araujo
messages: + msg159406
2012-04-26 17:41:49brett.cannoncreate