-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: build macOS packages using cibuildwheel
Close #1558.
- Loading branch information
Showing
3 changed files
with
52 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ on: | |
|
||
jobs: | ||
build-sdist: | ||
if: true | ||
# NOMERGE | ||
if: false | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -27,7 +28,6 @@ jobs: | |
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packages_sdist | ||
path: | | ||
dist/*/*.tar.gz | ||
|
@@ -54,7 +54,8 @@ jobs: | |
build-manylinux: | ||
if: true | ||
# NOMERGE | ||
if: false | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -95,7 +96,6 @@ jobs: | |
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packages_${{ matrix.tag }}_${{ matrix.arch }} | ||
path: | | ||
dist/*/*${{ matrix.tag }}_${{ matrix.arch }}.whl | ||
|
@@ -117,30 +117,34 @@ jobs: | |
build-macos: | ||
runs-on: macos-latest | ||
if: true | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] | ||
# These archs require an Apple M1 runner: [arm64, universal2] | ||
arch: [x86_64] | ||
pyver: [cp37, cp38, cp39, cp310, cp311] | ||
|
||
steps: | ||
- name: Checkout repos | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Build packages | ||
run: ./scripts/build/build_macos.sh | ||
package-dir: psycopg_binary | ||
env: | ||
PACKAGE_NAME: psycopg2-binary | ||
PSYCOPG2_TESTDB: postgres | ||
PSYCOPG2_TEST_FAST: 1 | ||
CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}} | ||
CIBW_ARCHS_MACOS: x86_64 | ||
CIBW_BEFORE_ALL_MACOS: ./scripts/build/wheel_macos_before_all.sh | ||
CIBW_TEST_COMMAND: >- | ||
python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')" | ||
CIBW_ENVIRONMENT: >- | ||
PACKAGE_NAME=psycopg2-binary | ||
PSYCOPG2_TESTDB=postgres | ||
PSYCOPG2_TEST_FAST=1 | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: packages_macos | ||
path: | | ||
dist/*/*${{ matrix.platform }}.whl | ||
path: ./wheelhouse/*.whl |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Configure the environment needed to build wheel packages on Mac OS. | ||
# This script is designed to be used by cibuildwheel as CIBW_BEFORE_ALL_MACOS | ||
|
||
set -euo pipefail | ||
set -x | ||
|
||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
brew install gnu-sed postgresql@15 | ||
|
||
# Start the database for testing | ||
brew services start postgresql | ||
|
||
# Wait for postgres to come up | ||
for i in $(seq 10 -1 0); do | ||
eval pg_isready && break | ||
if [ $i == 0 ]; then | ||
echo "PostgreSQL service not ready, giving up" | ||
exit 1 | ||
fi | ||
echo "PostgreSQL service not ready, waiting a bit, attempts left: $i" | ||
sleep 5 | ||
done | ||
|
||
# Replace the package name | ||
if [[ "${PACKAGE_NAME:-}" ]]; then | ||
gsed -i "s/^setup(name=\"psycopg2\"/setup(name=\"${PACKAGE_NAME}\"/" \ | ||
"${prjdir}/setup.py" | ||
fi |