Skip to content

Commit 680d700

Browse files
Alexpuxlazka
andcommitted
add python config sh
Co-authored-by: Алексей <[email protected]> Co-authored-by: Christoph Reiter <[email protected]>
1 parent 94d2c46 commit 680d700

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

Misc/python-config.sh.in

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
11
#!/bin/sh
22

3-
# Keep this script in sync with python-config.in
4-
53
exit_with_usage ()
64
{
75
echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
8-
exit $1
6+
exit 1
97
}
108

9+
# Really, python-config.py (and thus .sh) should be called directly, but
10+
# sometimes software (e.g. GDB) calls python-config.sh as if it were the
11+
# Python executable, passing python-config.py as the first argument.
12+
# Work around that oddness by ignoring any .py passed as first arg.
13+
case "$1" in
14+
*.py)
15+
shift
16+
;;
17+
esac
18+
1119
if [ "$1" = "" ] ; then
12-
exit_with_usage 1
20+
exit_with_usage
1321
fi
1422

1523
# Returns the actual prefix where this script was installed to.
1624
installed_prefix ()
1725
{
18-
RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
19-
if which readlink >/dev/null 2>&1 ; then
20-
if readlink -f "$RESULT" >/dev/null 2>&1; then
21-
RESULT=$(readlink -f "$RESULT")
22-
fi
26+
local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
27+
if [ $(which readlink) ] ; then
28+
RESULT=$(readlink -f "$RESULT")
29+
fi
30+
# Since we don't know where the output from this script will end up
31+
# we keep all paths in Windows-land since MSYS2 can handle that
32+
# while native tools can't handle paths in MSYS2-land.
33+
if [ "$OSTYPE" = "msys" ]; then
34+
RESULT=$(cd "$RESULT" && pwd -W)
2335
fi
2436
echo $RESULT
2537
}
2638

2739
prefix_real=$(installed_prefix "$0")
2840

29-
# Use sed to fix paths from their built-to locations to their installed-to
41+
# Use sed to fix paths from their built-to locations to their installed to
3042
# locations. Keep prefix & exec_prefix using their original values in case
3143
# they are referenced in other configure variables, to prevent double
3244
# substitution, issue #22140.
@@ -41,13 +53,17 @@ LIBM="@LIBM@"
4153
LIBC="@LIBC@"
4254
SYSLIBS="$LIBM $LIBC"
4355
ABIFLAGS="@ABIFLAGS@"
56+
# Protect against lack of substitution.
57+
if [ "$ABIFLAGS" = "@""ABIFLAGS""@" ] ; then
58+
ABIFLAGS=
59+
fi
4460
LIBS="@LIBPYTHON@ @LIBS@ $SYSLIBS"
4561
LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS"
4662
BASECFLAGS="@BASECFLAGS@"
47-
LDLIBRARY="@LDLIBRARY@"
4863
OPT="@OPT@"
4964
PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
5065
LDVERSION="@LDVERSION@"
66+
LDLIBRARY="@LDLIBRARY@"
5167
LIBDEST=${prefix_real}/lib/python${VERSION}
5268
LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#")
5369
SO="@EXT_SUFFIX@"
@@ -61,15 +77,15 @@ for ARG in $*
6177
do
6278
case $ARG in
6379
--help)
64-
exit_with_usage 0
80+
exit_with_usage
6581
;;
6682
--embed)
6783
PY_EMBED=1
6884
;;
6985
--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
7086
;;
7187
*)
72-
exit_with_usage 1
88+
exit_with_usage
7389
;;
7490
esac
7591
done
@@ -80,37 +96,37 @@ fi
8096

8197
for ARG in "$@"
8298
do
83-
case "$ARG" in
99+
case $ARG in
84100
--prefix)
85-
echo "$prefix_real"
101+
echo -ne "$prefix_real"
86102
;;
87103
--exec-prefix)
88-
echo "$exec_prefix_real"
104+
echo -ne "$exec_prefix_real "
89105
;;
90106
--includes)
91-
echo "$INCDIR $PLATINCDIR"
107+
echo -ne "$INCDIR $PLATINCDIR"
92108
;;
93109
--cflags)
94-
echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
110+
echo -ne "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
95111
;;
96112
--libs)
97-
echo "$LIBS"
113+
echo -ne "$LIBS"
98114
;;
99115
--ldflags)
100116
LIBPLUSED=
101117
if [ "$PY_ENABLE_SHARED" = "0" ] ; then
102118
LIBPLUSED="-L$LIBPL"
103119
fi
104-
echo "$LIBPLUSED -L$libdir $LIBS"
120+
echo -ne "$LIBPLUSED -L$libdir $LIBS "
105121
;;
106122
--extension-suffix)
107-
echo "$SO"
123+
echo -ne "$SO "
108124
;;
109125
--abiflags)
110-
echo "$ABIFLAGS"
126+
echo -ne "$ABIFLAGS "
111127
;;
112128
--configdir)
113-
echo "$LIBPL"
129+
echo -ne "$LIBPL "
114130
;;
115131
esac
116132
done

0 commit comments

Comments
 (0)