Skip to content

Commit

Permalink
Merge pull request #1772 from psycopg/ci-vcpkg
Browse files Browse the repository at this point in the history
Package psycopg2-binary for windows using vcpkg libpq
  • Loading branch information
dvarrazzo authored Jan 4, 2025
2 parents 947f731 + b8d49e6 commit ed4ba11
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 1,189 deletions.
19 changes: 0 additions & 19 deletions .appveyor/cache_rebuild

This file was deleted.

83 changes: 0 additions & 83 deletions .appveyor/packages.yml

This file was deleted.

74 changes: 0 additions & 74 deletions .appveyor/tests.yml

This file was deleted.

72 changes: 72 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,75 @@ jobs:
with:
name: macos-${{matrix.pyver}}-macos-${{matrix.macver}}_${{matrix.arch}}
path: ./wheelhouse/*.whl


build-windows:
runs-on: windows-latest
if: true

strategy:
fail-fast: false
matrix:
arch: [win_amd64]
pyver: [cp38, cp39, cp310, cp311, cp312, cp313]
package_name: [psycopg2, psycopg2-binary]

defaults:
run:
shell: bash

steps:
# there are some other libpq in PATH
- name: Drop spurious libpq in the path
run: rm -rf c:/tools/php C:/Strawberry/c/bin

- name: Checkout repo
uses: actions/checkout@v4

- name: Start PostgreSQL service for test
run: |
$PgSvc = Get-Service "postgresql*"
Set-Service $PgSvc.Name -StartupType manual
$PgSvc.Start()
shell: powershell

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
const path = require('path')
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
core.addPath(path.join(process.env.VCPKG_INSTALLATION_ROOT, 'installed/x64-windows-release/lib'));
core.addPath(path.join(process.env.VCPKG_INSTALLATION_ROOT, 'installed/x64-windows-release/bin'));
- name: Create the binary package source tree
run: >-
sed -i 's/^setup(name="psycopg2"/setup(name="${{matrix.package_name}}"/'
setup.py
if: ${{ matrix.package_name != 'psycopg2' }}

- name: Build wheels
uses: pypa/[email protected]
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" # cache vcpkg
CIBW_BUILD: ${{matrix.pyver}}-${{matrix.arch}}
CIBW_ARCHS_WINDOWS: AMD64 x86
CIBW_BEFORE_BUILD_WINDOWS: '.\scripts\build\wheel_win32_before_build.bat'
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
delvewheel repair -w {dest_dir}
--no-mangle "libiconv-2.dll;libwinpthread-1.dll" {wheel}
CIBW_TEST_COMMAND: >-
set PYTHONPATH={project} &&
python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')"
# Note: no fast test because we don't run Windows tests
CIBW_ENVIRONMENT_WINDOWS: >-
PSYCOPG2_TESTDB=postgres
PSYCOPG2_TESTDB_USER=postgres
PSYCOPG2_TESTDB_HOST=localhost
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.package_name }}-${{matrix.pyver}}-${{matrix.arch}}
path: ./wheelhouse/*.whl
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
jobs:
linux:
runs-on: ubuntu-latest
if: true

strategy:
fail-fast: false
Expand Down
9 changes: 2 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,8 @@ production it is advised to use the package built from sources.
.. _install: https://www.psycopg.org/docs/install.html#install-from-source
.. _faq: https://www.psycopg.org/docs/faq.html#faq-compile

:Linux/OSX: |gh-actions|
:Windows: |appveyor|
:Build status: |gh-actions|

.. |gh-actions| image:: https://github.com/psycopg/psycopg2/actions/workflows/tests.yml/badge.svg
:target: https://github.com/psycopg/psycopg2/actions/workflows/tests.yml
:alt: Linux and OSX build status

.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/psycopg/psycopg2?branch=master&svg=true
:target: https://ci.appveyor.com/project/psycopg/psycopg2/branch/master
:alt: Windows build status
:alt: Build status
14 changes: 2 additions & 12 deletions doc/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ How to make a psycopg2 release
$ export VERSION=2.8.4

- Push psycopg2 to master or to the maint branch. Make sure tests on `GitHub
Actions`__ and AppVeyor__ pass.
Actions`__.

.. __: https://github.com/psycopg/psycopg2/actions/workflows/tests.yml
.. __: https://ci.appveyor.com/project/psycopg/psycopg2

- Create a signed tag with the content of the relevant NEWS bit and push it.
E.g.::
Expand All @@ -41,19 +40,10 @@ How to make a psycopg2 release

- On GitHub Actions run manually a `package build workflow`__.

- On Appveyor change the `build settings`__ and replace the custom
configuration file name from ``.appveyor/tests.yml`` to
``.appveyor/packages.yml`` (yeah, that sucks a bit. Remember to put it
back to testing).

.. __: https://github.com/psycopg/psycopg2/actions/workflows/packages.yml
.. __: https://ci.appveyor.com/project/psycopg/psycopg2/settings

- When the workflows have finished download the packages from the job
artifacts. For Appveyor you can use the ``download_packages_appveyor.py``
scripts from the ``scripts/build`` directory. They will be saved in a
``wheelhouse/psycopg2-${VERSION}`` directory. For Github just download it
from the web interface (it's a single file).
artifacts.

- Only for stable packages: upload the signed packages on PyPI::

Expand Down
1 change: 1 addition & 0 deletions psycopg/psycopg.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#ifndef PSYCOPG_H
#define PSYCOPG_H 1

#include <pg_config.h>
#if PG_VERSION_NUM < 90100
#error "Psycopg requires PostgreSQL client library (libpq) >= 9.1"
#endif
Expand Down
Loading

0 comments on commit ed4ba11

Please sign in to comment.