For in-tree tests, the jw package is split across several projects, and
each directory containing a py-ns-dir.mk contributes its subtree. So far,
it's up to that directory how the contribution is handled. Usually an
__init__.py with pkgutil.extend_path() is present in version control to
glue these parts together. This commit makes py-ns-dir.mk handle the
contribution method centrally by default unless PY_UPDATE_INIT_PY is set to
false.
As of this commit, this is the case by default, i.e. PY_UPDATE_INIT_PY is
set to false in py-ns-dir.mk, maintaining the current behaviour.
Downstream projects or modules can decide to have __init__.py centrally
maintained. For this, they need to remove __init__.py from version control
and set PY_UPDATE_INIT_PY to true in the respective Makefile.
PY_UPDATE_INIT_PY = false is also set explicitly in src/python/jw/Makefile,
because that file should never be generated. Bootstrapping the entire
workspace hinges on it.
Pending better testing, most notably of consistent in-tree testing
functionality, PY_UPDATE_INIT_PY = true might become a global default in
the future.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add py-ns-dir.mk. It's first intended use is inside the
$(TOPDIR)/src/python/jw directories of each package. These are to be
treated specially, because they contribute to the same namespace: jw.
This is true when installed, which means that no __init__.py should
be packaged from that directory, see the guide linked below.
And it's also true when not installed, in which case there has to be
a path-extending __init__.py in the directory. Normally, it should
work without __init__.py in that case, as well, and it does for
running Python code with PYTHONPATH pointing to the respective
package roots. However, pyright doesn't seem to pull in code
scattered over multiple locations without an old-style namespace
path-extender, so we're likely going to add (but not install) an
__init__.py there.
Not sure if it's going to be auto-generated py py-ns-dir.mk or
committed to version control, we'll see with more testing.
Here's where I have my info from, aside from experiments.
https://packaging.python.org/en/latest/guides/packaging-namespace-packages/
Signed-off-by: Jan Lindemann <jan@janware.com>