Skip to content

use importlib.metadata.version to get package version #2316

@davidism

Description

@davidism

Problem Statement

Modern packaging metadata provides a standard way to get the version of any package. Flask and other Pallets projects will be deprecating the __version__ attribute. Instead, use importlib.metadata.version if the version is needed (or use feature detection). This will work regardless of what version is installed.

It looks like your Pyramid integration already does this, might be worth it to use the standard consistently across all integrations.

Solution Brainstorm

Replace from flask import __version__ as FLASK_VERSION with FLASK_VERSION = importlib.metadata.version("flask"). Possibly replace all __version__ imports.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions