Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /trunk/python/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download)
Sat Mar 18 14:17:18 2023 UTC (2 years ago) by amb
File size: 3668 byte(s)
Do not try to install the Python module when running 'make install'
but write a warning message explaining why and offering suggestions.
Add a pyproject.toml file.

1 # Python interface Makefile
2 #
3 # Part of the Routino routing software.
4 #
5 # This file Copyright 2018, 2019, 2023 Andrew M. Bishop
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
16 #
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 # All configuration is in the top-level Makefile.conf
22
23 include ../Makefile.conf
24
25 # Programs
26
27 PYTHON=python3
28
29 SWIG=swig
30
31 # Compilation targets
32
33 PY_FILES=$(wildcard src/*.py)
34
35 C_FILES=$(wildcard src/*.c)
36 CC_FILES=$(wildcard src/*.cc)
37
38 SWIG_C=src/_router.c
39 SWIG_CC=src/_database.cc
40 SWIG_PY=src/router.py src/database.py
41
42 ifneq ($(HOST),MINGW)
43 LIBROUTINO=../src/libroutino.so
44 else
45 LIBROUTINO=../src/routino.dll
46 endif
47
48 BUILD_TIMESTAMP=build/.timestamp
49
50 # Check that we have Python3 and swig installed
51
52 # Note: We need to use swig here and not have it called from setup.py because
53 # setuptools copies 'py_modules' before building 'ext_modules' so will
54 # miss the python files that are generated by swig.
55
56 HAVE_PYTHON=$(shell $(PYTHON) --version 2> /dev/null)
57
58 HAVE_SWIG=$(shell $(SWIG) -version 2> /dev/null)
59
60 ifeq ($(HAVE_PYTHON),)
61 $(warning Python3 not installed - skipping Python module creation)
62 endif
63
64 ifeq ($(HAVE_SWIG),)
65 $(warning Swig not installed - skipping Python module creation)
66 endif
67
68 ########
69
70 all: $(and $(HAVE_SWIG),$(HAVE_PYTHON),all-if-python)
71
72 all-if-python: $(BUILD_TIMESTAMP)
73
74 ########
75
76 $(BUILD_TIMESTAMP): $(SWIG_C) $(SWIG_CC) $(SWIG_PY) $(PY_FILES) $(C_FILES) $(CC_FILES) $(LIBROUTINO) setup.py
77 @rm -f $@
78 CFLAGS= LDFLAGS= $(PYTHON) setup.py build && touch $(BUILD_TIMESTAMP)
79
80 src/_router.c : src/router.i ../src/routino.h
81 $(SWIG) -python -o $@ $<
82
83 src/router.py : src/_router.c
84 @true # fake rule since src/router.py is created by the same rule as src/_router.c
85
86 src/_database.cc : src/database.i src/database.hh
87 $(SWIG) -c++ -python -o $@ $<
88
89 src/database.py : src/_database.cc
90 @true # fake rule since src/database.py is created by the same rule as src/_database.cc
91
92 $(LIBROUTINO):
93 cd ../src && $(MAKE) all-lib
94
95 ########
96
97 test: $(and $(HAVE_SWIG),$(HAVE_PYTHON),test-if-python)
98
99 test-if-python: $(BUILD_TIMESTAMP)
100 cd test && $(MAKE) test
101
102 ########
103
104 install: $(and $(HAVE_SWIG),$(HAVE_PYTHON),install-if-python)
105
106 install-if-python: all
107 @echo "WARNING: '$(PYTHON) setup.py install' is not supported by Python v3.10 and above."
108 @echo "WARNING: This Makefile therefore no longer tries to install the Routino module."
109 @echo "WARNING: You could try this to install it but it might not work on your system:"
110 @echo "WARNING: $(PYTHON) -m pip $(DESTDIR)$(prefix)"
111 @echo "WARNING: You could try this to build a Python 'wheel' and install that manually:"
112 @echo "WARNING: $(PYTHON) -m build --wheel"
113 -@false
114
115 ########
116
117 clean: clean-local
118 cd test && $(MAKE) $@
119
120 clean-local:
121 rm -f *~
122 rm -rf build
123 rm -rf dist
124 rm -rf Routino.egg-info
125 rm -f $(SWIG_C)
126 rm -f $(SWIG_CC)
127 rm -f $(SWIG_PY)
128
129 ########
130
131 distclean: distclean-local
132 cd test && $(MAKE) $@
133
134 distclean-local: clean-local
135
136 ########
137
138 .PHONY:: all test install clean distclean
139
140 .PHONY:: all-if-python test-if-python install-if-python
141
142 .PHONY:: clean-local distclean-local