Skip to content

Commit ed4ba11

Browse files
authored
Merge pull request #1772 from psycopg/ci-vcpkg
Package psycopg2-binary for windows using vcpkg libpq
2 parents 947f731 + b8d49e6 commit ed4ba11

File tree

15 files changed

+201
-1189
lines changed

15 files changed

+201
-1189
lines changed

.appveyor/cache_rebuild

Lines changed: 0 additions & 19 deletions
This file was deleted.

.appveyor/packages.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.appveyor/tests.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/packages.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,75 @@ jobs:
182182
with:
183183
name: macos-${{matrix.pyver}}-macos-${{matrix.macver}}_${{matrix.arch}}
184184
path: ./wheelhouse/*.whl
185+
186+
187+
build-windows:
188+
runs-on: windows-latest
189+
if: true
190+
191+
strategy:
192+
fail-fast: false
193+
matrix:
194+
arch: [win_amd64]
195+
pyver: [cp38, cp39, cp310, cp311, cp312, cp313]
196+
package_name: [psycopg2, psycopg2-binary]
197+
198+
defaults:
199+
run:
200+
shell: bash
201+
202+
steps:
203+
# there are some other libpq in PATH
204+
- name: Drop spurious libpq in the path
205+
run: rm -rf c:/tools/php C:/Strawberry/c/bin
206+
207+
- name: Checkout repo
208+
uses: actions/checkout@v4
209+
210+
- name: Start PostgreSQL service for test
211+
run: |
212+
$PgSvc = Get-Service "postgresql*"
213+
Set-Service $PgSvc.Name -StartupType manual
214+
$PgSvc.Start()
215+
shell: powershell
216+
217+
- name: Export GitHub Actions cache environment variables
218+
uses: actions/github-script@v7
219+
with:
220+
script: |
221+
const path = require('path')
222+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
223+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
224+
core.addPath(path.join(process.env.VCPKG_INSTALLATION_ROOT, 'installed/x64-windows-release/lib'));
225+
core.addPath(path.join(process.env.VCPKG_INSTALLATION_ROOT, 'installed/x64-windows-release/bin'));
226+
227+
- name: Create the binary package source tree
228+
run: >-
229+
sed -i 's/^setup(name="psycopg2"/setup(name="${{matrix.package_name}}"/'
230+
setup.py
231+
if: ${{ matrix.package_name != 'psycopg2' }}
232+
233+
- name: Build wheels
234+
uses: pypa/[email protected]
235+
env:
236+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" # cache vcpkg
237+
CIBW_BUILD: ${{matrix.pyver}}-${{matrix.arch}}
238+
CIBW_ARCHS_WINDOWS: AMD64 x86
239+
CIBW_BEFORE_BUILD_WINDOWS: '.\scripts\build\wheel_win32_before_build.bat'
240+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
241+
delvewheel repair -w {dest_dir}
242+
--no-mangle "libiconv-2.dll;libwinpthread-1.dll" {wheel}
243+
CIBW_TEST_COMMAND: >-
244+
set PYTHONPATH={project} &&
245+
python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')"
246+
# Note: no fast test because we don't run Windows tests
247+
CIBW_ENVIRONMENT_WINDOWS: >-
248+
PSYCOPG2_TESTDB=postgres
249+
PSYCOPG2_TESTDB_USER=postgres
250+
PSYCOPG2_TESTDB_HOST=localhost
251+
252+
- name: Upload artifacts
253+
uses: actions/upload-artifact@v4
254+
with:
255+
name: windows-${{ matrix.package_name }}-${{matrix.pyver}}-${{matrix.arch}}
256+
path: ./wheelhouse/*.whl

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
jobs:
1111
linux:
1212
runs-on: ubuntu-latest
13+
if: true
1314

1415
strategy:
1516
fail-fast: false

README.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,8 @@ production it is advised to use the package built from sources.
7373
.. _install: https://www.psycopg.org/docs/install.html#install-from-source
7474
.. _faq: https://www.psycopg.org/docs/faq.html#faq-compile
7575

76-
:Linux/OSX: |gh-actions|
77-
:Windows: |appveyor|
76+
:Build status: |gh-actions|
7877

7978
.. |gh-actions| image:: https://github.com/psycopg/psycopg2/actions/workflows/tests.yml/badge.svg
8079
:target: https://github.com/psycopg/psycopg2/actions/workflows/tests.yml
81-
:alt: Linux and OSX build status
82-
83-
.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/psycopg/psycopg2?branch=master&svg=true
84-
:target: https://ci.appveyor.com/project/psycopg/psycopg2/branch/master
85-
:alt: Windows build status
80+
:alt: Build status

doc/release.rst

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ How to make a psycopg2 release
1616
$ export VERSION=2.8.4
1717

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

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

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

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

44-
- On Appveyor change the `build settings`__ and replace the custom
45-
configuration file name from ``.appveyor/tests.yml`` to
46-
``.appveyor/packages.yml`` (yeah, that sucks a bit. Remember to put it
47-
back to testing).
48-
4943
.. __: https://github.com/psycopg/psycopg2/actions/workflows/packages.yml
50-
.. __: https://ci.appveyor.com/project/psycopg/psycopg2/settings
5144

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

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

psycopg/psycopg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#ifndef PSYCOPG_H
2828
#define PSYCOPG_H 1
2929

30+
#include <pg_config.h>
3031
#if PG_VERSION_NUM < 90100
3132
#error "Psycopg requires PostgreSQL client library (libpq) >= 9.1"
3233
#endif

0 commit comments

Comments
 (0)