pyscaffoldext.custom_extension package¶
Subpackages¶
Submodules¶
pyscaffoldext.custom_extension.extension module¶
Main logic to create custom extensions
- class pyscaffoldext.custom_extension.extension.CustomExtension(name: str | None = None)[source]¶
Bases:
Extension
Configures a project to start creating extensions
- activate(actions: List[Callable[[Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], Dict[str, Any]], Tuple[Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], Dict[str, Any]]]]) List[Callable[[Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], Dict[str, Any]], Tuple[Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], Dict[str, Any]]]] [source]¶
Activate extension, see
activate
.
- augment_cli(parser)[source]¶
Augments the command-line interface parser
A command line argument
--FLAG
where FLAG=``self.name`` is added which appendsself.activate
to the list of extensions. As help text the docstring of the extension class is used. In most cases this method does not need to be overwritten.- Parameters:
parser – current parser object
- pyscaffoldext.custom_extension.extension.INVALID_PROJECT_NAME = 'The prefix ``pyscaffoldext-`` will be added to the package name (as in PyPI/pip install). If that is not your intention, please use ``--force`` to overwrite.'¶
Project name does not comply with convention of an extension
- exception pyscaffoldext.custom_extension.extension.NamespaceError(message="It's not possible to define a custom namespace when using ``--custom-extension``.", *args, **kwargs)[source]¶
Bases:
RuntimeError
No additional namespace is allowed
- DEFAULT_MESSAGE = "It's not possible to define a custom namespace when using ``--custom-extension``."¶
- pyscaffoldext.custom_extension.extension.add_doc_requirements(struct: Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], opts: Dict[str, Any]) Tuple[Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], Dict[str, Any]] [source]¶
In order to build the docs new requirements are necessary now.
The default
tox.ini
generated by PyScaffold should already include-e {toxinidir}/docs/requirements.txt
in its dependencies. Therefore, this action will make suretox -e docs
run without problems.It is important to sort the requirements otherwise pre-commit will raise an error for a newly generated file and that would correspond to a bad user experience.
- pyscaffoldext.custom_extension.extension.add_entry_point(setupcfg: ConfigUpdater, opts: Dict[str, Any]) ConfigUpdater [source]¶
Adds the extension’s entry_point to setup.cfg
- pyscaffoldext.custom_extension.extension.add_files(struct: Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], opts: Dict[str, Any]) Tuple[Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], Dict[str, Any]] [source]¶
Add custom extension files. See
pyscaffold.actions.Action
- pyscaffoldext.custom_extension.extension.add_pytest_requirements(setupcfg: ConfigUpdater, _opts) ConfigUpdater [source]¶
Add [options.extras_require] testing requirements for py.test
- pyscaffoldext.custom_extension.extension.get_requirements() List[str] [source]¶
List of requirements for install_requires
- pyscaffoldext.custom_extension.extension.modify_setupcfg(definition: str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]], opts: Dict[str, Any]) Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] [source]¶
Modify setup.cfg to add install_requires and pytest settings before it is written. See
pyscaffold.operations
.
- pyscaffoldext.custom_extension.extension.process_options(struct: Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], opts: Dict[str, Any]) Tuple[Dict[str, str | None | Callable[[Dict[str, Any]], str | None] | Template | Tuple[str | None | Callable[[Dict[str, Any]], str | None] | Template, Callable[[Path, str | None, Dict[str, Any]], Path | None]] | dict], Dict[str, Any]] [source]¶
Process the given options enforcing policies and calculating derived ones.
Policies:
Fixed
namespace
value of pyscaffoldext (and no extra namespace)The project name must start with
pyscaffoldext-
.The package name shouldn’t contain the redundant
pyscaffoldext_
in the beginning of the name.