public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dan Davis <[email protected]>
To: [email protected]
Subject: How to build statically on Windows
Date: Mon, 4 Oct 2021 19:01:04 -0400
Message-ID: <CAFzonYY=gW5cG9oJNGkF-6vzYvNvg9BB1CCfVkeqYGCKzH=9PQ@mail.gmail.com> (raw)

Can anyone give me a solution to build psycopg2 statically on Windows?

I have succeeded in building it, but when I run dumpbin /dependents on the
generated file (the PYD file), it still depends on libpq.dll even when I
pass --static-libpq.

*Environment*

- OS: Windows 10
- Psycopg version: psycopg2-2.8.5
- Python version: 3.9
- PostgreSQL version: 14.0 (from ZIP)
- pip version: 21.2.4
- Visual C++ version: 2019

*Procedure*

- Make sure pg_config and psql are in the path
- Download as follows - pip download psycopg2==2.8.5 --no-binary :all:
- Expand the tarball
- Build in that directory as follows (following appveyor.py
<https://github.com/psycopg/psycopg2/blob/master/scripts/build/appveyor.py#L291;
)

      python setup.py build_ext -l "libpgcommon libpgport"

- Try to verify it is indeed static

      dumpbin /dependents
build\lib.win-amd64-3.9\psycopg2\_psycopg.cp39-win_amd64.pyd


*Background*
The purpose here is 2 fold:

* Backfill support for Python 3.9 and psycopg2 to versions that may have
come out before 3.9 was available.
* Make sure our psycopg2 is built against a more recent version of the
PostgreSQL client libraries than 9.x


view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: How to build statically on Windows
  In-Reply-To: <CAFzonYY=gW5cG9oJNGkF-6vzYvNvg9BB1CCfVkeqYGCKzH=9PQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox