public inbox for [email protected]  
help / color / mirror / Atom feed
From: Daniele Varrazzo <[email protected]>
To: Kerrick Staley <[email protected]>
Cc: [email protected]
Subject: Re: Does psycopg2-binary provide the psycopg2 package?
Date: Tue, 23 May 2023 13:18:17 +0200
Message-ID: <CA+mi_8Yxu1845mO5BBTVX3jsYEJqZ8QHWPrSPFDerKoQU2pu1g@mail.gmail.com> (raw)
In-Reply-To: <CACfSeTE=r0BkTB8S_1BDw8=5tharqoZAaeRLUNkYPsSu8jbw+A@mail.gmail.com>
References: <CACfSeTE=r0BkTB8S_1BDw8=5tharqoZAaeRLUNkYPsSu8jbw+A@mail.gmail.com>

On Tue, 23 May 2023 at 08:52, Kerrick Staley <[email protected]> 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






view thread (2+ messages)

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: Does psycopg2-binary provide the psycopg2 package?
  In-Reply-To: <CA+mi_8Yxu1845mO5BBTVX3jsYEJqZ8QHWPrSPFDerKoQU2pu1g@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