From 8561fba46509db7f74f9770d71dd0ba41e4cb594 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 18 Feb 2022 19:44:34 -0500 Subject: [PATCH 1/2] ENH: Add bids.ext namespace package for subpackages --- bids/ext/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 bids/ext/__init__.py diff --git a/bids/ext/__init__.py b/bids/ext/__init__.py new file mode 100644 index 000000000..69e3be50d --- /dev/null +++ b/bids/ext/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) From 39d67ed57d5c944afb06da1db4a18320e9ebd758 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 18 Feb 2022 19:54:55 -0500 Subject: [PATCH 2/2] DOC: Add an explanation of how to set up a namespace package --- bids/ext/__init__.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/bids/ext/__init__.py b/bids/ext/__init__.py index 69e3be50d..0b197c8fd 100644 --- a/bids/ext/__init__.py +++ b/bids/ext/__init__.py @@ -1 +1,41 @@ +""" +The PyBIDS extension namespace package + +``bids.ext`` is reserved as a namespace for extensions to install into. +To write such an extension, the following things are needed: + +1) Create a new package with the following structure (assuming setuptools):: + + package/ + bids/ + ext/ + __init__.py + EXTENSION/ + __init__.py + ... + setup.cfg + setup.py + + The important things to note are that the ``bids/`` directory must be + empty apart from ``ext/`` and ``bids/ext/`` must be empty except for + your extension and an ``__init__.py``. + +2) Place the following (and nothing else) in ``__init__.py``:: + + __path__ = __import__('pkgutil').extend_path(__path__, __name__) + +3) Include the following lines in ``setup.cfg``:: + + [options] + install_requires = + pybids >= 0.15 + packages = find_namespace: + + [options.packages.find] + include = + bids.ext.EXTENSION + bids.ext.EXTENSION.* + +""" + __path__ = __import__('pkgutil').extend_path(__path__, __name__)