Commit graph

43 commits

Author SHA1 Message Date
5a48143064 py-defs.mk: Move boolean vars to top

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>
2026-03-17 16:22:17 +01:00
226a241e8a py-defs.mk: Add PY_INSTALL_INIT_PY

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>
2026-03-17 16:22:02 +01:00
58ae1b68ca py-defs.mk: Remove PY_PREREQ_BUILD[_DIRS]

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>
2026-01-26 17:17:23 +01:00
f05e1ee0e3 make/[Makefile|*.mk): Improve variable caching

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>
2026-01-26 17:17:23 +01:00
b7d88a6e22 py-defs.mk: Default PY_UPDATE_INIT_PY ?= true

Set PY_UPDATE_INIT_PY to true to match jw-build's default behaviour before the variable was introduced.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-18 12:04:29 +01:00
d0c1eac1a9 py-defs.mk, py-mod.mk: Support PY_UPDATE_INIT_PY

Allow to disable auto-updating of __init__.py in a directory via PY_UPDATE_INIT_PY = true | false.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-16 18:42:58 +01:00
0a9340af49 make: Re-add files necessary for building jw-python

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>
2025-11-13 17:27:14 +01:00
bc883deed4 Everywhere: Remove everything non-essential for "make clean all"

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>
2025-11-14 15:02:56 +01:00
cb714d83ad py-devs.mk: Don't ?= PYTHONPATH

For performance's sake, don't ?= define PYTHONPATH, but := it, like so:

ifeq ($(origin PYTHONPATH),undefined) PYTHONPATH := $(call proj_query, pythonpath $(PROJECT) $(PY_PREREQ_RUN)) endif
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-13 15:20:54 +01:00
a907a5640f py-defs.mk: Support PY_INSTALL[_XXX]

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>
2025-07-16 16:21:35 +00:00
60ef137bc3 projects.mk, py-defs.mk, py-version.mk: Add py-version.mk

This commit adds py-version.mk, eliminating redundancy between projects.mk and py-defs.mk in setting up the Python version early.

2025-02-22 09:04:17 +00:00
9a5bc11cd0 py-defs.mk: Fix: mypy finds modules unter multiple paths
Signed-off-by: Jan Lindemann <jan@janware.com>
2024-06-04 08:56:19 +00:00
17851c9d11 projects.mk / py-defs.mk: Support Python 3.10

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>
2022-10-04 11:05:24 +00:00
f3febfa460 py-defs.mk, projects.mk: Fix /usr/bin/python globbing on OpenSUSE
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-05-18 13:15:35 +00:00
caf33841b4 py-defs.mk, projects.mk: Use latest install Python

Use $(lastword $(shell ls -v /usr/bin/python[0-9]*)) for the Python version to use.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-05-16 13:22:51 +00:00
a82fa9023b py-xxx.mk: Introduce PYTHON_MAJOR

Where *.pyc files are created is decided by PYTHON_MAJOR, not PYTHON_VERSION, so introduce it.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-05-16 13:09:16 +00:00
fab119fca9 py-defs.mk: Add MYPYPATH to py-libpath target
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-26 19:04:18 +00:00
a404be15b9 make, scripts: Add support for static Python typechecking

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>
2020-04-10 12:13:12 +00:00
d8542717b1 py-defs.mk: Add PY_PREREQ_RUN in PYTHONPATH

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>
2020-04-05 12:51:08 +00:00
921a929cd3 Ubuntu: Fix PY_SITE_PACKAGES_PATH

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>
2019-11-13 12:49:27 +00:00
9f0276ead5 py-defs.mk: Fix clean target

pyc.clean was broken because it did rm -f __pycache__ (a directory) Also, add include guards.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-10-28 12:20:50 +00:00
b2d6e6f554 Everywhere: Rename MODDIR -> JWBDIR

Rename the omnipresent MODDIR variable to JWBDIR, since that's more to the point.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-29 21:34:18 +00:00
386f9304c6 py-defs.mk: Add automatic detection of PY_CPYTHON_PREFIX
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-11 08:47:46 +00:00
ab5fc0c334 py-defs.mk: Fix installation with predefined PY_INSTALL_DIR

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>
2019-06-11 08:31:11 +00:00
4e9be149ef py-defs.mk: Fix PY_INSTALL_XXX_MOD generation
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-09 06:24:43 +00:00
956aea82eb py-*.mk: Fix python version detection
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-03 08:00:39 +00:00
13fa28e23f make, scripts: Flip some more switches from pathon 2 to 3 (untested!)

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>
2019-06-02 12:28:13 +00:00
fe161ff4d6 py-defs.mk, py-mod.mk: Add support for Python3's __pycache__
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-03-12 11:35:49 +00:00
aa85417a17 Everywhere: Purge spaces in text files
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-03-06 12:38:20 +00:00
0eaef0c326 conf/jcs, make, tmpl/doxygen: Align equal signs in makefiles to column 30
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-03-03 18:12:28 +00:00
ed8b3918cc py-defs.mk: Allow PY_INSTALL_DIR to be overridden (?=)
Signed-off-by: Jan Lindemann <jan@janware.com>
2018-12-28 13:46:23 +00:00
e68d4eb83b make, scripts: Now excplicitly calling python2 executable instead of python
Signed-off-by: Jan Lindemann <jan@janware.com>
2018-01-02 13:12:00 +00:00
6bfa55481c make: Speed up clean targets
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-12-27 11:43:01 +00:00
f70465cbd5 make: Replace pwd by $(PWD)
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-12-18 13:45:55 +00:00
3dddce9817 py-defs.mk: Add multiple inclusion preventer
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-23 08:41:46 +00:00
2594143b1f make: Improvements to a couple of makefiles

- Depend.mk, ldlibpath.mk: add multiple inclusion guards - Flex-bison.mk some dependency fiddling - Py-defs.mk: remove *.pyc on clean

Signed-off-by: Jan Lindemann <jan@janware.com>
2017-10-30 12:02:43 +00:00
db1e6097fa ldlibpath.mk, py-defs.mk, rules.mk: Add ldlibpath.mk to py-defs.mk

Since python might need bound C libraries, too, this looks like a good idea.

Signed-off-by: Jan Lindemann <jan@janware.com>
2017-08-01 21:53:36 +00:00
ad2c1da54a py-defs.mk: Add (disabled) support for python3
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-26 09:45:54 +00:00
3f782d3f3f py-defs/py-mod.mk: Fix __init__.py generation
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-25 15:04:44 +00:00
55f9b50562 py-defs.mk, py-mod.mk, python-tools.sh: Improve python module handling

- 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>
2017-07-24 10:59:08 +00:00
cdabaad7ef py-*.mk: Fill PYTHONPATH from build dependencies
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-22 18:16:08 +00:00
f8747fcdbd py-defs.mk, py-mod.mk: Add exports to __init__.py
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-22 14:34:23 +00:00
d49340917b make: Add py-defs.mk py-mod.mk py-run.mk
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-21 15:34:16 +00:00