mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
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>
This commit is contained in:
parent
42e01d9dd8
commit
ab5fc0c334
2 changed files with 60 additions and 30 deletions
|
|
@ -7,6 +7,9 @@ JW_BUILD_DEF_MK_INCLUDED = true
|
||||||
|
|
||||||
MAKEFLAGS += -r
|
MAKEFLAGS += -r
|
||||||
|
|
||||||
|
empty :=
|
||||||
|
space := $(empty) $(empty)
|
||||||
|
|
||||||
include $(MODDIR)/make/projects.mk
|
include $(MODDIR)/make/projects.mk
|
||||||
|
|
||||||
ifeq ($(MAKE_BENCHMARK),true)
|
ifeq ($(MAKE_BENCHMARK),true)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
ENV_PYTHONPATH := $(PYTHONPATH)
|
ENV_PYTHONPATH := $(PYTHONPATH)
|
||||||
|
|
||||||
ifeq ($(PYTHON),)
|
ifeq ($(PYTHON),)
|
||||||
PYTHON_VERSION ?= 3
|
PYTHON_VERSION ?= 3
|
||||||
PYTHON ?= /usr/bin/python$(PYTHON_VERSION)
|
PYTHON ?= /usr/bin/python$(PYTHON_VERSION)
|
||||||
|
|
@ -6,26 +7,35 @@ else
|
||||||
PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON)))
|
PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON)))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(DEVELOPMENT),true)
|
ifeq ($(DEVELOPMENT),true)
|
||||||
PY_SITE_PACKAGES_PATH := $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[0])")
|
|
||||||
else
|
|
||||||
PY_SITE_PACKAGES_PATH := $(PREFIX)/python$(PYTHON_VERSION)/site-packages
|
PY_SITE_PACKAGES_PATH := $(PREFIX)/python$(PYTHON_VERSION)/site-packages
|
||||||
|
else
|
||||||
|
PY_SITE_PACKAGES_PATH := $(shell $(PYTHON) -c "import site; print(site.getsitepackages()[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
|
endif
|
||||||
|
|
||||||
PY_PREREQ_BUILD ?= $(shell $(proj_query_cmd) pkg-requires --subsections jw -d ' ' -p --no-version build $(PROJECT))
|
|
||||||
PY_PREREQ_BUILD_DIRS ?= $(shell $(proj_query_cmd) proj-dir $(PY_PREREQ_BUILD))
|
|
||||||
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_PROJ_MODULES += $(dir $(wildcard $(PY_MODULE_DIRS)/*/__init__.py))
|
|
||||||
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 = $(PY_SRC_PY)
|
||||||
|
|
||||||
ifneq ($(PYTHON_VERSION),3)
|
ifneq ($(PYTHON_VERSION),3)
|
||||||
PY_PYC = $(patsubst %.py,%.pyc,$(PY_ALL_PY))
|
PY_PYC = $(patsubst %.py,%.pyc,$(PY_ALL_PY))
|
||||||
else
|
else
|
||||||
PY_PYC = $(patsubst %.py,__pycache__/%.cpython-37.pyc,$(PY_ALL_PY))
|
PY_PYC = $(patsubst %.py,__pycache__/%.cpython-37.pyc,$(PY_ALL_PY))
|
||||||
endif
|
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_PKG_MOD ?= $(shell $(ECHO) $(CWD) | $(SED) 's%.*/python/%%; s%/.*%%')
|
||||||
PY_INSTALL_SUB_MOD ?= $(shell $(ECHO) $(CWD) | $(SED) "s%.*/$(PY_INSTALL_PKG_MOD)\(/\|$$\)%%")
|
PY_INSTALL_SUB_MOD ?= $(shell $(ECHO) $(CWD) | $(SED) "s%.*/$(PY_INSTALL_PKG_MOD)\(/\|$$\)%%")
|
||||||
ifneq ($(PY_INSTALL_SUB_MOD),)
|
ifneq ($(PY_INSTALL_SUB_MOD),)
|
||||||
|
|
@ -34,35 +44,52 @@ 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_ALL_PY += __init__.py
|
||||||
PY_INSTALL_DIR_PY ?= $(ENV_PREFIX)$(PY_SITE_PACKAGES_PATH)/$(patsubst .,/,$(PY_INSTALL_MOD))
|
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_VERSION),3)
|
ifeq ($(PYTHON_VERSION),3)
|
||||||
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)/__pycache__
|
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)/__pycache__
|
||||||
|
else
|
||||||
|
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)
|
||||||
endif
|
endif
|
||||||
PY_INSTALL_DIRS ?= $(PY_INSTALL_DIR_PY) $(PY_INSTALL_DIR_PYC)
|
|
||||||
PY_INSTALLED_PY = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_ALL_PY))
|
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_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_PYC))
|
PY_INSTALLED_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_PYC))
|
||||||
PY_INSTALLED_REG = $(PY_INSTALLED_PY) $(PY_INSTALLED_PYC)
|
PY_INSTALLED_REG = $(PY_INSTALLED_PY) $(PY_INSTALLED_PYC)
|
||||||
|
|
||||||
empty :=
|
|
||||||
space := $(empty) $(empty)
|
|
||||||
PYTHONPATH ?= $(call proj_query, pythonpath $(PROJECT))
|
PYTHONPATH ?= $(call proj_query, pythonpath $(PROJECT))
|
||||||
#PYTHONPATH = $(subst $(space),,$(ENV_PYTHONPATH)$(foreach d,$(PY_MODULE_DIRS),:$(d)))
|
#PYTHONPATH = $(subst $(space),,$(ENV_PYTHONPATH)$(foreach d,$(PY_MODULE_DIRS),:$(d)))
|
||||||
export PYTHONPATH
|
export PYTHONPATH
|
||||||
|
|
||||||
|
# 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))
|
||||||
|
|
||||||
PY_DEFS_MK_INCLUDED := true
|
PY_DEFS_MK_INCLUDED := true
|
||||||
|
|
||||||
ifneq ($(PY_DEFS_MK_INCLUDED),true)
|
ifneq ($(PY_DEFS_MK_INCLUDED),true)
|
||||||
all:
|
all:
|
||||||
clean: pyc.clean
|
clean: pyc.clean
|
||||||
|
|
||||||
echo-py:
|
echo-py:
|
||||||
@echo PROJECT = $(PROJECT)
|
@echo "PY_INSTALL_DIR_PY = $(PY_INSTALL_DIR_PY)"
|
||||||
@echo PY_PROJ_MODULE_DIRS = $(PY_PROJ_MODULE_DIRS)
|
@echo "PROJECT = $(PROJECT)"
|
||||||
@echo PY_MODULE_DIRS = $(PY_MODULE_DIRS)
|
@echo "PY_SITE_PACKAGES_PATH = $(PY_SITE_PACKAGES_PATH)"
|
||||||
@echo PY_SITE_PACKAGES_PATH = $(PY_SITE_PACKAGES_PATH)
|
@echo "PY_MODULES = $(PY_MODULES)"
|
||||||
@echo PY_MODULES = $(PY_MODULES)
|
@echo "PYTHONPATH = $(PYTHONPATH)"
|
||||||
@echo PYTHONPATH = $(PYTHONPATH)
|
@echo "PY_INSTALL_MOD = $(PY_INSTALL_MOD)"
|
||||||
@echo PY_INSTALL_MOD = $(PY_INSTALL_MOD)
|
@echo "PY_INSTALL_SUB_MOD = $(PY_INSTALL_SUB_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:
|
pyc.clean:
|
||||||
$(RM) -f $(wildcard *.pyc) __pycache__
|
$(RM) -f $(wildcard *.pyc) __pycache__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue