mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 10:53:44 +03:00
parent
daeec37fab
commit
97df29a312
33
.github/workflows/packages.yml
vendored
33
.github/workflows/packages.yml
vendored
|
@ -27,7 +27,6 @@ jobs:
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: packages_sdist
|
|
||||||
path: |
|
path: |
|
||||||
dist/*/*.tar.gz
|
dist/*/*.tar.gz
|
||||||
|
|
||||||
|
@ -95,7 +94,6 @@ jobs:
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: packages_${{ matrix.tag }}_${{ matrix.arch }}
|
|
||||||
path: |
|
path: |
|
||||||
dist/*/*${{ matrix.tag }}_${{ matrix.arch }}.whl
|
dist/*/*${{ matrix.tag }}_${{ matrix.arch }}.whl
|
||||||
|
|
||||||
|
@ -117,30 +115,33 @@ jobs:
|
||||||
build-macos:
|
build-macos:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
if: true
|
if: true
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
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:
|
steps:
|
||||||
- name: Checkout repos
|
- name: Checkout repos
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Build wheels
|
||||||
uses: actions/setup-python@v4
|
uses: pypa/cibuildwheel@v2.12.1
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Build packages
|
|
||||||
run: ./scripts/build/build_macos.sh
|
|
||||||
env:
|
env:
|
||||||
PACKAGE_NAME: psycopg2-binary
|
CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}}
|
||||||
PSYCOPG2_TESTDB: postgres
|
CIBW_ARCHS_MACOS: x86_64
|
||||||
PSYCOPG2_TEST_FAST: 1
|
CIBW_BEFORE_ALL_MACOS: ./scripts/build/wheel_macos_before_all.sh
|
||||||
|
CIBW_TEST_COMMAND: >-
|
||||||
|
export PYTHONPATH={project} &&
|
||||||
|
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
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: packages_macos
|
path: ./wheelhouse/*.whl
|
||||||
path: |
|
|
||||||
dist/*/*${{ matrix.platform }}.whl
|
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Create macOS wheels for psycopg2
|
|
||||||
#
|
|
||||||
# Following instructions from https://github.com/MacPython/wiki/wiki/Spinning-wheels
|
|
||||||
# Cargoculting pieces of implementation from https://github.com/matthew-brett/multibuild
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
set -x
|
|
||||||
|
|
||||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
prjdir="$( cd "${dir}/../.." && pwd )"
|
|
||||||
|
|
||||||
brew update
|
|
||||||
brew install gnu-sed postgresql@14
|
|
||||||
# Fetch 14.1 if 14.0 is still the default version
|
|
||||||
brew reinstall postgresql
|
|
||||||
|
|
||||||
# Start the database for testing
|
|
||||||
brew services start postgresql
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Find psycopg version
|
|
||||||
version=$(grep -e ^PSYCOPG_VERSION "${prjdir}/setup.py" | gsed "s/.*'\(.*\)'/\1/")
|
|
||||||
# A gratuitous comment to fix broken vim syntax file: '")
|
|
||||||
distdir="${prjdir}/dist/psycopg2-$version"
|
|
||||||
mkdir -p "$distdir"
|
|
||||||
|
|
||||||
# Install required python packages
|
|
||||||
pip install -U pip wheel delocate
|
|
||||||
|
|
||||||
# Replace the package name
|
|
||||||
if [[ "${PACKAGE_NAME:-}" ]]; then
|
|
||||||
gsed -i "s/^setup(name=\"psycopg2\"/setup(name=\"${PACKAGE_NAME}\"/" \
|
|
||||||
"${prjdir}/setup.py"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build the wheels
|
|
||||||
wheeldir="${prjdir}/wheels"
|
|
||||||
pip wheel -w ${wheeldir} .
|
|
||||||
delocate-listdeps ${wheeldir}/*.whl
|
|
||||||
|
|
||||||
# Check where is the libpq. I'm gonna kill it for testing
|
|
||||||
if [[ -z "${LIBPQ:-}" ]]; then
|
|
||||||
export LIBPQ=$(delocate-listdeps ${wheeldir}/*.whl | grep libpq)
|
|
||||||
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
|
|
||||||
cp ${wheeldir}/*.whl ${distdir}
|
|
||||||
|
|
||||||
# kill the libpq to make sure tests don't depend on it
|
|
||||||
mv "$LIBPQ" "${LIBPQ}-bye"
|
|
||||||
|
|
||||||
# Install and test the built wheel
|
|
||||||
pip install ${PACKAGE_NAME:-psycopg2} --no-index -f "$distdir"
|
|
||||||
|
|
||||||
# Print psycopg and libpq versions
|
|
||||||
python -c "import psycopg2; print(psycopg2.__version__)"
|
|
||||||
python -c "import psycopg2; print(psycopg2.__libpq_version__)"
|
|
||||||
python -c "import psycopg2; print(psycopg2.extensions.libpq_version())"
|
|
||||||
|
|
||||||
# fail if we are not using the expected libpq library
|
|
||||||
# Disabled as we just use what's available on the system on macOS
|
|
||||||
# if [[ "${WANT_LIBPQ:-}" ]]; then
|
|
||||||
# python -c "import psycopg2, sys; sys.exit(${WANT_LIBPQ} != psycopg2.extensions.libpq_version())"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')"
|
|
||||||
|
|
||||||
# just because I'm a boy scout
|
|
||||||
mv "${LIBPQ}-bye" "$LIBPQ"
|
|
32
scripts/build/wheel_macos_before_all.sh
Executable file
32
scripts/build/wheel_macos_before_all.sh
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/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 )"
|
||||||
|
prjdir="$( cd "${dir}/../.." && 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
|
Loading…
Reference in New Issue
Block a user