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 1q1Q3G-0008HL-Nw for psycopg@arkaria.postgresql.org; Tue, 23 May 2023 11:19:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q1Q2G-0001QN-QW for psycopg@arkaria.postgresql.org; Tue, 23 May 2023 11:18:36 +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 1q1Q2G-0001Q1-Im for psycopg@lists.postgresql.org; Tue, 23 May 2023 11:18:36 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q1Q29-001Rb0-OC for psycopg@postgresql.org; Tue, 23 May 2023 11:18:35 +0000 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6af81142b6dso1473242a34.2 for ; Tue, 23 May 2023 04:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684840709; x=1687432709; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0H94EAX65WMoQUQOvHVIIP6VF4AkexK2VpMmUer65BI=; b=BtxVwj7KjQW2Lkh682JUQ439nFvYz9wT7F2a3mx6DIsNZ4Rh7O88pabBqgdvtEjR8Y Gz7VQRLcD+dgjHwkxyCmH348AHJQ+sjc3/D8oIRzYCPIeiDCvh2WXcGDRNkrvV40oyuX r9d4ME/+a3tOPcpMcmsWFM910S6I6tBpSLEaBZr3zxSssGACEfXN65EkxyzPD03wk4yb upEkSjb5p2ZQIGzWs4FpGE55GfDFNoDFCoeCr36q4byhChFrgm67aQnxzqeKzXXS9bpK 7oHE9tSmHHGfPnemXSdM7KCVmkRnGbViXpOKCSpYRHCNWx1fOnFA3b5HYTFoTp9uuihN nBNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684840709; x=1687432709; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0H94EAX65WMoQUQOvHVIIP6VF4AkexK2VpMmUer65BI=; b=SmfDgMWH3tdu2lPv+SYy4q7kXnUqL+33tc2FHYaiBmWSlZRn4k9SbRNqapH0XHqeAJ aKcUuU5ZCF1qsMc/Ea0GSeDiuiRAsty4Hoak2SdGnzOi5x8MMxIAAenYoVCBkdyOZUd0 1s8qDOtJbdU1xm4rxd7LA7fR+BESpkIRbJf0UfC83pnukJWdnnWe8887igoh/U5+zYih QkCS+VZgP9efs9OU2EqcsZWlLv/GahmE2hiimjop80aoCfHjjTHWZzcbY9h+ivgDbvTg /S4JLp0pudOwsSzN67Y+80m8kXAIzjw5Eb+Fvhh7MFHtZM9vHBgm0s9IjDQlU8Qn0Uzt TNfw== X-Gm-Message-State: AC+VfDzdjTsmMwwZaUpZtyVvcU6QLZQ7D5kvh4ycjnR2/FRC6uk/YiWl R0xXQoUyug/K5lERZck1XeFGWFd3Ym+OgzVzUkE= X-Google-Smtp-Source: ACHHUZ4JPfAwfdZkXDypZ5UTvvSeM0Y2/wEe2crW+wxEFCBHvteDvtOtX8WckmNOrHktSbG0QU0POCFYmadAdpegdUY= X-Received: by 2002:a05:6870:5b2d:b0:19a:12aa:e3ae with SMTP id ds45-20020a0568705b2d00b0019a12aae3aemr6780135oab.9.1684840709094; Tue, 23 May 2023 04:18:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniele Varrazzo Date: Tue, 23 May 2023 13:18:17 +0200 Message-ID: Subject: Re: Does psycopg2-binary provide the psycopg2 package? To: Kerrick Staley Cc: psycopg@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 23 May 2023 at 08:52, Kerrick Staley wrote: > > If I install psycopg2-binary, and then I try to install a package that depends on psycopg2, will pip "know" that psycopg2-binary satisfies the psycopg2 requirement and avoid installing psycopg2? > > Empirically the answer seems to be "no". I installed psycopg2-binary, then ran `python3 -m pip install -e .` in a directory with this setup.py file, and it tried to install psycopg2. > > Is there a way that, in my setup.py file, I can depend on either psycopg2 or psycopg2-binary, whichever is available? I don't think there is. You cannot make a package depending on either one or the other. Python packaging metadata doesn't offer this flexibility. In psycopg 3 the only package to depend on is `psycopg`. The pre-compiled C module (the `psycopg-binary` package on pypi) can be added as an add-on and it is not necessary for a library to depend on it. It can be an application requirement instead. In my projects I use `psycopg` as an abstract dependency (in the `setup.cfg` of the packages that need psycopg) and `psycopg-binary==3.x.x` as a concrete dependency (in a `requirements.txt` file generated by `pip-tools` using `psycopg-binary in the `requirements.in`) More details about psycopg 3 versions management are available at https://www.psycopg.org/psycopg3/docs/basic/install.html#handling-dependencies -- Daniele