py-xxx.mk: Some variable housekeeping #81
3 changed files with 24 additions and 16 deletions
|
|
@ -3,14 +3,14 @@ include $(JWBDIR)/make/py-version.mk
|
|||
PY_INSTALL_INIT_PY ?= true
|
||||
PY_UPDATE_INIT_PY ?= true
|
||||
PY_INSTALL ?= true
|
||||
PY_INSTALL_REG ?= true
|
||||
PY_DO_INSTALL_REG ?= true
|
||||
|
||||
ifneq ($(PY_INSTALL),true)
|
||||
PY_INSTALL_REG = false
|
||||
PY_DO_INSTALL_REG = false
|
||||
endif
|
||||
PY_INSTALL_PYC ?= true
|
||||
ifneq ($(PY_INSTALL_REG),true)
|
||||
PY_INSTALL_PYC = false
|
||||
PY_DO_INSTALL_PYC ?= true
|
||||
ifneq ($(PY_DO_INSTALL_REG),true)
|
||||
PY_DO_INSTALL_PYC = false
|
||||
endif
|
||||
|
||||
ifeq ($(DEVELOPMENT),true)
|
||||
|
|
@ -20,13 +20,16 @@ else
|
|||
endif
|
||||
|
||||
PY_SRC_PY ?= $(wildcard *.py)
|
||||
PY_ALL_PY = $(filter-out __init__.py,$(PY_SRC_PY))
|
||||
PY_LOCAL_PY = $(PY_SRC_PY)
|
||||
PY_INSTALL_PY = $(filter-out __init__.py,$(PY_SRC_PY))
|
||||
|
||||
ifneq ($(PYTHON_MAJOR),3)
|
||||
PY_PYC = $(patsubst %.py,%.pyc,$(PY_ALL_PY))
|
||||
PY_LOCAL_PYC = $(patsubst %.py,%.pyc,$(PY_LOCAL_PY))
|
||||
PY_INSTALL_PYC = $(patsubst %.py,%.pyc,$(PY_INSTALL_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))
|
||||
PY_LOCAL_PYC = $(patsubst %.py,__pycache__/%.$(PY_CPYTHON_PREFIX).pyc,$(PY_LOCAL_PY))
|
||||
PY_INSTALL_PYC = $(patsubst %.py,__pycache__/%.$(PY_CPYTHON_PREFIX).pyc,$(PY_INSTALL_PY))
|
||||
endif
|
||||
|
||||
ifneq ($(PY_INSTALL_DIR),)
|
||||
|
|
@ -46,7 +49,10 @@ ifeq ($(PY_INSTALL_DIR_PY),)
|
|||
endif
|
||||
PY_MOD ?= $(subst /,.,$(PY_INSTALL_MOD))
|
||||
ifeq ($(PY_INSTALL_INIT_PY),true)
|
||||
PY_ALL_PY += __init__.py
|
||||
PY_INSTALL_PY += __init__.py
|
||||
PY_LOCAL_PY += __init__.py
|
||||
else ifeq ($(PY_UPDATE_INIT_PY),true)
|
||||
PY_LOCAL_PY += __init__.py
|
||||
endif
|
||||
PY_INSTALL_DIR_PY ?= $(ENV_PREFIX)$(PY_SITE_PACKAGES_PATH)/$(patsubst .,/,$(PY_INSTALL_MOD))
|
||||
else
|
||||
|
|
@ -62,12 +68,12 @@ else
|
|||
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)))
|
||||
PY_INSTALLED_PY = $(addprefix $(PY_INSTALL_DIR_PY)/,$(sort $(PY_INSTALL_PY)))
|
||||
PY_INSTALLED_PY_TYPED = $(addprefix $(PY_INSTALL_DIR_PY)/,$(wildcard py.typed))
|
||||
ifeq ($(PY_INSTALL_PYC),true)
|
||||
PY_INSTALLED_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_PYC))
|
||||
ifeq ($(PY_DO_INSTALL_PYC),true)
|
||||
PY_INSTALLED_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_INSTALL_PYC))
|
||||
endif
|
||||
ifeq ($(PY_INSTALL_REG),true)
|
||||
ifeq ($(PY_DO_INSTALL_REG),true)
|
||||
PY_INSTALLED_REG = $(PY_INSTALLED_PY) $(PY_INSTALLED_PYC) $(PY_INSTALLED_PY_TYPED)
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ endif
|
|||
#leftparen := (
|
||||
#PY_EXPORT ?= $(shell sed '/\(class\|def\) ..*\# *export/ !d; s/\(class\|def\) *//; s/[$(leftparen):].*//' $(PY_SRC_PY))
|
||||
|
||||
all: $(PY_PYC)
|
||||
all: $(PY_LOCAL_PYC)
|
||||
install: install-dirs.done install-reg.done
|
||||
clean: invalidate-testability py.clean
|
||||
distclean:
|
||||
|
|
@ -34,6 +34,6 @@ ifeq ($(PY_UPDATE_INIT_PY),true)
|
|||
__init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY))
|
||||
if [ "$(PY_INIT_TMPL)" ]; then cat "$(PY_INIT_TMPL)" > $@.tmp; else > $@.tmp; fi
|
||||
set -e -o pipefail; $(PY_GENERATE_INIT_PY) \
|
||||
$(filter-out __init__.py,$(PY_ALL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp
|
||||
$(filter-out __init__.py,$(PY_LOCAL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp
|
||||
mv $@.tmp $@
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ all:
|
|||
|
||||
py.clean:
|
||||
$(RM) -f *.done *.pyc *.rep
|
||||
/bin/bash $(JWB_SCRIPT_DIR)/scm.sh clean -f __init__.py
|
||||
$(RM) -rf __pycache__ .mypy_cache
|
||||
ifeq ($(PY_UPDATE_INIT_PY),true)
|
||||
/bin/bash $(JWB_SCRIPT_DIR)/scm.sh clean -f __init__.py
|
||||
endif
|
||||
|
||||
install-dirs.done:
|
||||
$(INSTALL) -d -m $(PYJWBDIRMODE) -o $(PYJWBDIROWNER) -g $(PYJWBDIRGROUP) $(PY_INSTALL_DIRS)
|
||||
|
|
|
|||
Loading…
Reference in a new issue