Skip to content

ci: use vcpkg to install libpq on windows#966

Merged
dvarrazzo merged 3 commits intopsycopg:masterfrom
trim21:try-vcpkg
Dec 21, 2024
Merged

ci: use vcpkg to install libpq on windows#966
dvarrazzo merged 3 commits intopsycopg:masterfrom
trim21:try-vcpkg

Conversation

@trim21
Copy link
Contributor

@trim21 trim21 commented Dec 15, 2024

@trim21 trim21 marked this pull request as ready for review December 16, 2024 00:18
@trim21 trim21 changed the title ci: try to use vcpkg to install libpq on windows ci: use vcpkg to install libpq on windows Dec 16, 2024
@dvarrazzo
Copy link
Member

Trying to have a chat with vkpkg to figure out if they can add libpq 17...

@dvarrazzo
Copy link
Member

microsoft/vcpkg#41747 would allow to use libpq 17

@dvarrazzo
Copy link
Member

This shows something strange:

libpq used: 140012
libpq compiled: 160004

it seems that we do find the vcpkg at build time, but when testing we found an outdated version. I have push a change to upgrade the dependency check.

Maybe we should just delete the offending stale libpq.dll from the runner. I would iterate on every entry in PATH and delete $dir/libpq.dll and $dir/pg_config.exe if found, before installing the vcpkg version.

Copy link
Member

@dvarrazzo dvarrazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this initiative: it seems a welcome change.

@trim21
Copy link
Contributor Author

trim21 commented Dec 16, 2024

This shows something strange:

libpq used: 140012
libpq compiled: 160004

it seems that we do find the vcpkg at build time, but when testing we found an outdated version. I have push a change to upgrade the dependency check.

Maybe we should just delete the offending stale libpq.dll from the runner. I would iterate on every entry in PATH and delete $dir/libpq.dll and $dir/pg_config.exe if found, before installing the vcpkg version.

I think it may be possible to use a static libpq here? would that be a option?

@dvarrazzo
Copy link
Member

I think it may be possible to use a static libpq here? would that be a option?

If it works it would not be a problem to distribute a static build.

@trim21

This comment was marked as outdated.

@trim21
Copy link
Contributor Author

trim21 commented Dec 17, 2024

This shows something strange:

libpq used: 140012
libpq compiled: 160004

it seems that we do find the vcpkg at build time, but when testing we found an outdated version. I have push a change to upgrade the dependency check.

Maybe we should just delete the offending stale libpq.dll from the runner. I would iterate on every entry in PATH and delete $dir/libpq.dll and $dir/pg_config.exe if found, before installing the vcpkg version.

Just find out that we do not need to clear libpq.dll from path (even there is also a very old version 11 in path from php, but I just rm whole php from runner).

The reason it use wrong dll is, there is a extra repair wheel step with extra PATH I forget to remove, so it bundle wrong dll into wheels.

pip install delvewheel wheel
# The windows runner is a total mess, with random copies of the libpq
# scattered all over the places. Give precedence to the one under our
# control (or the illusion of it).
export PATH="/c/Program Files/PostgreSQL/14/bin/:$PATH"

Remove this step will make it work as expected.

libpq wrapper implementation: c
libpq used: 160004
libpq compiled: 160004

@trim21
Copy link
Contributor Author

trim21 commented Dec 17, 2024

done

There are some extra workflow file changes for debugging, I'll revert them once this PR is ready to be merged.

@trim21 trim21 requested a review from dvarrazzo December 19, 2024 22:35
@dvarrazzo
Copy link
Member

Thank you very much for this works: looks good!

I have rebased the branch and squashed your commits and re-enabled all the CI jobs. Running a final test on the workflows our side, and then this is good to go.

@trim21
Copy link
Contributor Author

trim21 commented Dec 21, 2024

@dvarrazzo
Copy link
Member

You are right, my bad: my local master was ahead one step WRT upstream, because it's sitting on an unrelated MR. Rebasing again...

@trim21
Copy link
Contributor Author

trim21 commented Dec 21, 2024

qemu is so slow…

@dvarrazzo
Copy link
Member

qemu is so slow…

Why, what are you trying to do? 😄

@trim21
Copy link
Contributor Author

trim21 commented Dec 21, 2024

qemu is so slow…

Why, what are you trying to do? 😄

nothing, just hoping GitHub get free arm linux runner someday

@dvarrazzo dvarrazzo merged commit b678cb8 into psycopg:master Dec 21, 2024
@dvarrazzo
Copy link
Member

Merged! Thank you very much for this work!

I actually need to do the same for psycopg2: the build system for Windows runs on appveyor and the platform is not very quick to release new runners. As a consequence we haven't provided yet Python 3.13 wheels for Windows (psycopg/psycopg2#1736) :\

I think it will easy to backport this build procedure to psycopg 2 too. Would you be willing to provide a MR for it? If not it's no problem: thanks to your help it shouldn't be difficult for me to do it.

Thank you again!

@trim21
Copy link
Contributor Author

trim21 commented Dec 21, 2024

not really, sorry, I do not use psycopg2

@trim21
Copy link
Contributor Author

trim21 commented Feb 22, 2025

Sorry to reply to a already merged issue, I recently just find that conda ecosystem (conda-force) provide libpq(with a working pg_config.exe, so we can also get ride of pg_config_vcpkg_stub) and openssl for windows platform. And doesn't like vcpkg, you can lock version of libpq and openssl.

So maybe it's possible to resolve this comment if we install libpq conda but not vcpkg.

# Note: On windows the latest version can be found at
# https://vcpkg.io/en/package/libpq
# However the command line tool doesn't have a flag to specify to install
# a specific version, so whatever you get you keep it.
# https://github.com/microsoft/vcpkg/discussions/25622

(also using conda doesn't mean you have to use a python from conda, it's possible to use c-library from conda without using a python from it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants