- Issue #16235: Implement python-config as a shell script. · python/cpython@8742119 · GitHub
Skip to content

Commit 8742119

Browse files
author
doko@python.org
committed
- Issue #16235: Implement python-config as a shell script.
1 parent ed3c412 commit 8742119

5 files changed

Lines changed: 133 additions & 6 deletions

File tree

Makefile.pre.in

Lines changed: 7 additions & 4 deletions

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ Tests
763763
Build
764764
-----
765765

766+
- Issue #16235: Implement python-config as a shell script.
767+
766768
- Issue #16769: Remove outdated Visual Studio projects.
767769

768770
- Issue #17031: Fix running regen in cross builds.

Misc/python-config.sh.in

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/sh
2+
3+
exit_with_usage ()
4+
{
5+
echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir"
6+
exit $1
7+
}
8+
9+
if [ "$1" = "" ] ; then
10+
exit_with_usage 1
11+
fi
12+
13+
# Returns the actual prefix where this script was installed to.
14+
installed_prefix ()
15+
{
16+
RESULT=$(dirname $(cd $(dirname "$1") && pwd -P))
17+
if which readlink >/dev/null 2>&1 ; then
18+
RESULT=$(readlink -f "$RESULT")
19+
fi
20+
echo $RESULT
21+
}
22+
23+
prefix_build="@prefix@"
24+
prefix_real=$(installed_prefix "$0")
25+
26+
# Use sed to fix paths from their built to locations to their installed to locations.
27+
prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#")
28+
exec_prefix_build="@exec_prefix@"
29+
exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#")
30+
includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#")
31+
libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#")
32+
CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#")
33+
VERSION="@VERSION@"
34+
LIBM="@LIBM@"
35+
LIBC="@LIBC@"
36+
SYSLIBS="$LIBM $LIBC"
37+
ABIFLAGS="@ABIFLAGS@"
38+
LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}${ABIFLAGS}"
39+
BASECFLAGS="@BASECFLAGS@"
40+
LDLIBRARY="@LDLIBRARY@"
41+
LINKFORSHARED="@LINKFORSHARED@"
42+
OPT="@OPT@"
43+
PY_ENABLE_SHARED="@PY_ENABLE_SHARED@"
44+
LDVERSION="@LDVERSION@"
45+
LIBDEST=${prefix}/lib/python${VERSION}
46+
LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#")
47+
SO="@SO@"
48+
PYTHONFRAMEWORK="@PYTHONFRAMEWORK@"
49+
INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
50+
PLATINCDIR="-I$includedir/python${VERSION}${ABIFLAGS}"
51+
52+
# Scan for --help or unknown argument.
53+
for ARG in $*
54+
do
55+
case $ARG in
56+
--help)
57+
exit_with_usage 0
58+
;;
59+
--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir)
60+
;;
61+
*)
62+
exit_with_usage 1
63+
;;
64+
esac
65+
done
66+
67+
for ARG in "$@"
68+
do
69+
case "$ARG" in
70+
--prefix)
71+
echo "$prefix"
72+
;;
73+
--exec-prefix)
74+
echo "$exec_prefix"
75+
;;
76+
--includes)
77+
echo "$INCDIR $PLATINCDIR"
78+
;;
79+
--cflags)
80+
echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT"
81+
;;
82+
--libs)
83+
echo "$LIBS"
84+
;;
85+
--ldflags)
86+
LINKFORSHAREDUSED=
87+
if [ -z "$PYTHONFRAMEWORK" ] ; then
88+
LINKFORSHAREDUSED=$LINKFORSHARED
89+
fi
90+
LIBPLUSED=
91+
if [ "$PY_ENABLE_SHARED" = "0" ] ; then
92+
LIBPLUSED="-L$LIBPL"
93+
fi
94+
echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED"
95+
;;
96+
--extension-suffix)
97+
echo "$SO"
98+
;;
99+
--abiflags)
100+
echo "$ABIFLAGS"
101+
;;
102+
--configdir)
103+
echo "$LIBPL"
104+
;;
105+
esac
106+
done

configure

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,8 @@ ac_includes_default="\
625625
ac_subst_vars='LTLIBOBJS
626626
SRCDIRS
627627
THREADHEADERS
628+
LIBPL
629+
PY_ENABLE_SHARED
628630
SOABI
629631
LIBC
630632
LIBM
@@ -5573,6 +5575,7 @@ fi
55735575

55745576
# Other platforms follow
55755577
if test $enable_shared = "yes"; then
5578+
PY_ENABLE_SHARED=1
55765579

55775580
$as_echo "#define Py_ENABLE_SHARED 1" >>confdefs.h
55785581

@@ -5630,6 +5633,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>confdefs.h
56305633

56315634
esac
56325635
else # shared is disabled
5636+
PY_ENABLE_SHARED=0
56335637
case $ac_sys_system in
56345638
CYGWIN*)
56355639
BLDLIBRARY='$(LIBRARY)'
@@ -13689,6 +13693,10 @@ LDVERSION='$(VERSION)$(ABIFLAGS)'
1368913693
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDVERSION" >&5
1369013694
$as_echo "$LDVERSION" >&6; }
1369113695

13696+
13697+
LIBPL="${prefix}/lib/python${VERSION}/config-${LDVERSION}"
13698+
13699+
1369213700
# SO is the extension of shared libraries `(including the dot!)
1369313701
# -- usually .so, .sl on HP-UX, .dll on Cygwin
1369413702
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SO" >&5
@@ -15136,7 +15144,7 @@ $as_echo "#define HAVE_IPA_PURE_CONST_BUG 1" >>confdefs.h
1513615144
fi
1513715145

1513815146
# generate output files
15139-
ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc"
15147+
ac_config_files="$ac_config_files Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh"
1514015148

1514115149
ac_config_files="$ac_config_files Modules/ld_so_aix"
1514215150

@@ -15840,6 +15848,7 @@ do
1584015848
"Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;;
1584115849
"Modules/Setup.config") CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;;
1584215850
"Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;;
15851+
"Misc/python-config.sh") CONFIG_FILES="$CONFIG_FILES Misc/python-config.sh" ;;
1584315852
"Modules/ld_so_aix") CONFIG_FILES="$CONFIG_FILES Modules/ld_so_aix" ;;
1584415853
1584515854
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;

configure.ac

Lines changed: 8 additions & 1 deletion

0 commit comments

Comments
 (0)