classification
Title: Allow to restrict ModuleFinder to get "direct" dependencies
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: eric.araujo, eric.snow, jvr, misc, ncoghlan, nnorwitz, theller
Priority: normal Keywords: easy, patch

Created on 2005-09-08 09:28 by misc_from_metz, last changed 2013-01-25 19:18 by brett.cannon.

Files
File name Uploaded Description Edit
modulefinder.no_recurse.diff misc_from_metz, 2005-09-08 09:28 Add a parameter to ModuleFinder, to not recurse when searching module.
modulefinder-no-recurse.diff eric.araujo, 2011-07-29 13:53 review
Messages (10)
msg48725 - (view) Author: Scherer Michael (misc_from_metz) Date: 2005-09-08 09:28
this patch add a parameter to ModuleFinder, to not
recurse when searching module.
This way, someone can compute the modules needed by a
specific file, without having to compute all other
imported module, which may take time for result that
are no t needed. 

With the current system, you cannot create a clean
graph of modules dependancy, since  they are all on the
same level.

This patch do not change the default behavior.


msg48726 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2005-10-01 03:39
Logged In: YES 
user_id=33168

Thomas are you the defacto maintainer of modulefinder?  Any
comments?
msg48727 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2007-06-08 19:48
I have no time or interest in this patch, so unassigning.
msg114551 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-21 19:19
Anyone interested in this or can it be closed?
msg114553 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-21 19:33
Adding jvr and people interested in import machinery, per Misc/maintainers.rst

Michael, can you refresh your patch against the py3k branch? Please also generate a unified diff from the top level of the source distribution, as detailed in http://www.python.org/dev/patches/ The feature seems useful to me and the patch is straightforward. Tests and doc updates are needed; do you want to add them?

Mark, I think that feature requests are never closed just because they’re old; they have to be rejected, implemented or obsoleted. (Thank you for all your triage work.)
msg114645 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2010-08-22 08:42
The generalist in me is inclined to suggest a "depth" parameter (with depth=1 equivalent to direct dependencies only, and depth = None meaning all dependencies), but I must admit I don't have a concrete use case for the extra generality. So the simpler, recurse/don't recurse approach is probably a better option (building a depth-limited search on top of the recursion flag wouldn't be difficult anyway).

Aside from missing docs and unit test updates, the idea seems sound.
msg114646 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2010-08-22 08:45
Although I do find it a little concerning that there is no mention of sys.path_hooks or sys.meta_path in the modulefinder source code. I suspect this module only works correctly with vanilla filesystem based imports and can't handle anything imported via PEP 302.
msg124928 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-12-30 18:37
The depth parameter idea sounds like YAGNI, so let’s stay with a recurse boolean :)
msg140602 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-18 16:23
I applied the patch, added a test and found a bug.  Here’s my progress so far; someone can start from it to write more tests and fix the code.
msg141381 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-07-29 13:53
I modernized modulefinder a bit in 1521d9837d16; here’s a refreshed patch.
History
Date User Action Args
2013-01-25 19:18:16brett.cannonsetnosy: - brett.cannon
2011-07-29 13:53:58eric.araujosetfiles: + modulefinder-no-recurse.diff

messages: + msg141381
2011-07-29 13:52:42eric.araujosetfiles: - modulefinder-no-recurse.diff
2011-07-18 16:32:20eric.snowsetnosy: + eric.snow
2011-07-18 16:23:56eric.araujosetfiles: + modulefinder-no-recurse.diff
nosy: + misc
messages: + msg140602

2010-12-30 18:37:02eric.araujosetversions: + Python 3.3, - Python 3.2
nosy: - misc_from_metz, BreamoreBoy

messages: + msg124928

assignee: eric.araujo
stage: test needed -> patch review
2010-08-22 08:45:21ncoghlansetmessages: + msg114646
2010-08-22 08:42:18ncoghlansetmessages: + msg114645
2010-08-21 19:33:56eric.araujosetnosy: + eric.araujo, jvr, brett.cannon, ncoghlan
messages: + msg114553
2010-08-21 19:19:00BreamoreBoysetnosy: + BreamoreBoy

messages: + msg114551
versions: + Python 3.2, - Python 2.7
2009-04-22 05:08:10ajaksu2setkeywords: + easy
2009-03-31 01:19:22ajaksu2setstage: test needed
type: enhancement
versions: + Python 2.7
2005-09-08 09:28:31misc_from_metzcreate