RN rnmake  3.0.0
Rules.python.mk
Go to the documentation of this file.
1 ################################################################################
2 #
3 # Rules.python.mk
4 #
5 ifdef RNMAKE_DOXY
6 /*!
7 \file
8 
9 \brief Special rules file to make python modules using standard setup.py
10 python file.
11 
12 Include this file in each appropriate local make file (usually near the bottom).
13 
14 \par Key RNMAKE Variables:
15  \li RNMAKE_PYTHON_ENABLED - python is [not] enabled for this architecture.
16  \li PYTHON_MOD_DIR - python module directory (default: ./modules)
17 
18 \pkgsynopsis
19 RN Make System
20 
21 \pkgfile{Rules.python.mk}
22 
23 \pkgauthor{Robin Knight,robin.knight@roadnarrows.com}
24 
25 \pkgcopyright{2010-2018,RoadNarrows LLC,http://www.roadnarrows.com}
26 
27 \license{MIT}
28 
29 \EulaBegin
30 \EulaEnd
31 
32 \cond RNMAKE_DOXY
33  */
34 endif
35 #
36 ################################################################################
37 
38 _RULES_PYTHON_MK = 1
39 
40 ifeq ($(strip $(RNMAKE_PYTHON_ENABLED)),y)
41 
42 PYTHON_MOD_DIR ?= ./modules
43 
44 SETUP_BUILD_DIR = ./build
45 PYTHON_BUILD_DIR = $(SETUP_BUILD_DIR).$(RNMAKE_ARCH)
46 
47 define unlink_build
48  @if [ -e $(SETUP_BUILD_DIR) ]; \
49  then \
50  $(UNLINK) $(SETUP_BUILD_DIR); \
51  fi
52 endef
53 
54 # Target: python-all (default)
55 #
56 # Use python's standard distutils to build and install python modules. The
57 # "build - install" sequence is equivalent to the RNMAKE "all" target with
58 # the "install" installing into the package dist/dist.<arch> directory.
59 #
60 # Note that the distutils supports where to build the intermediates but does
61 # not support the concept of source location for installing to target location,
62 # but rather always installs from the build directory. Hence the linking high
63 # jynx.
64 #
65 .PHONY: python-all
66 python-all:
67  $(call printGoalDesc,$(PYTHON) setup.py)
68  $(call unlink_build)
69  $(PYTHON) setup.py build --build-base=$(PYTHON_BUILD_DIR)
70  $(SYMLINK) $(PYTHON_BUILD_DIR) $(SETUP_BUILD_DIR)
71  $(PYTHON) setup.py install --prefix=$(DIST_ARCH)
72 
73 # Target: make python source documentation
74 .PHONY: python-doc
75 python-doc:
76  $(call printGoalDesc,$(@),Making python source documentation)
77  @test -d "$(DISTDIR_DOC)/pydoc" || $(MKDIR) $(DISTDIR_DOC)/pydoc
78  @$(PYTHON) $(RNMAKE_ROOT)/utils/pydocmk.py \
79  --docroot=$(DISTDIR_DOC)/pydoc \
80  --vpath=$(DIST_VPATH_LIB) \
81  setup
82 
83 # Target: python-clean
84 .PHONY: python-clean
85 python-clean:
86  $(call printGoalDesc,$(@),Removing byte-compiled python files)
87  @$(FIND) $(PYTHON_MOD_DIR) \( \
88  -name '*.svn*' -or -wholename '.svn' -or \
89  -wholename '*.deps*' -or -wholename '.deps' -or \
90  -wholename '*obj*' -or -wholename 'obj' -or -wholename '*.o' -or \
91  -wholename '*.out' -or -wholename '*.log' \
92  \) -prune -or -print | \
93  $(GREP) -e '.py[co]' | \
94  $(XARGS) $(RM)
95 
96 .PHONY: python-distclean
97 python-distclean:
98  $(call printGoalDesc,$(@),Removing intermediate $(PYTHON_BUILD_DIR) directory)
99  $(call unlink_build)
100  @$(RM) $(PYTHON_BUILD_DIR)
101 
102 else
103 
104 python-all python-doc python-clean python-distclean:
105  @printf "python not enabled - ignoring\n"
106 
107 endif
108 
109 ifdef RNMAKE_DOXY
110 /*! \endcond RNMAKE_DOXY */
111 endif