epregistry


Nameepregistry JSON
Version 1.3.0 PyPI version JSON
download
home_pageNone
SummaryA registry for entry points (cached and generically typed)
upload_time2025-10-06 20:30:03
maintainerNone
docs_urlNone
authorPhilipp Temminghoff
requires_python>=3.12
licenseMIT License Copyright (c) 2024, Philipp Temminghoff Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # epregistry

[![PyPI License](https://img.shields.io/pypi/l/epregistry.svg)](https://pypi.org/project/epregistry/)
[![Package status](https://img.shields.io/pypi/status/epregistry.svg)](https://pypi.org/project/epregistry/)
[![Monthly downloads](https://img.shields.io/pypi/dm/epregistry.svg)](https://pypi.org/project/epregistry/)
[![Distribution format](https://img.shields.io/pypi/format/epregistry.svg)](https://pypi.org/project/epregistry/)
[![Wheel availability](https://img.shields.io/pypi/wheel/epregistry.svg)](https://pypi.org/project/epregistry/)
[![Python version](https://img.shields.io/pypi/pyversions/epregistry.svg)](https://pypi.org/project/epregistry/)
[![Implementation](https://img.shields.io/pypi/implementation/epregistry.svg)](https://pypi.org/project/epregistry/)
[![Releases](https://img.shields.io/github/downloads/phil65/epregistry/total.svg)](https://github.com/phil65/epregistry/releases)
[![Github Contributors](https://img.shields.io/github/contributors/phil65/epregistry)](https://github.com/phil65/epregistry/graphs/contributors)
[![Github Discussions](https://img.shields.io/github/discussions/phil65/epregistry)](https://github.com/phil65/epregistry/discussions)
[![Github Forks](https://img.shields.io/github/forks/phil65/epregistry)](https://github.com/phil65/epregistry/forks)
[![Github Issues](https://img.shields.io/github/issues/phil65/epregistry)](https://github.com/phil65/epregistry/issues)
[![Github Issues](https://img.shields.io/github/issues-pr/phil65/epregistry)](https://github.com/phil65/epregistry/pulls)
[![Github Watchers](https://img.shields.io/github/watchers/phil65/epregistry)](https://github.com/phil65/epregistry/watchers)
[![Github Stars](https://img.shields.io/github/stars/phil65/epregistry)](https://github.com/phil65/epregistry/stars)
[![Github Repository size](https://img.shields.io/github/repo-size/phil65/epregistry)](https://github.com/phil65/epregistry)
[![Github last commit](https://img.shields.io/github/last-commit/phil65/epregistry)](https://github.com/phil65/epregistry/commits)
[![Github release date](https://img.shields.io/github/release-date/phil65/epregistry)](https://github.com/phil65/epregistry/releases)
[![Github language count](https://img.shields.io/github/languages/count/phil65/epregistry)](https://github.com/phil65/epregistry)
[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/epregistry)](https://github.com/phil65/epregistry)
[![Package status](https://codecov.io/gh/phil65/epregistry/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/epregistry/)
[![PyUp](https://pyup.io/repos/github/phil65/epregistry/shield.svg)](https://pyup.io/repos/github/phil65/epregistry/)

[Read the documentation!](https://phil65.github.io/epregistry/)

## Overview

The Entry Point Registry system provides a convenient way to manage and access Python entry points. It offers two different approaches to work with entry points:
- Group-based access: Work with all entry points in a specific group
- Module-based access: Work with all entry points provided by a specific module

This flexibility makes it particularly useful for plugin systems, extensions, or any modular components in Python applications.

## Basic Usage

### Group-based Registry

When you want to work with entry points organized by their group:

```python
from epregistry import EntryPointRegistry

# Create a registry for console scripts
registry = EntryPointRegistry[Callable]("console_scripts")

# Get and load an entry point
script = registry.load("my-script")

# Get all entry points in the group
all_scripts = registry.get_all()
```

### Module-based Registry

When you want to work with all entry points provided by a specific module:

```python
from epregistry import ModuleEntryPointRegistry

# Create a registry for a specific module
registry = ModuleEntryPointRegistry[Any]("your_module_name")

# Get all groups that have entry points from this module
groups = registry.groups()

# Get entry points for a specific group
group_eps = registry.get_group("console_scripts")

# Load all entry points for a group
loaded_eps = registry.load_group("console_scripts")
```

> **💡 Tip: Type Hints**
> Use the generic type parameter to specify the expected type of your entry points.
> For example, `EntryPointRegistry[Callable]` indicates that the entry points are callable objects.

### Working with Group-based Registry

#### Get Entry Points

```python
# Get an entry point (returns None if not found)
entry_point = registry.get("script_name")

# Get and load an entry point (returns None if not found)
loaded_entry_point = registry.load("script_name")

# Get an entry point with exception handling
try:
    entry_point = registry["script_name"]
except KeyError:
    print("Entry point not found")
```

#### Working with Multiple Entry Points

```python
# Get all entry point names
names = registry.names()

# Get all entry points as a dictionary
all_entry_points = registry.get_all()  # dict[str, EntryPoint]

# Load all entry points
loaded_points = registry.load_all()  # dict[str, T]
```

### Working with Module-based Registry

#### Get Entry Points by Group

```python
# Get all entry points for a specific group
eps = registry.get_group("console_scripts")

# Load all entry points for a group
loaded_eps = registry.load_group("console_scripts")

```

#### Access All Entry Points

```python
# Get all groups that contain entry points from this module
groups = registry.groups()

# Get all entry points organized by group
all_eps = registry.get_all()  # dict[str, list[EntryPoint]]

# Load all entry points from all groups
loaded_eps = registry.load_all()  # dict[str, list[T]]
```

### Common Operations

```python
# Check if an entry point exists
if "script_name" in registry:
    print("Entry point exists")

# Get the total number of entry points
count = len(registry)

# Iterate over entry points
for entry_point in registry:
    print(entry_point.name)
```

## Advanced Features

### Metadata Access

```python
# For group-based registry
metadata = registry.get_metadata("script_name")
print(f"Module: {metadata['module']}")
print(f"Attribute: {metadata['attr']}")
print(f"Distribution: {metadata['dist']}")
print(f"Version: {metadata['version']}")
```

### Extension Point Directory

```python
# For group-based registry
directory = registry.get_extension_point_dir("script_name")
print(f"Extension is installed at: {directory}")

```

### Discovery and Search

```python
from epregistry import (
    available_groups,
    filter_entry_points,
    search_entry_points,
    list_distributions,
)

# Get all available groups
groups = available_groups()

# Filter entry points
flask_eps = filter_entry_points(group="flask.*")
pytest_eps = filter_entry_points(distribution="pytest")
test_eps = filter_entry_points(name_pattern="test_*")

# Search across all entry points
results = search_entry_points(
    "test",
    include_groups=True,
    include_names=True,
    include_distributions=True
)

# List all distributions with entry points
distributions = list_distributions()
```

> **💡 Tip: Filtering Patterns**
> The filtering system supports wildcards:
> - `*` matches any number of characters
> - `?` matches exactly one character
> - Patterns are case-insensitive

## Package and Distribution Name Conversion

The package also contain some helpers to convert between package and distribution names.
The mapping in this case is also cached, only the first conversion may take long to build the index.

```python
from epregistry import package_to_distribution, distribution_to_package

# Convert package name to distribution
dist_name = package_to_distribution("PIL")  # Returns 'Pillow'
dist_name = package_to_distribution("requests")  # Returns 'requests'

# Convert distribution to primary package
pkg_name = distribution_to_package("Pillow")  # Returns 'PIL'
pkg_name = distribution_to_package("requests")  # Returns 'requests'
```

## Integration with Package Management

The Entry Point Registry integrates with Python's [`importlib.metadata`](https://docs.python.org/3/library/importlib.metadata.html) system, making it compatible with:

- [📦 setuptools](https://setuptools.pypa.io/en/latest/)
- [📦 poetry](https://python-poetry.org/)
- Other packaging tools that follow the entry points specification

> **📝 Note: Automatic Caching**
> Both registry types implement automatic caching of entry points for better performance.
> The cache is initialized on first use and shared across all registry instances.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "epregistry",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "Philipp Temminghoff",
    "author_email": "Philipp Temminghoff <philipptemminghoff@googlemail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6b/b8/5cf70c93eb154af3d979e87907b853eb9e8240a52addc00fa27bb5c21c64/epregistry-1.3.0.tar.gz",
    "platform": null,
    "description": "# epregistry\n\n[![PyPI License](https://img.shields.io/pypi/l/epregistry.svg)](https://pypi.org/project/epregistry/)\n[![Package status](https://img.shields.io/pypi/status/epregistry.svg)](https://pypi.org/project/epregistry/)\n[![Monthly downloads](https://img.shields.io/pypi/dm/epregistry.svg)](https://pypi.org/project/epregistry/)\n[![Distribution format](https://img.shields.io/pypi/format/epregistry.svg)](https://pypi.org/project/epregistry/)\n[![Wheel availability](https://img.shields.io/pypi/wheel/epregistry.svg)](https://pypi.org/project/epregistry/)\n[![Python version](https://img.shields.io/pypi/pyversions/epregistry.svg)](https://pypi.org/project/epregistry/)\n[![Implementation](https://img.shields.io/pypi/implementation/epregistry.svg)](https://pypi.org/project/epregistry/)\n[![Releases](https://img.shields.io/github/downloads/phil65/epregistry/total.svg)](https://github.com/phil65/epregistry/releases)\n[![Github Contributors](https://img.shields.io/github/contributors/phil65/epregistry)](https://github.com/phil65/epregistry/graphs/contributors)\n[![Github Discussions](https://img.shields.io/github/discussions/phil65/epregistry)](https://github.com/phil65/epregistry/discussions)\n[![Github Forks](https://img.shields.io/github/forks/phil65/epregistry)](https://github.com/phil65/epregistry/forks)\n[![Github Issues](https://img.shields.io/github/issues/phil65/epregistry)](https://github.com/phil65/epregistry/issues)\n[![Github Issues](https://img.shields.io/github/issues-pr/phil65/epregistry)](https://github.com/phil65/epregistry/pulls)\n[![Github Watchers](https://img.shields.io/github/watchers/phil65/epregistry)](https://github.com/phil65/epregistry/watchers)\n[![Github Stars](https://img.shields.io/github/stars/phil65/epregistry)](https://github.com/phil65/epregistry/stars)\n[![Github Repository size](https://img.shields.io/github/repo-size/phil65/epregistry)](https://github.com/phil65/epregistry)\n[![Github last commit](https://img.shields.io/github/last-commit/phil65/epregistry)](https://github.com/phil65/epregistry/commits)\n[![Github release date](https://img.shields.io/github/release-date/phil65/epregistry)](https://github.com/phil65/epregistry/releases)\n[![Github language count](https://img.shields.io/github/languages/count/phil65/epregistry)](https://github.com/phil65/epregistry)\n[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/epregistry)](https://github.com/phil65/epregistry)\n[![Package status](https://codecov.io/gh/phil65/epregistry/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/epregistry/)\n[![PyUp](https://pyup.io/repos/github/phil65/epregistry/shield.svg)](https://pyup.io/repos/github/phil65/epregistry/)\n\n[Read the documentation!](https://phil65.github.io/epregistry/)\n\n## Overview\n\nThe Entry Point Registry system provides a convenient way to manage and access Python entry points. It offers two different approaches to work with entry points:\n- Group-based access: Work with all entry points in a specific group\n- Module-based access: Work with all entry points provided by a specific module\n\nThis flexibility makes it particularly useful for plugin systems, extensions, or any modular components in Python applications.\n\n## Basic Usage\n\n### Group-based Registry\n\nWhen you want to work with entry points organized by their group:\n\n```python\nfrom epregistry import EntryPointRegistry\n\n# Create a registry for console scripts\nregistry = EntryPointRegistry[Callable](\"console_scripts\")\n\n# Get and load an entry point\nscript = registry.load(\"my-script\")\n\n# Get all entry points in the group\nall_scripts = registry.get_all()\n```\n\n### Module-based Registry\n\nWhen you want to work with all entry points provided by a specific module:\n\n```python\nfrom epregistry import ModuleEntryPointRegistry\n\n# Create a registry for a specific module\nregistry = ModuleEntryPointRegistry[Any](\"your_module_name\")\n\n# Get all groups that have entry points from this module\ngroups = registry.groups()\n\n# Get entry points for a specific group\ngroup_eps = registry.get_group(\"console_scripts\")\n\n# Load all entry points for a group\nloaded_eps = registry.load_group(\"console_scripts\")\n```\n\n> **\ud83d\udca1 Tip: Type Hints**\n> Use the generic type parameter to specify the expected type of your entry points.\n> For example, `EntryPointRegistry[Callable]` indicates that the entry points are callable objects.\n\n### Working with Group-based Registry\n\n#### Get Entry Points\n\n```python\n# Get an entry point (returns None if not found)\nentry_point = registry.get(\"script_name\")\n\n# Get and load an entry point (returns None if not found)\nloaded_entry_point = registry.load(\"script_name\")\n\n# Get an entry point with exception handling\ntry:\n    entry_point = registry[\"script_name\"]\nexcept KeyError:\n    print(\"Entry point not found\")\n```\n\n#### Working with Multiple Entry Points\n\n```python\n# Get all entry point names\nnames = registry.names()\n\n# Get all entry points as a dictionary\nall_entry_points = registry.get_all()  # dict[str, EntryPoint]\n\n# Load all entry points\nloaded_points = registry.load_all()  # dict[str, T]\n```\n\n### Working with Module-based Registry\n\n#### Get Entry Points by Group\n\n```python\n# Get all entry points for a specific group\neps = registry.get_group(\"console_scripts\")\n\n# Load all entry points for a group\nloaded_eps = registry.load_group(\"console_scripts\")\n\n```\n\n#### Access All Entry Points\n\n```python\n# Get all groups that contain entry points from this module\ngroups = registry.groups()\n\n# Get all entry points organized by group\nall_eps = registry.get_all()  # dict[str, list[EntryPoint]]\n\n# Load all entry points from all groups\nloaded_eps = registry.load_all()  # dict[str, list[T]]\n```\n\n### Common Operations\n\n```python\n# Check if an entry point exists\nif \"script_name\" in registry:\n    print(\"Entry point exists\")\n\n# Get the total number of entry points\ncount = len(registry)\n\n# Iterate over entry points\nfor entry_point in registry:\n    print(entry_point.name)\n```\n\n## Advanced Features\n\n### Metadata Access\n\n```python\n# For group-based registry\nmetadata = registry.get_metadata(\"script_name\")\nprint(f\"Module: {metadata['module']}\")\nprint(f\"Attribute: {metadata['attr']}\")\nprint(f\"Distribution: {metadata['dist']}\")\nprint(f\"Version: {metadata['version']}\")\n```\n\n### Extension Point Directory\n\n```python\n# For group-based registry\ndirectory = registry.get_extension_point_dir(\"script_name\")\nprint(f\"Extension is installed at: {directory}\")\n\n```\n\n### Discovery and Search\n\n```python\nfrom epregistry import (\n    available_groups,\n    filter_entry_points,\n    search_entry_points,\n    list_distributions,\n)\n\n# Get all available groups\ngroups = available_groups()\n\n# Filter entry points\nflask_eps = filter_entry_points(group=\"flask.*\")\npytest_eps = filter_entry_points(distribution=\"pytest\")\ntest_eps = filter_entry_points(name_pattern=\"test_*\")\n\n# Search across all entry points\nresults = search_entry_points(\n    \"test\",\n    include_groups=True,\n    include_names=True,\n    include_distributions=True\n)\n\n# List all distributions with entry points\ndistributions = list_distributions()\n```\n\n> **\ud83d\udca1 Tip: Filtering Patterns**\n> The filtering system supports wildcards:\n> - `*` matches any number of characters\n> - `?` matches exactly one character\n> - Patterns are case-insensitive\n\n## Package and Distribution Name Conversion\n\nThe package also contain some helpers to convert between package and distribution names.\nThe mapping in this case is also cached, only the first conversion may take long to build the index.\n\n```python\nfrom epregistry import package_to_distribution, distribution_to_package\n\n# Convert package name to distribution\ndist_name = package_to_distribution(\"PIL\")  # Returns 'Pillow'\ndist_name = package_to_distribution(\"requests\")  # Returns 'requests'\n\n# Convert distribution to primary package\npkg_name = distribution_to_package(\"Pillow\")  # Returns 'PIL'\npkg_name = distribution_to_package(\"requests\")  # Returns 'requests'\n```\n\n## Integration with Package Management\n\nThe Entry Point Registry integrates with Python's [`importlib.metadata`](https://docs.python.org/3/library/importlib.metadata.html) system, making it compatible with:\n\n- [\ud83d\udce6 setuptools](https://setuptools.pypa.io/en/latest/)\n- [\ud83d\udce6 poetry](https://python-poetry.org/)\n- Other packaging tools that follow the entry points specification\n\n> **\ud83d\udcdd Note: Automatic Caching**\n> Both registry types implement automatic caching of entry points for better performance.\n> The cache is initialized on first use and shared across all registry instances.\n",
    "bugtrack_url": null,
    "license": "MIT License\n         \n         Copyright (c) 2024, Philipp Temminghoff\n         \n         Permission is hereby granted, free of charge, to any person obtaining a copy\n         of this software and associated documentation files (the \"Software\"), to deal\n         in the Software without restriction, including without limitation the rights\n         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n         copies of the Software, and to permit persons to whom the Software is\n         furnished to do so, subject to the following conditions:\n         \n         The above copyright notice and this permission notice shall be included in all\n         copies or substantial portions of the Software.\n         \n         THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n         SOFTWARE.\n         ",
    "summary": "A registry for entry points (cached and generically typed)",
    "version": "1.3.0",
    "project_urls": {
        "Code coverage": "https://app.codecov.io/gh/phil65/epregistry",
        "Discussions": "https://github.com/phil65/epregistry/discussions",
        "Documentation": "https://phil65.github.io/epregistry/",
        "Issues": "https://github.com/phil65/epregistry/issues",
        "Source": "https://github.com/phil65/epregistry"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "987621f147df44c5408e36d860e2d56787d45b9857bb71dad3828582d6a07056",
                "md5": "1f9c66150893d4cd023234ed650f8cb0",
                "sha256": "3dee5d177d29fa57ec12fedc50c7d8276ff22e4eaf9d0a6d59d900de0b11259d"
            },
            "downloads": -1,
            "filename": "epregistry-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1f9c66150893d4cd023234ed650f8cb0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 11023,
            "upload_time": "2025-10-06T20:30:02",
            "upload_time_iso_8601": "2025-10-06T20:30:02.914503Z",
            "url": "https://files.pythonhosted.org/packages/98/76/21f147df44c5408e36d860e2d56787d45b9857bb71dad3828582d6a07056/epregistry-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6bb85cf70c93eb154af3d979e87907b853eb9e8240a52addc00fa27bb5c21c64",
                "md5": "11a72bed13edd297da78b0326e5cb2e5",
                "sha256": "f15212a8f746558ef58110e591935849d66e9a3484880cdeb0ba9bed5340ae78"
            },
            "downloads": -1,
            "filename": "epregistry-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "11a72bed13edd297da78b0326e5cb2e5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 11761,
            "upload_time": "2025-10-06T20:30:03",
            "upload_time_iso_8601": "2025-10-06T20:30:03.988694Z",
            "url": "https://files.pythonhosted.org/packages/6b/b8/5cf70c93eb154af3d979e87907b853eb9e8240a52addc00fa27bb5c21c64/epregistry-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-06 20:30:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "phil65",
    "github_project": "epregistry",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "epregistry"
}
        
Elapsed time: 1.35602s