Skip to main content

External plugin for PyBuilder to generate a base project structure

Project description

PyBuilder Archetype Base Plugin

This plugin generates a base common structure with no major dependecies. The main idea is to get an skeleton that can be used for any kind of Python module. It modifies PyBuilder structure logic lightly, removing some packages making it less Java-like.

In the following diagram there is every directory and file created during create_archetype_base:

└── package_name
    ├── config  # For any kind of configuration files or constants
    |   ├── logger
    |   |   └── logger.yml
    |   ├──
    |   ├──
    |   └──
    ├── core  # Logic of the project itself
    |   └──
    ├── errors  # For every custom exception made
    |   ├── core  # Make as many scripts as packages in core (i.e. for core.processing)
    |   |   └──
    |   └──
    ├── utils  # For any kind of util used in the project
    |   ├── logging
    |   |   ├──
    |   |   └── handlers.yml  # For custom logging handles (i.e. database logging)
    |   ├──
    |   └──
LICENSE # Empty file

There are other PyBuilder plugins that depend on pybuilder_archetype_base that include other more specific packages. These plugins are:

How to use pybuilder_archetype_base

NOTICE: This plugin only works on Windows due to its dependency with pybuilder_pycharm_workspace PyBuilder plugin. Using this plugin in other OS shall not work properly. Multi-platform support soon.

Add plugin dependencies to your (it requires pybuilder_pycharm_workspace to work properly):


Configure the plugin within your init function:

def initialise(project):
    project.set_property('project_base_path', project_path)
    project.set_property('pycharm_workspace_project_path', project_path)

This will tell the plugin which is the project location in the filesystem. project_base_path property value should be always the same. It is needed to inform pycharm_workspace_project_path too in order to get pybuilder_pycharm_workspace working.

Launch the task with:

(venv) C:\Users\foo\PycharmProjects\bar> pyb create_archetype_base file recommended

This plugin doesn't include a file due to there should be already one at the moment of the execution of pyb command. The following template can be used along this plugin. Modify as desired.

from pathlib import Path

from pybuilder.core import use_plugin, init, Author, before



project_path = Path(__file__).resolve().parent

name =
authors = [Author("foo", 'bar')]
license = "Apache License, Version 2.0"
version = '1.0.0'

def initialise(project):

    project.set_property('dir_source_main_python', 'src')

    project.set_property('dir_source_unittest_python', 'tests')
    project.set_property('unittest_module_glob', 'test_*')

    project.set_property('project_base_path', project_path)
    project.set_property('pycharm_workspace_project_path', project_path)

def initialise_dev(project):
    project.version = f'{project.version}.dev'
    project.set_property('flake8_verbose_output', True)

def initialise_pro(project):
    project.set_property('flake8_break_build', True)
    project.set_property('flake8_include_test_sources', True)

def pack_files(project):
    Includes non-Python files in the build.

    :param pybuilder.core.Project project: PyBuilder project instance
    :return: None
    package_path = list(Path(project.get_property('dir_source_main_python')).glob('*'))[0]
    resources_paths = sorted(package_path.glob('**'))[1:]
        { [str((path.relative_to(package_path) / '*').as_posix()) for path in resources_paths] })

Take note of example on pybuilder_pycharm_workspace plugin README to cover its needs too.


Plugin has next properties with provided defaults

Name Type Default Value Description
project_base_path Path None Project's path in filesystem (same as file). Mandatory

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

pybuilder-archetype-base-0.1.1.tar.gz (13.4 kB view hashes)

Uploaded source

Built Distribution

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