diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index f47fb139..482b06a1 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -2,6 +2,8 @@ name: Build packages on: - workflow_dispatch + # XXX: Temp change while working on PR; remove with prettier changes + - pull_request jobs: build-sdist: @@ -137,24 +139,44 @@ jobs: # This only uploads the arm64 wheels for Apple M1 silicon usage build-macos-arm64: - runs-on: macos-10.15 + runs-on: ${{ matrix.os }} strategy: fail-fast: false - name: "build-macos (3.8-3.10 - arm64)" + matrix: + os: [macos-10.15, macos-11.0] + name: "build-${{ matrix.os }} - arm64)" steps: - uses: actions/checkout@v2 + - name: Install pre-requisites + run: | + # brew install gnu-sed postgresql@13 + brew install postgresql@13 + brew services start postgresql + # gsed -i "s/^setup(name=\"psycopg2\"/setup(name=\"psycopg2-binary\"/" setup.py + # git diff + # This builds all possible Python versions (currently, 3.8 to 3.10) - uses: pypa/cibuildwheel@v2.1.1 with: output-dir: dist # Read about options here https://cibuildwheel.readthedocs.io/en/stable/options env: - CIBW_ARCHS_MACOS: arm64 - # Skip testing the arm64 builds - CIBW_TEST_SKIP: "*:arm64" + CIBW_ARCHS: arm64 + PACKAGE_NAME: psycopg2-binary + + - name: Some tests + run: | + git diff + ls -l dist + pip install psycopg2-binary --no-index -f dist/ + python -c "import psycopg2; print(psycopg2.__version__)" + python -c "import psycopg2; print(psycopg2.__libpq_version__)" + python -c "import psycopg2; print(psycopg2.extensions.libpq_version())" + python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')" + - name: Upload artifacts uses: actions/upload-artifact@v2 with: - name: packages_macos_arm64 + name: packages_${{ matrix.os }}_arm64 path: | dist/*macosx_11_0_arm64.whl diff --git a/scripts/build/build_macos.sh b/scripts/build/build_macos.sh index 0fe4b56c..d2e1631f 100755 --- a/scripts/build/build_macos.sh +++ b/scripts/build/build_macos.sh @@ -8,8 +8,8 @@ set -euo pipefail set -x -dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -prjdir="$( cd "${dir}/../.." && pwd )" +dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +prjdir="$(cd "${dir}/../.." && pwd)" brew install gnu-sed postgresql@13 @@ -17,13 +17,13 @@ brew install gnu-sed postgresql@13 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 + 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 @@ -35,15 +35,9 @@ 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} . +pip wheel --use-feature=in-tree-build -w ${wheeldir} . delocate-listdeps ${wheeldir}/*.whl # Check where is the libpq. I'm gonna kill it for testing diff --git a/setup.py b/setup.py index 8137ef63..60efb191 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ except ImportError: # for a consistent versioning pattern. PSYCOPG_VERSION = '2.9.1' +PSYCOPG_NAME = os.environ.get("PACKAGE_NAME", "psycopg2") # note: if you are changing the list of supported Python version please fix @@ -545,7 +546,7 @@ except Exception: print("failed to read readme: ignoring...") readme = __doc__ -setup(name="psycopg2", +setup(name=PSYCOPG_NAME, version=PSYCOPG_VERSION, author="Federico Di Gregorio", author_email="fog@initd.org",