Code Monkey home page Code Monkey logo

Comments (4)

thebjorn avatar thebjorn commented on August 16, 2024

Is this just convenience functionality to not need to find the location of a module, or is there something special about modules found with find_spec?

from pydeps.

furechan avatar furechan commented on August 16, 2024

Hi, yes it is mostly a convenience. If you have lots of packages installed, some editable some not editable, depending on which env, etc it can be a lot of work to seek them in the folder tree. Also if you want to automate some sort of reporting, it makes sense to have a central place to call pydeps independently of the location of the various project worspaces. I could create a custom wrapper around pydeps but I thought it'd more practical to have this builtin ...
Thank You

from pydeps.

Hnasar avatar Hnasar commented on August 16, 2024

Passing the filename can cause pydeps to incorrectly resolve imports.

If you have modules like:

a.b
a.c
c

and a/b.py has import c

then passing pydeps a/b.py --show-deps will show that import c is resolved to a/c.py which is incorrect.
(If a/b.py were to import a/c.py then it would need to do either import a.c or from . import c OR a/b.py must be run as a script (so that pythona adds a/ to sys.path)

But if we were able to run pydeps -m a.b then pydeps ought to know not to resolve import c to a/c.py.

edit: Oh I guess it resolves differently if a is a namespace package (i.e. if a/__init__.py exists or not)

from pydeps.

thebjorn avatar thebjorn commented on August 16, 2024

Python seems to think that a/c.py is correct, ie.:

\tmp\pydeps199\src> yamldirs .
.:
  __init__.py: ''
  a:
    __init__.py: ''
    b.py: |
      print('a/b.py')
      import c
    c.py: print('a/c.py')
  c.py: print('/c.py')

Python:

\tmp\pydeps199\src> py -3.12 a\b.py
a/b.py
a/c.py

You might be running into the difference in import-behavior between scripts and imports..?

from pydeps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.