8000 Detect if package is installed editable · Issue #404 · python/importlib_metadata · GitHub
[go: up one dir, main page]

Skip to content
10000
Detect if package is installed editable #404
Closed
@kasium

Description

@kasium

Hey,

Not sure if this is the right place and/or right package to ask, but you need to start somewhere 😄 .

I have the following case: A script in a distributable should behave differently if it's started by the distributable or by anther project just importing the distributable.

For instance, the distributable has the name foo.
If I developing foo currently and I execute foo.py it should return 1. If another project depends on foo and executes foo.py after installing foo over pip it should return 2.

Since there seems to be no reliable way, for now I use the assumption that current project means editable install. With that I can use

 distribution = pkg_resources.get_distribution("foo")
 is_foo= "dist-info" not in distribution.egg_info

So if foo is installed editable, the egg_info has no dist-info. But that's very hacky.

Therefore, how can I improve this?

  1. do you have anything in mind which would solve the below issue in the first place
  2. if not, do you think you can expose the direct_url.json of PEP 660 somehow? It would help to detect if it's an editable install w/o finding/parsing the file on my own

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0