This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: new importlib dependencies csv, email and zipfile
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, barry, brett.cannon, doko, eric.snow, jaraco, ncoghlan, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-06-05 10:55 by doko, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (8)
msg344703 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2019-06-05 10:55
compared to 3.8 alpha4, beta1's importlib has three new dependencies csv, email and zipfile.  Is this intended, or should the toplevel imports in importlib.metadata be moved into the functions where these are once used?
msg344728 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2019-06-05 14:43
I imagine that importlib.metadata isn’t imported at bootstrap time, only after the import infrastructure is ready. I think an early failure to import one of those dependencies is desirable. What is the reasoning behind deferring the imports and why does it apply to this module?
msg344731 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-06-05 15:14
at least for debian, the motivation is to provide a `pythonX.X-minimal` and a `pythonX.X` package -- the former ~mostly just contains the interpreter and the latter includes the stdlib

(I'm interested as well, hit this packaging 3.8 for deadsnakes)
msg344740 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-05 15:56
I have not found zipfile here.

email is used for parsing METADATA and PKG-INFO. It replaces the rfc822 module.

cvs is used for parsing RECORD and SOURCES.txt. Actually using it for for parsing SOURCES.txt is improper as it might contain double quotes or backslashes (unlikely but possible).
msg344754 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-06-05 17:37
The imports are on purpose but they are not required for import to run, just like importlib.resources isn't necessary.
msg344786 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2019-06-06 04:14
yes, that's for the minimal package.

zipfile is found in Lib/importlib/_bootstrap_external.py

Again, it's just a question here, having found an unmotivated distutils import before in one of the standard modules.
msg344897 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-06-07 04:56
@staticmethod
    def _switch_path(path):
        from contextlib import suppress
        import zipfile
        from pathlib import Path
        with suppress(Exception):
            return zipfile.Path(path)
        return Path(path)

Oh, I did not know about zipfile.Path!

I do not think this is a correct solution. It does not work with general loaders. I think that it would be more correct to override some methods in zipimport.
msg345009 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-06-07 20:56
@serhiy: mind opening a new issue for your zipfile.Path worry?
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81343
2019-06-07 20:56:46brett.cannonsetmessages: + msg345009
2019-06-07 04:56:56serhiy.storchakasetmessages: + msg344897
2019-06-06 19:23:23brett.cannonsetstatus: open -> closed
stage: resolved
2019-06-06 04:14:01dokosetresolution: not a bug
messages: + msg344786
2019-06-05 17:37:42brett.cannonsetmessages: + msg344754
2019-06-05 15:56:42serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg344740
2019-06-05 15:14:14Anthony Sottilesetnosy: + Anthony Sottile
messages: + msg344731
2019-06-05 14:43:36jaracosetmessages: + msg344728
2019-06-05 11:20:18xtreaksetnosy: + barry, jaraco
2019-06-05 10:55:09dokocreate