Skip to content

macOS: libpython isn't linked with a non-system Python ($Config{dlext} is bundle) #44

Closed

Description

@nukopian

On macOS with a pyenv-installed Python (3.12.12 and 3.14.8, both
--enable-shared), 0.58 and current master build Python.bundle
without linking libpython. perl Makefile.PL prints:
Unrecognized argument in LIBS ignored: 'libpython3.12.dylib', the
link succeeds because of -undefined dynamic_lookup, and then 37 of
the 38 test files fail with symbol not found in flat namespace '_PyBool_Type'.

The cause seems to be line 90 of Makefile.PL, which only turns the
library name into a -l flag if it ends in $Config{dlext} or
$Config{_a}. On macOS dlext is bundle, while the shared library
extension ($Config{so}) is dylib. Since #35,
special_non_windows_check_shared_static_libs sets libpython to
LDLIBRARY, which is libpython3.12.dylib here, so it no longer
matches. On Linux LDLIBRARY ends in .so, which is also dlext,
so Linux isn't affected.

Accepting $Config{so} as well fixes it for me:

-$sel->{libpython} =~ s/lib(.*)(?:\.\Q$Config{dlext}\E|\Q$Config{_a}\E)/-l$1/;
+$sel->{libpython} =~ s/lib(.*)(?:\.\Q$Config{so}\E|\.\Q$Config{dlext}\E|\Q$Config{_a}\E)/-l$1/;

With it, make test passes (38 files, 837 tests) on both Pythons,
and Python Lib shows -lpython3.12 / -lpython3.14. I haven't
tried Linux, Windows or Apple's system Python. The change keeps the
existing two alternatives, so they should behave as before.

Environment: macOS 26.7.1 arm64, Apple clang 21.0.0, Perl 5.36.3
(perlbrew, darwin-thread-multi-2level), Inline::Python 0.58 and
master at 2b2e476.

Activity

  1. niner commented on Oct 25, 2026

    @niner
    Owner

    Fixed in b52d63a and released as 0.59
    Thanks for the report and patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions