-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
feat: Cross-compile macos arm64 wheels #1348
Conversation
This uses [cibuildwheel](https://cibuildwheel.readthedocs.io/en/stable/) in order to cross-compile the arm64 wheels for Python 3.8, 3.9 & 3.10. Fixes psycopg#1286
@dvarrazzo thanks for opening this question This PR uses the I did not manage to produce the This can also be tested locally with `cibuildwheel --platform macos --archs arm64 |
I've pushed one more commit to name correctly the upload artifact. Meanwhile, I've tested that it installs: ❯ brew uninstall postgresql
Uninstalling /opt/homebrew/Cellar/postgresql/13.4... (3,230 files, 43.6MB)
❯ pip install ~/Downloads/packages_macos/psycopg2-2.9.1-cp38-cp38-macosx_11_0_arm64.whl --no-cache-dir
Processing /Users/armenzg/Downloads/packages_macos/psycopg2-2.9.1-cp38-cp38-macosx_11_0_arm64.whl
Installing collected packages: psycopg2
Successfully installed psycopg2-2.9.1 |
The latest artifacts will show up in here: You should be able to see |
@@ -51,16 +50,15 @@ jobs: | |||
--health-timeout 5s | |||
--health-retries 5 | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't like two spaces? 🥺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention. prettier
change the formatting of the file. I will change it.
- {tag: manylinux2014, arch: i686} | ||
- {tag: manylinux_2_24, arch: aarch64} | ||
- {tag: manylinux_2_24, arch: ppc64le} | ||
- { tag: manylinux2014, arch: x86_64 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded
build-macos: | ||
runs-on: macos-10.15 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['3.6', '3.7', '3.8', '3.9'] | ||
python-version: ["3.6", "3.7", "3.8", "3.9"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded
I'm not sure it worked: the zip size is only 418k |
Did you try if the result imports and passes the test suite? Honestly releasing packages that aren't tested makes me nervous... |
No worries. I will look at the code tomorrow and see what you have in place for testing. Thanks for the prompt feedback. If you have any specific code you want me to look to see how to get it tested let me know. |
What
you can tweak the env vars you find in What I mean is more a general thing however: future releases will build package that will not be tested automatically by the CI, at least until M1 runners are available. |
|
||
# Build the wheels | ||
wheeldir="${prjdir}/wheels" | ||
pip wheel -w ${wheeldir} . | ||
pip wheel --use-feature=in-tree-build -w ${wheeldir} . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a warning to switch to this.
@@ -8,22 +8,22 @@ | |||
set -euo pipefail | |||
set -x | |||
|
|||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ignore auto-formatting changes for now. My IDE is all messed up. I will fix it up at the very end.
@@ -52,28 +48,33 @@ if [[ -z "${LIBPQ:-}" ]]; then | |||
fi | |||
|
|||
delocate-wheel ${wheeldir}/*.whl | |||
# https://github.com/MacPython/wiki/wiki/Spinning-wheels#question-will-pip-give-me-a-broken-wheel | |||
delocate-addplat --rm-orig -x 10_9 -x 10_10 ${wheeldir}/*.whl | |||
if [[ $(uname -m) != 'arm64' ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to help my M1 machine skip this step.
@@ -0,0 +1,23 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this script for now.
@@ -45,6 +45,7 @@ | |||
# for a consistent versioning pattern. | |||
|
|||
PSYCOPG_VERSION = '2.9.1' | |||
PSYCOPG_NAME = os.environ.get("PACKAGE_NAME", "psycopg2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the need to touch the file to generate pyscopg2-binary
.
If I execute the I can work around this on Sentry by installing postgresql on the developer's machine and get the wheel built on their machines. |
@armenzg, if Sentry would like to help with this work maybe they could lend a machine to use as external worker and do without cross compiling? |
80a2a94
to
30cbc68
Compare
Hi @dvarrazzo I worked on finding ways to fund you instead. The process is out of my hand at the moment. |
I'm not very familiar with the build/test related differences between psycopg2 and psycopg3. But isn't it possible to more or less copy the workflows from psycopg3? For example, it would be nice to get |
@lithammer psycopg2 doesn't use cibuildwheel. Before recently, as you know, there wasn't a standard for musl wheels. Now there is, but it's probably easier to adapt the existing build pipeline to musl than to start using cibuildwheel. The M1 issue is different: you can cross compile but you cannot test the produced artifacts and this is not really acceptable quality IMO. |
This uses cibuildwheel in order to cross-compile the arm64 wheels for Python 3.8, 3.9 & 3.10.
Fixes #1286