mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
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>
This commit is contained in:
parent
5b758023ac
commit
0a9340af49
7 changed files with 261 additions and 0 deletions
119
make/py-defs.mk
Normal file
119
make/py-defs.mk
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
ENV_PYTHONPATH := $(PYTHONPATH)
|
||||
|
||||
include $(JWBDIR)/make/py-version.mk
|
||||
|
||||
ifeq ($(DEVELOPMENT),true)
|
||||
PY_SITE_PACKAGES_PATH := $(PREFIX)/python$(PYTHON_VERSION)/site-packages
|
||||
else
|
||||
PY_SITE_PACKAGES_PATH := $(shell $(PYTHON) -c "import site; print([d for d in site.getsitepackages() if d.find('/local/') == -1][0])")
|
||||
endif
|
||||
|
||||
ifndef PY_PREREQ_BUILD
|
||||
PY_PREREQ_BUILD := $(shell $(proj_query_cmd) pkg-requires --subsections jw -d ' ' -p --no-version build $(PROJECT))
|
||||
endif
|
||||
|
||||
ifndef PY_PREREQ_BUILD_DIRS
|
||||
PY_PREREQ_BUILD_DIRS := $(shell $(proj_query_cmd) proj-dir $(PY_PREREQ_BUILD))
|
||||
endif
|
||||
|
||||
PY_MYPY ?= mypy --ignore-missing-imports --no-namespace-packages
|
||||
|
||||
PY_SRC_PY ?= $(wildcard *.py)
|
||||
PY_ALL_PY = $(PY_SRC_PY)
|
||||
|
||||
ifneq ($(PYTHON_MAJOR),3)
|
||||
PY_PYC = $(patsubst %.py,%.pyc,$(PY_ALL_PY))
|
||||
else
|
||||
PY_CPYTHON_PREFIX := $(shell $(PYTHON) -c "import sys; print('cpython-{}{}'.format(sys.version_info[0],sys.version_info[1]))")
|
||||
PY_PYC = $(patsubst %.py,__pycache__/%.$(PY_CPYTHON_PREFIX).pyc,$(PY_ALL_PY))
|
||||
endif
|
||||
|
||||
ifneq ($(PY_INSTALL_DIR),)
|
||||
PY_INSTALL_DIR_PY ?= $(PY_INSTALL_DIR)
|
||||
endif
|
||||
|
||||
# deduce PY_INSTALL_DIR_PY from working directory below .. python/
|
||||
ifeq ($(PY_INSTALL_DIR_PY),)
|
||||
PY_INSTALL_PKG_MOD ?= $(shell $(ECHO) $(CWD) | $(SED) 's%.*/python/%%; s%/.*%%')
|
||||
PY_INSTALL_SUB_MOD ?= $(shell $(ECHO) $(CWD) | $(SED) "s%.*/$(PY_INSTALL_PKG_MOD)\(/\|$$\)%%")
|
||||
ifneq ($(PY_INSTALL_SUB_MOD),)
|
||||
PY_INSTALL_MOD ?= $(PY_INSTALL_PKG_MOD)/$(PY_INSTALL_SUB_MOD)
|
||||
else
|
||||
PY_INSTALL_MOD ?= $(PY_INSTALL_PKG_MOD)
|
||||
endif
|
||||
PY_MOD ?= $(subst /,.,$(PY_INSTALL_MOD))
|
||||
PY_ALL_PY += __init__.py
|
||||
PY_INSTALL_DIR_PY ?= $(ENV_PREFIX)$(PY_SITE_PACKAGES_PATH)/$(patsubst .,/,$(PY_INSTALL_MOD))
|
||||
else
|
||||
ifeq ($(PY_INSTALL_DIR_PY),)
|
||||
$(error PY_INSTALL_DIR_PY is undefined)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PYTHON_MAJOR),3)
|
||||
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)/__pycache__
|
||||
else
|
||||
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)
|
||||
endif
|
||||
|
||||
PY_INSTALL ?= true
|
||||
PY_INSTALL_REG ?= true
|
||||
ifneq ($(PY_INSTALL),true)
|
||||
PY_INSTALL_REG = false
|
||||
endif
|
||||
PY_INSTALL_PYC ?= true
|
||||
ifneq ($(PY_INSTALL_REG),true)
|
||||
PY_INSTALL_PYC = false
|
||||
endif
|
||||
|
||||
PY_INSTALL_DIRS ?= $(sort $(PY_INSTALL_DIR_PY) $(PY_INSTALL_DIR_PYC))
|
||||
PY_INSTALLED_PY = $(addprefix $(PY_INSTALL_DIR_PY)/,$(sort $(PY_ALL_PY)))
|
||||
ifeq ($(PY_INSTALL_PYC),true)
|
||||
PY_INSTALLED_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_PYC))
|
||||
endif
|
||||
ifeq ($(PY_INSTALL_REG),true)
|
||||
PY_INSTALLED_REG = $(PY_INSTALLED_PY) $(PY_INSTALLED_PYC)
|
||||
endif
|
||||
|
||||
ifeq ($(origin PYTHONPATH),undefined)
|
||||
PYTHONPATH := $(call proj_query, pythonpath $(PROJECT) $(PY_PREREQ_RUN))
|
||||
endif
|
||||
#PYTHONPATH = $(subst $(space),,$(ENV_PYTHONPATH)$(foreach d,$(PY_MODULE_DIRS),:$(d)))
|
||||
MYPYPATH = $(PYTHONPATH)
|
||||
export PYTHONPATH MYPYPATH
|
||||
|
||||
# not used anywhere
|
||||
#PY_PROJ_MODULE_DIRS ?= $(wildcard $(foreach subdir,/tools/python /src/python,$(addsuffix $(subdir),$(TOPDIR) $(PY_PREREQ_BUILD_DIRS))))
|
||||
#PY_MODULE_DIRS ?= $(PY_PROJ_MODULE_DIRS)
|
||||
#PY_MODULES ?= $(PY_PROJ_MODULES)
|
||||
#PY_PROJ_MODULES += $(dir $(wildcard $(PY_MODULE_DIRS)/*/__init__.py))
|
||||
|
||||
ifneq ($(PY_DEFS_MK_INCLUDED),true)
|
||||
all:
|
||||
clean: pyc.clean
|
||||
|
||||
echo-py:
|
||||
@echo "PYTHON = $(PYTHON)"
|
||||
@echo "PY_INSTALL_DIR_PY = $(PY_INSTALL_DIR_PY)"
|
||||
@echo "PROJECT = $(PROJECT)"
|
||||
@echo "PY_SITE_PACKAGES_PATH = $(PY_SITE_PACKAGES_PATH)"
|
||||
@echo "PY_MODULES = $(PY_MODULES)"
|
||||
@echo "PYTHONPATH = $(PYTHONPATH)"
|
||||
@echo "MYPYPATH = $(MYPYPATH)"
|
||||
@echo "PY_INSTALL_MOD = $(PY_INSTALL_MOD)"
|
||||
@echo "PY_INSTALL_SUB_MOD = $(PY_INSTALL_SUB_MOD)"
|
||||
# not used anywhere"
|
||||
#@echo "PY_PROJ_MODULE_DIRS = $(PY_PROJ_MODULE_DIRS)"
|
||||
#@echo "PY_MODULE_DIRS = $(PY_MODULE_DIRS)"
|
||||
|
||||
pyc.clean:
|
||||
$(RM) -rf $(wildcard *.pyc) __pycache__
|
||||
libpath: py-libpath
|
||||
py-libpath:
|
||||
@echo export PYTHONPATH=$(PYTHONPATH)
|
||||
@echo export MYPYPATH=$(MYPYPATH)
|
||||
endif
|
||||
|
||||
PY_DEFS_MK_INCLUDED := true
|
||||
|
||||
include $(JWBDIR)/make/ldlibpath.mk
|
||||
Loading…
Add table
Add a link
Reference in a new issue