Skip to content

Commit

Permalink
add python config sh
Browse files Browse the repository at this point in the history
Co-authored-by: Алексей <[email protected]>
Co-authored-by: Christoph Reiter <[email protected]>
  • Loading branch information
Alexpux and lazka committed Aug 25, 2023
1 parent a086a11 commit 5d08426
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions Misc/python-config.sh.in
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
#!/bin/sh

# Keep this script in sync with python-config.in

exit_with_usage ()
{
echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
exit $1
exit 1
}

# Really, python-config.py (and thus .sh) should be called directly, but
# sometimes software (e.g. GDB) calls python-config.sh as if it were the
# Python executable, passing python-config.py as the first argument.
# Work around that oddness by ignoring any .py passed as first arg.
case "$1" in
*.py)
shift
;;
esac

if [ "$1" = "" ] ; then
exit_with_usage 1
exit_with_usage
fi

# Returns the actual prefix where this script was installed to.
installed_prefix ()
{
RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
if which readlink >/dev/null 2>&1 ; then
if readlink -f "$RESULT" >/dev/null 2>&1; then
RESULT=$(readlink -f "$RESULT")
fi
local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
if [ $(which readlink) ] ; then
RESULT=$(readlink -f "$RESULT")
fi
# Since we don't know where the output from this script will end up
# we keep all paths in Windows-land since MSYS2 can handle that
# while native tools can't handle paths in MSYS2-land.
if [ "$OSTYPE" = "msys" ]; then
RESULT=$(cd "$RESULT" && pwd -W)
fi
echo $RESULT
}

prefix_real=$(installed_prefix "$0")

# Use sed to fix paths from their built-to locations to their installed-to
# Use sed to fix paths from their built-to locations to their installed to
# locations. Keep prefix & exec_prefix using their original values in case
# they are referenced in other configure variables, to prevent double
# substitution, issue #22140.
Expand All @@ -41,13 +53,17 @@ LIBM="@LIBM@"
LIBC="@LIBC@"
SYSLIBS="$LIBM $LIBC"
ABIFLAGS="@ABIFLAGS@"
# Protect against lack of substitution.
if [ "$ABIFLAGS" = "@""ABIFLAGS""@" ] ; then
ABIFLAGS=
fi
LIBS="@LIBPYTHON@ @LIBS@ $SYSLIBS"
LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS"
BASECFLAGS="@BASECFLAGS@"
LDLIBRARY="@LDLIBRARY@"
OPT="@OPT@"
PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
LDVERSION="@LDVERSION@"
LDLIBRARY="@LDLIBRARY@"
LIBDEST=${prefix_real}/lib/python${VERSION}
LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#")
SO="@EXT_SUFFIX@"
Expand All @@ -61,15 +77,15 @@ for ARG in $*
do
case $ARG in
--help)
exit_with_usage 0
exit_with_usage
;;
--embed)
PY_EMBED=1
;;
--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
;;
*)
exit_with_usage 1
exit_with_usage
;;
esac
done
Expand All @@ -80,37 +96,37 @@ fi

for ARG in "$@"
do
case "$ARG" in
case $ARG in
--prefix)
echo "$prefix_real"
echo -ne "$prefix_real"
;;
--exec-prefix)
echo "$exec_prefix_real"
echo -ne "$exec_prefix_real "
;;
--includes)
echo "$INCDIR $PLATINCDIR"
echo -ne "$INCDIR $PLATINCDIR"
;;
--cflags)
echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
echo -ne "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
;;
--libs)
echo "$LIBS"
echo -ne "$LIBS"
;;
--ldflags)
LIBPLUSED=
if [ "$PY_ENABLE_SHARED" = "0" ] ; then
LIBPLUSED="-L$LIBPL"
fi
echo "$LIBPLUSED -L$libdir $LIBS"
echo -ne "$LIBPLUSED -L$libdir $LIBS "
;;
--extension-suffix)
echo "$SO"
echo -ne "$SO "
;;
--abiflags)
echo "$ABIFLAGS"
echo -ne "$ABIFLAGS "
;;
--configdir)
echo "$LIBPL"
echo -ne "$LIBPL "
;;
esac
done

0 comments on commit 5d08426

Please sign in to comment.