summaryrefslogtreecommitdiff
path: root/t/python-prefix.sh
blob: 147bc029bb10cb2a9bc8de0375240c2531f71406 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /bin/sh
# Copyright (C) 2021-2022 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# Test configure options --with-python_prefix and --with-python_exec_prefix.

required=python
. test-init.sh

cat >>configure.ac <<EOF
AM_PATH_PYTHON
AC_OUTPUT
EOF

cat >Makefile.am <<'END'
# to be installed in pythondir:
python_PYTHON = one.py

# to be installed in pythonpkgdir:
pkgpython_PYTHON = pkgtwo.py

one.py:
	echo 'def one(): return 1' >$@ || rm -f $@
pkgtwo.py:
	echo 'def pkgtwo(): return 1' >$@ || rm -f $@

# It's too much trouble to build and install something that actually
# needs to be under exec_prefix. Instead, we'll just check the value of
# the variable.
echo-python-exec-prefix:
	@echo $(PYTHON_EXEC_PREFIX)
END

py_version=$(python -c 'import sys; print("%u.%u" % sys.version_info[:2])')
py_inst_site=inst/lib/python$py_version/site-packages
py_instexec_site=instexec/lib/python$py_version/site-packages

#  First test: if --with-python_prefix is given, by default it should
# be used for python_exec_prefix too.
#
$ACLOCAL
$AUTOCONF
$AUTOMAKE --add-missing

mkdir build
cd build
../configure --with-python_prefix="$(pwd)/inst"
$MAKE install
#
py_installed "$py_inst_site"/one.py
py_installed "$py_inst_site"/one.pyc
#
py_installed "$py_inst_site"/python-prefix/pkgtwo.py
py_installed "$py_inst_site"/python-prefix/pkgtwo.pyc
#
test "$($MAKE echo-python-exec-prefix)" = "$(pwd)/inst"

#  Second test: specify different --with-python_prefix
# and --with-python_exec_prefix values.
#
cd ..
rm -rf build auto4mte.cache
mkdir build
cd build
../configure --with-python_prefix="$(pwd)/inst" \
             --with-python_exec_prefix="$(pwd)/instexec"
$MAKE install
#
py_installed "$py_inst_site"/one.py
py_installed "$py_inst_site"/one.pyc
#
py_installed "$py_inst_site"/python-prefix/pkgtwo.py
py_installed "$py_inst_site"/python-prefix/pkgtwo.pyc
#
test "$($MAKE echo-python-exec-prefix)" = "$(pwd)/instexec"

: