Skip to main content

The Cython-Optimized Plugin Oriented Programming System

Project description

cPop is used to express the Plugin Oriented Programming Paradigm. The Plugin Oriented Programming Paradigm has been designed to make pluggable software easy to write and easy to extend.

Plugin Oriented Programming presents a new way to scale development teams and deliver complex software. This is done by making the applications entirely out of plugins, and also making the applications themselves natively pluggable with each other.

Using Plugin Oriented Programming it then becomes easy to have the best of both worlds, software can be built in small pieces, making development easier to maintain. The small pieces can then be merged and deployed in a single binary, making code deployment easy as well.

All this using Cython, one of the world’s most popular and powerful programming languages.

Instalation

First off, install cPop from pypi:

pip3 install cPop

Now all it takes to create a pluggable application is a few lines of code. This is the root of every pop project. We create a hub, we add dynamic subsystems, and then we call them through the hub’s namespace.

import pop.hub
import asyncio

loop = asyncio.get_event_loop()
asyncio.run(main())


async def main():
    hub = await pop.hub.AsyncHub()
    await hub.my_sub.init.cli()

Configuration

When creating a cpop app, we put all of the pop configuration in a config.yaml

# Every config option for your plugin
config:
    my_namespace:
        my_opt:
            default: True

# Options that should be exposed on the CLI when your app controls the CLI
cli_config:
    my_namespace:
        my_opt:
            # All options that are accepted by ArgParser.add_argument are good here
            help: description of this option
            subcommands:
                - my_subcommand
            group: My arg group

# Subcommands to expose for your project
subcommands:
    my_namespace:
        my_subcommand:
            help: My subcommand

# Dynamic namespaces that your app merges onto and which folders extend those namespaces
dyne:
    my_dyne:
    - src_dir

# python imports that your app uses which should be added to hub.lib for your app
import:
    - asyncio
    - importlib
    - importlib.resources
    - os
    - toml

Create a pop config file:

# The default location is in ~/.pop/config.yaml
# But you can change that by setting the POP_CONFIG environment variable

pop_cli:
    # Setting this option will make your hub persist on the cli between calls
    hub_state: ~/.pop/hub.pkl
log:
    log_plugin: async

From the above example, all arguments would be loaded onto the namespace under hub.OPT.my_namesapce. One config.yaml can add config options to multiple namespaces. They are all merged together in the order they are found in sys.path

Testing

Clone the repo

git clone https://gitlab.com/Akm0d/cpop.git
cd cpop

Install cpop with the testing extras

pip3 install .\[test\]

Run the tests in your cloned fork of cPop:

pytest tests

Release

The following steps are how to release a project with hatch

pip install .\[build\]
hatch build
export HATCH_INDEX_USER="__token__"
export HATCH_INDEX_AUTH="pypi-api-token"
hatch publish

Documentation

Check out the docs for more information:

https://pop.readthedocs.io

There is a much more in depth tutorial here, followed by documents on how to think in Plugin Oriented Programming. Take your time to read it, it is not long and can change how you look at writing software!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpop-32.0.1.tar.gz (41.5 kB view details)

Uploaded Source

Built Distributions

cpop-32.0.1-cp312-cp312-manylinux_2_38_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.38+ x86-64

cpop-32.0.1-cp311-cp311-manylinux_2_39_x86_64.whl (778.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.39+ x86-64

File details

Details for the file cpop-32.0.1.tar.gz.

File metadata

  • Download URL: cpop-32.0.1.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for cpop-32.0.1.tar.gz
Algorithm Hash digest
SHA256 f811a71cefbbf5f83e561f724cc723c5a9c7bc9e621d214f775f3883b5aad568
MD5 a8bd805c92be53cb782745c47ba520f2
BLAKE2b-256 dab938297700d06f7b00282f5464c44ceb46997147ed28564a11b7d6ded3fc71

See more details on using hashes here.

File details

Details for the file cpop-32.0.1-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for cpop-32.0.1-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 430d60e627802d2bc2a9e42604fbd22ad2214c103ba4bbce3a16effa59aa3f5b
MD5 9a52b320349d5c31ac8b2c91fb49a9bb
BLAKE2b-256 e7dd75cafe1680b51ef9d7517973495e44f4ac17ff3b8b7e20bbd12f74924cdb

See more details on using hashes here.

File details

Details for the file cpop-32.0.1-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for cpop-32.0.1-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 9549df03d68044832d206426602a1d8961660f3987e055878a90b16a4fce9825
MD5 e93fcdd7b3ab937267011bf310994e5c
BLAKE2b-256 2a7eba4d582d3929ef54e29d86bef50f7ba20e6b2e3ec8d83d476c3ecb02ef5b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page