The meaning of the many PY_XXX variables isn't easy to tell apart, so
start renaming some of them.
PY_ALL_PY and PY_PYC consistently are now named PY_LOCAL|INSTALL_PY and
PY_LOCAL|INSTALL_PYC, depending on whether or not they are intended to
be installed.
The old PY_INSTALL_PY was renamed to PY_DO_INSTALLL_PY, a move that
would be better applied to all boolean variables. I won't try with this
commit, however, because a lot of downstream packages depend on
PY_UPDATE_INIT_PY and PY_INSTALL_INIT_PY, i.e. without "_DO".
Signed-off-by: Jan Lindemann <jan@janware.com>
PY_ALL_PY is derived from PY_SRC_PY, which wildcards *.py in the module
directory, so a checked-in __init__.py enters the install list
unconditionally. PY_INSTALL_INIT_PY only gates the later append of
__init__.py, which covers files generated at build time. Setting it to
false thus had no effect on an existing __init__.py, which was still
installed together with its .pyc.
Filter __init__.py out of PY_ALL_PY. When PY_INSTALL_INIT_PY is true,
the existing append adds it back, so generated and checked-in
__init__.py files are installed as before. When it is false, an
existing __init__.py is now excluded from PY_ALL_PY and therefore also
from PY_INSTALLED_PY and PY_PYC.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Add py-check.mk and use it from py-topdir.mk and py-rules.mk. This
removes redundant check definitions, making sure that that checks run
from a repo's subdirectory match the checks run from its toplevel
directory.
Signed-off-by: Jan Lindemann <jan@janware.com>
py-defs.mk uses the variables ECHO and SED defined in defs.mk. The
complexity this introduces doesn't justify the reduced redundancy,
though, so this commit defines them redundantly in py-defs.mk and to
allow inclusion without prior defs.mk.
Signed-off-by: Jan Lindemann <jan@janware.com>
For backwards compatibility, ldlibpath.mk kept py-path.mk included.
The projects depending on that have been fixed by now and this is no
longer needed. So, move it to the py-defs.mk where it belongs and has
narrower scope.
Signed-off-by: Jan Lindemann <jan@janware.com>
.mypy_cache, .ruff_cache and .pytest_cache are not consistently
cleaned in all subdirectories. Fix that.
Signed-off-by: Jan Lindemann <jan@janware.com>
py-path.mk is the place to host PYTHONPATH and MYPYPATH definitions,
so move them there from py-defs.mk for consistency. Also, remove some
dead code.
Signed-off-by: Jan Lindemann <jan@janware.com>
If make echo-py's output is accidentally subjected to shell
expansion, it can yield surprising results. Protect it from that
happening.
Signed-off-by: Jan Lindemann <jan@janware.com>
If $(wildcard py.typed) is found in a python module directory,
install it. py.typed should be used by every repo that declares
properly typed code, for jw-pkg that would be at the jw.pkg node, i.e
installed to <site-dir>/jw/jw-pkg/py.typed.
Signed-off-by: Jan Lindemann <jan@janware.com>
Move the PY_XXX = true|false variable definitions meant to be preset
by including makefiles to the top of py-defs.mk to make the structure
of the file clearer.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add PY_INSTALL_INIT_PY ?= true to py-defs.mk. If set to false, a
Python module will not try to attempt installing an existing /
generated __init__.py. This is useful when installing into an exiting
directory with an existing __init__.py.
Signed-off-by: Jan Lindemann <jan@janware.com>
Remove PY_PREREQ_BUILD and PY_PREREQ_BUILD_DIRS from py-defs.mk:
Apparently they're not used anywhere, and are costly in terms of
directory startup time.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit aims at improving speed by using better caching.
- Makefile, cache.mk: Split .cache.mk up
To allow caching of runtime path variables which are
project-specific, split .cache.mk up in .cache-project.mk and
.cache-projects.mk
- ldlibpath.mk: Cache ldlibpath, exepath and pythonpath
Place the output of $(call proj_query ldlibpath), $(call
proj_query, exepath) and $(call proj_query pythonpath) in
JW_PKG_LD_LIBRARY_PATH, JW_PKG_EXE_PATH, and JW_PKG_PYTHON_PATH
respectively, and cache the variables in make/.project-cache.mk.
- cache.mk: Use = instead of :=
Recursively expanded variables are nearly as fast as := variables
if the assigned value is a fixed string. And sometimes it's not,
rightly so, because variables get assigned below, as with
JW_PKG_XXX for instance.
- cache.mk: Use $(TOPDIR) as variable values
Replace absolute references to project's topdir by $(TOPDIR) with
sed. As soon as the project queries produce absolute paths, they
will be transformed into relative paths which allow the code base
to be moved to a different location and still remain functional
without a rebuild.
Signed-off-by: Jan Lindemann <jan@janware.com>
Re-add everything necessary for building and packaging jw-python.
ldlibpath.mk is not strictly necessary, but might be with other
Python packages backed by compiled C-code, so leave it in.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit removes everything not strictly necessary for running
"make clean all" inside jw-build.
packaging jw-devtest. This cuts the repo down from 24077 to 4725
lines of code.
The idea is to
1) Further remove bloat from the remaining bits
2) Re-add what's necessary to build and package other essential repos.
The decision should be based on whether or not jw-build can also be
useful in a non-janware context.
Signed-off-by: Jan Lindemann <jan@janware.com>
Support the Makefile variables PY_INSTALL, PY_INSTALL_REG, PY_INSTALL_PYC, all
defaulting to true. They can be set to false to stop installation of whatever
file type is undesired in the target. A common use case for this are
__init__.cpython-313.pyc, provided by a package the installing package depends
on. The prerequisite package might already provide these files for common
directories.
Signed-off-by: Jan Lindemann <jan@janware.com>
The current globbing pattern for filling the PYTHON variable doesn't
account for the fact that /usr/bin/python3.X might have more than one
digit for X, fix that
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit adds support for static typechecking with mypy.
Notable additions:
- A new target "check" which does the type checking
- Py-mods.mk, meant to be included from a directory containing python modules
in subdirectories, but not being a python module itself. It makes the all
target depend on check only if PY_RUN_CHECK_AFTER_BUILD is defined and
true. That's because pypy is under heavy development, and the Ubuntu 18.04
version is too old to work for lots of the code.
Signed-off-by: Jan Lindemann <jan@janware.com>
This allows to specify modules in a test directory which a given module does
_not_ depend on and doesn't want to depend on.
Signed-off-by: Jan Lindemann <jan@janware.com>
PY_SITE_PACKAGES_PATH is set to the first element site.getsitepackages(), which
(correctly, but in this case undesirably) is below /usr/local. Use the first
path which is not.
Signed-off-by: Jan Lindemann <jan@janware.com>
Predefined PY_INSTALL_DIR was ignored prior to this commit, which shuffles the
py-defs.mk variables around considerably. Still some temporary variables
unnecessarily defined with ?=, but some testing would be good prior to further
changes.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit flips some more switches from Python 2 to Python 3 in makefiles and
Python code. Build runs through, but it's still likely to break things.
Signed-off-by: Jan Lindemann <jan@janware.com>
- Fix superflous dots in module names
- Generate PYTHONPATH in projects.py
- Add support for __init__.py.tmpl
Signed-off-by: Jan Lindemann <jan@janware.com>