mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
py-defs.mk, py-mod.mk: Add support for Python3's __pycache__
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
367dfb90c2
commit
fe161ff4d6
2 changed files with 31 additions and 12 deletions
|
|
@ -3,9 +3,9 @@ PYTHON ?= python2
|
||||||
#PYTHON = python3
|
#PYTHON = python3
|
||||||
|
|
||||||
ifneq ($(DEVELOPMENT),true)
|
ifneq ($(DEVELOPMENT),true)
|
||||||
PY_SITE_PACKAGES_PATH = $(shell $(PYTHON) -c "import site; print site.getsitepackages()[0]")
|
PY_SITE_PACKAGES_PATH := $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")
|
||||||
else
|
else
|
||||||
PY_SITE_PACKAGES_PATH = $(PREFIX)/python2/site-packages
|
PY_SITE_PACKAGES_PATH := $(PREFIX)/python2/site-packages
|
||||||
endif
|
endif
|
||||||
|
|
||||||
PY_PREREQ_BUILD ?= $(shell $(proj_query_cmd) pkg-requires --subsections jw -d ' ' -p --no-version build $(PROJECT))
|
PY_PREREQ_BUILD ?= $(shell $(proj_query_cmd) pkg-requires --subsections jw -d ' ' -p --no-version build $(PROJECT))
|
||||||
|
|
@ -16,7 +16,11 @@ PY_PROJ_MODULES += $(dir $(wildcard $(PY_MODULE_DIRS)/*/__init__.py)
|
||||||
PY_MODULES ?= $(PY_PROJ_MODULES)
|
PY_MODULES ?= $(PY_PROJ_MODULES)
|
||||||
PY_SRC_PY ?= $(wildcard *.py)
|
PY_SRC_PY ?= $(wildcard *.py)
|
||||||
PY_ALL_PY = $(sort $(PY_SRC_PY) __init__.py)
|
PY_ALL_PY = $(sort $(PY_SRC_PY) __init__.py)
|
||||||
PY_PYC = $(patsubst %.py,%.pyc,$(PY_ALL_PY))
|
ifneq ($(PYTHON),python3)
|
||||||
|
PY_PYC = $(patsubst %.py,%.pyc,$(PY_ALL_PY))
|
||||||
|
else
|
||||||
|
PY_PYC = $(patsubst %.py,__pycache__/%.cpython-37.pyc,$(PY_ALL_PY))
|
||||||
|
endif
|
||||||
|
|
||||||
PY_INSTALL_PKG_MOD ?= $(shell $(PWD) | sed 's%.*/python/%%; s%/.*%%')
|
PY_INSTALL_PKG_MOD ?= $(shell $(PWD) | sed 's%.*/python/%%; s%/.*%%')
|
||||||
PY_INSTALL_SUB_MOD ?= $(shell $(PWD) | sed "s%.*/$(PY_INSTALL_PKG_MOD)\(/\|$$\)%%")
|
PY_INSTALL_SUB_MOD ?= $(shell $(PWD) | sed "s%.*/$(PY_INSTALL_PKG_MOD)\(/\|$$\)%%")
|
||||||
|
|
@ -26,8 +30,14 @@ else
|
||||||
PY_INSTALL_MOD ?= $(PY_INSTALL_PKG_MOD)
|
PY_INSTALL_MOD ?= $(PY_INSTALL_PKG_MOD)
|
||||||
endif
|
endif
|
||||||
PY_MOD ?= $(subst /,.,$(PY_INSTALL_MOD))
|
PY_MOD ?= $(subst /,.,$(PY_INSTALL_MOD))
|
||||||
PY_INSTALL_DIR ?= $(ENV_PREFIX)$(PY_SITE_PACKAGES_PATH)/$(patsubst .,/,$(PY_INSTALL_MOD))
|
PY_INSTALL_DIR_PY ?= $(ENV_PREFIX)$(PY_SITE_PACKAGES_PATH)/$(patsubst .,/,$(PY_INSTALL_MOD))
|
||||||
PY_INSTALLED_REG = $(addprefix $(PY_INSTALL_DIR)/,$(PY_ALL_PY) $(PY_PYC))
|
ifeq ($(PYTHON),python3)
|
||||||
|
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)/__pycache__
|
||||||
|
endif
|
||||||
|
PY_INSTALL_DIRS ?= $(PY_INSTALL_DIR_PY) $(PY_INSTALL_DIR_PYC)
|
||||||
|
PY_INSTALLED_PY = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_ALL_PY))
|
||||||
|
PY_INSTALLED_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_PYC))
|
||||||
|
PY_INSTALLED_REG = $(PY_INSTALLED_PY) $(PY_INSTALLED_PYC)
|
||||||
|
|
||||||
empty :=
|
empty :=
|
||||||
space := $(empty) $(empty)
|
space := $(empty) $(empty)
|
||||||
|
|
@ -51,7 +61,7 @@ echo-py:
|
||||||
@echo PY_INSTALL_SUB_MOD = $(PY_INSTALL_SUB_MOD)
|
@echo PY_INSTALL_SUB_MOD = $(PY_INSTALL_SUB_MOD)
|
||||||
|
|
||||||
pyc.clean:
|
pyc.clean:
|
||||||
$(RM) -f $(wildcard *.pyc)
|
$(RM) -f $(wildcard *.pyc) __pycache__
|
||||||
libpath: py-libpath
|
libpath: py-libpath
|
||||||
py-libpath:
|
py-libpath:
|
||||||
@echo export PYTHONPATH=$(PYTHONPATH)
|
@echo export PYTHONPATH=$(PYTHONPATH)
|
||||||
|
|
|
||||||
|
|
@ -17,21 +17,30 @@ distclean:
|
||||||
py.clean:
|
py.clean:
|
||||||
$(RM) -f *.done *.pyc
|
$(RM) -f *.done *.pyc
|
||||||
/bin/bash $(MOD_SCRIPT_DIR)/scm.sh clean -f __init__.py
|
/bin/bash $(MOD_SCRIPT_DIR)/scm.sh clean -f __init__.py
|
||||||
|
$(RM) -rf __pycache__
|
||||||
|
|
||||||
install-dirs.done:
|
install-dirs.done:
|
||||||
$(INSTALL) -d -m $(PYMODDIRMODE) -o $(PYMODDIROWNER) -g $(PYMODDIRGROUP) $(PY_INSTALL_DIR)
|
$(INSTALL) -d -m $(PYMODDIRMODE) -o $(PYMODDIROWNER) -g $(PYMODDIRGROUP) $(PY_INSTALL_DIRS)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
install-reg.done: install-dirs.done $(PY_INSTALLED_REG)
|
install-reg.done: install-dirs.done $(PY_INSTALLED_REG)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
%.pyc: %.py
|
$(PY_INSTALL_DIR_PY)/%.py: %.py
|
||||||
python2 -c "import py_compile; py_compile.compile(\"$<\")"
|
|
||||||
|
|
||||||
$(PY_INSTALL_DIR)/%.py: %.py
|
|
||||||
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
|
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
|
||||||
|
|
||||||
$(PY_INSTALL_DIR)/%.pyc: %.pyc
|
ifneq ($(PYTHON),python3)
|
||||||
|
%.pyc: %.py
|
||||||
|
else
|
||||||
|
__pycache__/%.cpython-37.pyc: %.py
|
||||||
|
endif
|
||||||
|
$(PYTHON) -c "import py_compile; py_compile.compile(\"$<\")"
|
||||||
|
|
||||||
|
ifeq ($(PYTHON),python3)
|
||||||
|
$(PY_INSTALL_DIR_PY)/__pycache__/%.cpython-37.pyc: __pycache__/%.cpython-37.pyc
|
||||||
|
else
|
||||||
|
$(PY_INSTALL_DIR_PY)/%.pyc: %.pyc
|
||||||
|
endif
|
||||||
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
|
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
|
||||||
|
|
||||||
__init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY))
|
__init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue