Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
I
importlib_metadata
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 10
    • Issues 10
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 3
    • Merge Requests 3
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • python-devs
  • importlib_metadata
  • Issues
  • #131

Closed
Open
Opened Oct 16, 2020 by 8day@8day

No way to detect "import packages" in multi-package "distribution packages"

Apart from Distribution.from_name() there must exist Distribution.from_package_name(). E.g., pkg_resources from setuptools can't be found with importlib_metadata.Distribution.from_name('pkg_resources'). Another example is PyYAML (dist name) that contains yaml (package name).

Most likely for this to work dists will need Provides-Dist: {dist}:{pkg} to be defined in their metadata. Considering that it seems that nobody uses a proper solution, ATM can be implemented as a hack: check if *.dist-info/top_level.txt exists and *.dist-info/INSTALLER contains pip, then use contents of *.dist-info/top_level.txt to list "import packages" contained by "distribution package".

This will require Package to be added, which will complicate things quite a bit: e.g., Package.files() will have to return files stored within package, and not entire distribution. Also, this will require adjustment of terminology, seeing as ATM "package" is more or less the same as "distribution package".

Note that this will require reading of metadata of all found dists, which will be extremely inefficient.

All of this can be avoided by a switch to another, mono-package dist format and preferably metadata format, but that's a topic for another discussion...

Edit: I could sware I've read about notation like Provides-Dist: {dist}:{pkg} in one of the PEPs, but can't find any sources...

Edited Oct 16, 2020 by 8day
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: python-devs/importlib_metadata#131