Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4021756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:23:28+00:00 2026-05-20T10:23:28+00:00

Is it possible to programmatically detect dependencies given a python project residing in SVN?

  • 0

Is it possible to programmatically detect dependencies given a python project residing in SVN?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:23:29+00:00Added an answer on May 20, 2026 at 10:23 am

    Here is a twist which adds some precision, and which might be useful if you find you’re frequently checking dependencies of miscellaneous code:

    • Catches only import statements executed by the code being analyzed.
    • Automatically excludes all system-loaded modules, so you don’t have to weed through it.
    • Also reports the symbols imported from each module.

    Code:

    import __builtin__
    import collections
    import sys
    
    IN_USE = collections.defaultdict(set)
    _IMPORT = __builtin__.__import__
    
    def _myimport(name, globs=None, locs=None, fromlist=None, level=-1):
        global IN_USE
        if fromlist is None:
            fromlist = []
        IN_USE[name].update(fromlist)
        return _IMPORT(name, globs, locs, fromlist, level)
    
    # monkey-patch __import__
    setattr(__builtin__, '__import__', _myimport)
    
    # import and run the target project here and run the routine
    import foobar
    foobar.do_something()
    
    # when it finishes running, dump the imports
    print 'modules and symbols imported by "foobar":'
    for key in sorted(IN_USE.keys()):
        print key
        for name in sorted(IN_USE[key]):
            print '  ', name
    

    Example foobar module:

    import byteplay
    import cjson
    
    def _other():
        from os import path
        from sys import modules
    
    def do_something():
        import hashlib
        import lxml
        _other()
    

    Output:

    modules and symbols imported by "foobar":
    _hashlib
    array
       array
    byteplay
    cStringIO
       StringIO
    cjson
    dis
       findlabels
    foobar
    hashlib
    itertools
    lxml
    opcode
       *
       __all__
    operator
    os
       path
    sys
       modules
    types
    warnings
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Best way to programmatically detect iPad/iPhone hardware For example I want my
Is it possible to programmatically either via the win32API (python) or via a command
Possible Duplicate: Programmatically detect if app is being run on device or simulator How
Possible Duplicate: Detecting iPad 3 vs iPad 2 device? Programmatically detect an iPad 3
Is it possible to programmatically reload a C# project? In one of my previous
Is it possible to programmatically find out how core data matches a given class
Possible Duplicate: Best way to programmatically detect iPad/iPhone hardware How can I differentiate the
Possible Duplicate: Programmatically delete my own app Currently I am working on a iphone
Is it possible to programmatically push files to a wireless SD card - like
Is it possible to programmatically, or otherwise, increase the width of the Windows console

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.