Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXWxT-0000hD-U5 for psycopg@arkaria.postgresql.org; Mon, 04 Oct 2021 23:01:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXWxS-0003dd-Te for psycopg@arkaria.postgresql.org; Mon, 04 Oct 2021 23:01:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXWxS-0003dV-OB for psycopg@lists.postgresql.org; Mon, 04 Oct 2021 23:01:18 +0000 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mXWxQ-0004DF-I3 for psycopg@lists.postgresql.org; Mon, 04 Oct 2021 23:01:17 +0000 Received: by mail-vs1-xe2b.google.com with SMTP id y141so5897429vsy.5 for ; Mon, 04 Oct 2021 16:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=65WtKPvdbVWzud/hC/cC1VVUgdCGFyNT7XRGcxhNjtM=; b=lwJKXgJtJPOgUbI6qn6+hasga1eCWOsffYO7LPqYPfJzPRnmGcDhRB3opBu7AURzcj tHkZkh/ImCPcoZy9txq8TK3ZGJET7sbhmO6XHXQw++1nuQDnKu64SA4tdqTuo4jP12qp rbPkdsXl8Twk0ZMBvQyFXnrwc79JCuSDEMUN4oV/91nIEPRlJth8Aj13MO2Ki6hHo44/ icZCpOEJLvX9+XVDWcjSBqRsU64SGm8Kdih0gcf+SP2isaUrlvU4HhHMS/Vfek+3GI/J JC86SWQPpHCsADj3ixISQETu916zyO2+G7Mrujt99w2LZGIzivEgE+x19mAT3G0VCUp7 RAfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=65WtKPvdbVWzud/hC/cC1VVUgdCGFyNT7XRGcxhNjtM=; b=DUyO7Zcb3c4cw8OFBclX7YdQngEtTTkY8eudHVOPo2BhxVG8CJCCoP9s4CItln5EEQ aAHemHmGRbIdbyrdNCFf/FqD3e9vuWfCUbnJodqNfibmJf55vmp5OT2uvNlTRQXMWdnL By0+15g4x/ok5l5mE1LUafDu1LP4VOc45qxmzG+H3sj7xAFPwIbJe/ZnEBbbWgVXDs7Y Rz/+9Jb4mXfAGSHQin3YDbSnaGIZaYPZT4Pweo86ers+NqoqmAlMo5DYPzDMffjBiC9f dA+OL8YziPwoeYhjMyrcqvEAmTCcSB39hZh3A3vFCPnZ5J6cAqZJbG2F6lcxP88Mn23P f+cQ== X-Gm-Message-State: AOAM532P8tND+fXYpKk2YTtYAS+cui+JgEbt93Ytwt9x+ZfkP+KDDzm5 ieuBvTmzP9y/VhNZmz6UWUsf/e4zf0qGCzQQYAZ99+FVar5K6g== X-Google-Smtp-Source: ABdhPJzMG5O+TYYQfmHpiiKK+Ipd5oE3poJ3Bv2cP+5WgRWKIY0Mohs6PZg44HldfgTmCu/7AnlB4FVkmmlewAUhvfw= X-Received: by 2002:a67:ec0f:: with SMTP id d15mr15900829vso.24.1633388475483; Mon, 04 Oct 2021 16:01:15 -0700 (PDT) MIME-Version: 1.0 From: Dan Davis Date: Mon, 4 Oct 2021 19:01:04 -0400 Message-ID: Subject: How to build statically on Windows To: psycopg@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000dc8c1505cd8ee301" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000dc8c1505cd8ee301 Content-Type: text/plain; charset="UTF-8" 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 ) 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 --000000000000dc8c1505cd8ee301 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Can anyone give me a solution to build psycopg2 statically= on Windows?

I have succeeded=C2=A0in building it, but w= hen I run dumpbin /dependents on the generated file (the PYD file), it stil= l depends on libpq.dll even when I pass --static-libpq.

Environment

- OS: Windows 10
- Psy= copg version: psycopg2-2.8.5
- Python version: 3.9
- PostgreSQL versi= on: 14.0 (from ZIP)
- pip version: 21.2.4
- Visual C++ version: 2019<= /div>

Procedure

- Make s= ure pg_config and psql are in the path
- Download as follows - pi= p download psycopg2=3D=3D2.8.5 --no-binary :all:
- Expand the tar= ball
- Build in that directory as follows (following appveyor.py)

=C2=A0 =C2=A0 =C2=A0 python s= etup.py build_ext -l "libpgcommon libpgport"

=
- Try to verify it is indeed static

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


Background
The purpose here is 2 fold:

* Backfil= l support for Python 3.9 and psycopg2 to versions that may have come out be= fore 3.9 was available.
* Make sure our psycopg2 is built against= a more recent version of the PostgreSQL client libraries than 9.x
--000000000000dc8c1505cd8ee301--