Packaging


Posts

blog Getting Entry Points from PyPI

Entry_points are used in a lot of my projects as they’re a fairly simple way of adding plugin points. Recently I was wondering if there was a tool or site that maps them to PyPI though I am not aware of any of them. I spent a little time prototyping with an idea to see how much of it might be feasable.

Read More →

blog Updating My Salt Extensions

I have been using salt for quite a while (oldest commit in my personal salt states repo is 2010), but have usually taken the old approach to distributing modules. By setting the file_roots you can automatically sync all your modules with the saltutil.sync_all command.

file_roots:
  base:
    - /srv/salt
    - /srv/salt-kafka
    - /srv/salt-forgejo

With our file_roots defined, our plugin repo looks like this

tree /srv/salt-kafka
├── LICENSE
├── README.md
└── _engines
    └── kafka_consumer.py

This is useful, but for maintainability, I finally sat down to look at how to package things up more properly.

Read More →

blog Entry Points With Enums

While updating my PowerPlug ( pypi ) project, I implemented a pattern I have started using in a few other places that I use entry-points .

By creating a custom enum using one of Django’s enumeration-types , you can make it much easier to load these modules.

from importlib import metadata

from django.db import models
from django.utils.translation import gettext_lazy as _

class EntryPoints(models.TextChoices):
    APPS = "powerplug.apps", _("Installed Apps")
    REST = "powerplug.rest", _("Installed APIs")
    SIGNAL = "powerplug.signal", _("Installed Signals")
    TASK = "powerplug.task", _("Installed Tasks")
    URLS = "powerplug.urls", _("Installed URLs")
    CONTEXT = "powerplug.context", _("Installed context processor")

    def group(self) -> metadata.EntryPoints:
        return metadata.entry_points(group=self.value)

Using an enum like this, makes it very easy to load one of our entry points, while keeping all the definitions for our app in a single place.

Read More →