Closed al closed 3 years ago
Yeah, I just noticed that happening, also outside of brew. I'm not sure yet what the cause is.
I don't suppose exposing the --without-python
option (in the same way --with-cassert
is) would be an acceptable short term workaround?
Looking inside the seemingly problematic text-based dylib file:
~ head -n30 /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.tbd
--- !tapi-tbd
tbd-version: 4
targets: [ x86_64-macos, arm64-macos, arm64e-macos ]
uuids:
- target: x86_64-macos
value: EA4FEBF4-8D7C-3D3D-BBCB-B084B95BFBF5
- target: arm64-macos
value: 00000000-0000-0000-0000-000000000000
- target: arm64e-macos
value: 4C205BA2-1934-3B13-AB55-9DBA891C1B13
install-name: '/System/Library/Frameworks/Python.framework/Versions/2.7/Python'
current-version: 2.7.16
compatibility-version: 2.7
allowable-clients:
- targets: [ x86_64-macos, arm64-macos, arm64e-macos ]
clients: [ Accounts, CPAN, CoreAnalytics_executables, CoreGraphicsBindings,
CoreMLTools, CoreNLPFramework, CreateMLTest, CreateML_tests,
DataDetectorsCore_executables, Feldspar, GPUDriversIntel,
HIDSensingPipeline, HSComposer, LanguageModeling, Mica, MobileBluetooth_DevTools,
MobileQuickLook_iosmac, PencilKit_swiftoverlay_iosmac, Photos_Swift,
Picholine, Raft, RaftFramework, RaftFrameworkExternal, SpeechRecognitionCore_executables,
Stocks, TimeSync_exec, UIKit_swiftoverlay, accounts_tool,
appletrace_bindings-python2, ausiss, caffeconverter, cgdump,
coremlpython, disasm, duallinkanalyse, eoslib, fastsim, gxtools,
lldbPluginScriptInterpreterPython2, lldb_host, mrecfpu, pdsasm,
pmrec, pmrec.tmp, py_dasm, pydis, pydis-s2a8, pyobjc, python.exe,
python_modules, pythonw, pytrace, quarantine_test, rogueasm,
sim, sim_bindings-python2, testbotctl, testbotd, testbotd-base,
testbottask, timesyncanalyse, timesynclogextract ]
Again the error message is:
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -bundle -multiply_defined suppress -o plpython2.so plpy_cursorobject.o plpy_elog.o plpy_exec.o plpy_main.o plpy_planobject.o plpy_plpymodule.o plpy_procedure.o plpy_resultobject.o plpy_spi.o plpy_subxactobject.o plpy_typeio.o plpy_util.o -L../../../src/port -L../../../src/common -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/icu4c/lib -L/opt/homebrew/opt/openldap/lib -L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/tcl-tk/lib -Wl,-dead_strip_dylibs -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib -lpython2.7 -ldl -framework CoreFoundation -lintl -bundle_loader ../../../src/backend/postgres
/bin/sh ../../../../config/install-sh -c -d '/opt/homebrew/Cellar/postgresql@12/12.8/share/extension'
/bin/sh ../../../../config/install-sh -c -d '/opt/homebrew/Cellar/postgresql@12/12.8/include/server'
/usr/bin/install -c -m 644 ./plperl.h ./ppport.h ./plperl_helpers.h '/opt/homebrew/Cellar/postgresql@12/12.8/include/server'
/usr/bin/install -c -m 644 ./plpgsql.control ./plpgsql--1.0.sql ./plpgsql--unpackaged--1.0.sql '/opt/homebrew/Cellar/postgresql@12/12.8/share/extension/'
/usr/bin/install -c -m 644 './plpgsql.h' '/opt/homebrew/Cellar/postgresql@12/12.8/include/server'
ld: cannot link directly with dylib/framework, your binary is not an allowed client of /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.tbd for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [plpython2.so] Error 1
make[2]: *** [install-plpython-recurse] Error 2
make[2]: *** Waiting for unfinished jobs....
So am I right in saying we're failing to build plpython2 because it's not explicitly listed as an allowable client of the Python dylib?
Looking on an older machine (MacOSX11.1.sdk) the corresponding file has no allowable-clients
section.
Yeah, it looks like Apple changed it so that you just can't build against the system Python installation anymore.
The way forward is probably to change everything to build against brewed Python.
I tried altering the formula to make it use a brewed version of Python but had no joy, so I offer two awful workarounds for anyone else stuck on this...
This is a terrible and probably dangerous idea, but open /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.tbd
in your favourite text editor and add plpython2, ltree_plpython, jsonb_plpython2, hstore_plpython2
to the clients
array under allowable-clients
.
or
Fork and clone this repo then symlink it to your Taps directory, e.g.:
~ ln -s /path/to/homebrew-postgresql `brew --repo`/Library/Taps/al/homebrew-postgresql
Verify with brew tap
:
~ brew tap
al/postgresql
homebrew/cask
homebrew/core
Edit the formula so that it skips Python:
diff --git a/postgresql@12.rb b/postgresql@12.rb
index b74cc77..1f4ef01 100644
--- a/postgresql@12.rb
+++ b/postgresql@12.rb
@@ -50,7 +50,7 @@ class PostgresqlAT12 < Formula
--with-uuid=e2fs
--with-pam
--with-perl
- --with-python
+ --without-python
--with-tcl
XML2_CONFIG=:
]
Install as normal, e.g.:
~ brew install al/postgresql/postgresql-common -v
~ brew install al/postgresql/postgresql@12 -v
👍
Running
brew install petere/postgresql/postgresql@12
on a new MBP, M1 Pro chip, running Monterey, I'm getting the following:The system Python is being detected and used for includes/libraries, and it seems unsuitable.
For what it's worth I've installed Python 2.7 via Pyenv and Python 3 via Homebrew. The configuration appears correct, but it's evidently not being detected during the build.
Any suggestions?
Excerpt from output: