diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index c5815da4..e2913dac 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1422,9 +1422,18 @@ use_freebsd_pkg() { # check if 11-R or later release="$(uname -r)" if [ "${release%%.*}" -ge 11 ]; then - if pkg info -e readline > /dev/null && ! command -v pkg-config > /dev/null ; then - # use readline from Ports Collection - # unlike Linux, BSD's cc does not look in /usr/local by default + # Use packages from Ports Collection. + # + # Unlike Linux, BSD's cc does not look in /usr/local by default + # where Ports-installed packages are, but they are available via pkg-config. + # Surprisingly, CPython's Configure only uses pkg-config + # to locate some of the dependencies and not others. + # Here we detect those that are (as of this writing) known + # to not be searched via pkg-config. + # + # XXX: As a side effect, this would pick up any other libs from Ports + # that are searched via compiler + if pkg info -e readline || pkg info -e sqlite3; then export CPPFLAGS="${CPPFLAGS:+${CPPFLAGS% } }-I/usr/local/include" export LDFLAGS="${LDFLAGS:+${LDFLAGS% } }-L/usr/local/lib -Wl,-rpath,/usr/local/lib" fi diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index f9c9a0a9..41bbaa33 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -259,6 +259,42 @@ make install OUT } +@test "readline and sqlite3 are linked from Ports in FreeBSD" { + cached_tarball "Python-3.6.2" + + for lib in readline sqlite3; do + + for i in {1..8}; do stub uname '-s : echo FreeBSD'; done + stub uname '-r : echo 11.0-RELEASE' + for i in {1..2}; do stub uname '-s : echo FreeBSD'; done + stub sysctl '-n hw.ncpu : echo 1' + + stub pkg "$([[ $lib == readline ]] && echo "info -e $lib : true" || echo false)" + if [[ $lib == sqlite3 ]]; then stub pkg echo "info -e $lib : true"; fi + + stub_make_install + + export -n MAKE_OPTS + run_inline_definition <