Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(macos): Avoid linking against Homebrew #1755

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bwoodsend
Copy link

Homebrew binaries are always compiled for exactly the version they're installed on making them very unportable. When a wheel is "repaired" by cibuildwheel, delocate-wheel pulls in _psycopg's dependencies (libpq.dylib, libssl.dylib and libcrypto.dylib) which, on a GitHub Actions macOS 14 runner, are provided by Homebrew and are therefore only macOS >= 14 compatible. The resultant wheel is therefore incompatible with all but the latest macOS versions.

Build all dependencies from source so that we can set the deployment target to something sensible. Fixes #1753.

Homebrew binaries are always compiled for exactly the version they're
installed on making them very unportable. When a wheel is "repaired" by
cibuildwheel, delocate-wheel pulls in _psycopg's dependencies
(libpq.dylib, libssl.dylib and libcrypto.dylib) which, on a GitHub
Actions macOS 14 runner, are provided by Homebrew and are therefore only
macOS >= 14 compatible. The resultant wheel is therefore incompatible
with all but the latest macOS versions.

Build all dependencies from source so that we can set the deployment
target to something sensible.
@bwoodsend
Copy link
Author

bwoodsend commented Nov 22, 2024

I've temporarily disabled all the other bits of CI just to make verifying quicker. I'll revert all that if/when we get closer to merging. I wanted to gauge whether you think this is worth the trouble before finishing it off? I can't imagine you'd be particularly comfortable with having a rather hairy build step that you can't run locally.

Here's a sample build with the macOS versions in the wheel tags back to normal.

@dvarrazzo
Copy link
Member

dvarrazzo commented Nov 23, 2024

Yes, this seems useful, and it's what we do for Linux: see the scripts/build/build_libpq.sh. Maybe it would be worth augmenting that script with macOS support? For sure it's better to edit complex bash in a .sh file than interspersed in yaml.

If you complete this operation it would be useful to port it to psycopg 3 too (which has a script pretty much identical).

Hint: you can use if: false to disable a job, which is less invasive then chopping everything away (the reason why there are the if: true in the workflow file is to remember that).

Thank you very much for your initiative!

export LDFLAGS="-L$fake_prefix/lib"
export CPPFLAGS="-I$fake_prefix/include"
cd postgresql-16.6
./configure --without-icu --prefix="$fake_prefix" --with-ssl=openssl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No gssapi/ldap support?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was going to ask about which --with-xxx features to use but you beat me to it. I see build_libpq.sh makes that decision for me anyway.

@dvarrazzo
Copy link
Member

What is, on macOS, the default socket dir? In other words:

$ psql "host='' port=9999"
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.9999" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?

what path is searched for in macOS? If it's not /tmp then it's worth patching the libpq before building, see

# Match the default unix socket dir default with what defined on Ubuntu and
# Red Hat, which seems the most common location
sed -i 's|#define DEFAULT_PGSOCKET_DIR .*'\
'|#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql"|' \
src/include/pg_config_manual.h

@bwoodsend
Copy link
Author

see the scripts/build/build_libpq.sh. Maybe it would be worth augmenting that script with macOS support? For sure it's better to edit complex bash in a .sh file than interspersed in yaml.

Thanks for pointing that out. Yes, adding macOS support to that script sounds better than doing it all over again in YAML.

What is, on macOS, the default socket dir?

I wasn't aware that there was such thing as a socket dir but does this answer your question?

> psql "host='' port=9999"
psql: error: connection to server on socket "/tmp/.s.PGSQL.9999" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?

(That's homebrew's psql – not a source built one in case it matters.)

@bwoodsend
Copy link
Author

bwoodsend commented Nov 23, 2024

Do you mind if I bump the OpenLDAP version? I need this fix or the check for POSIX regex throws a false negative. (It's probably sed-able if not.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

High macOS deployment targets for psycopg2-binary
2 participants