Skip to content

Commit

Permalink
Switch to psycopg2 from wheel-only psycopg2-binary
Browse files Browse the repository at this point in the history
This closes biocommons#623

Per the authors of the `psycopg2` package, `psycopg2-binary` "is meant
for beginners to start playing with Python and PostgreSQL without the
need to meet the build requirements."

However, it's preferable to depend on `psycopg2` for production software.

Issues in flight which should make this change irrelevant
---------------------------------------------------------

- [make data provider dependencies optional][hgvs-optional-deps]
- [replace psycopg2 with asyncpg][hgvs-asyncpg]
- [use a REST interface, eliminating libpq dependency][hgvs-rest]

------------------------------------------------------------------------

Why move away from `psycopg2-binary`?
=====================================
The psycopg2 project makes two recommendations in the
[psycopg2 vs psycopg2-binary][psycopg2-vs-psycopg2-binary] docs:

> If you are the maintainer of a published package depending on `psycopg2` you
> shouldn’t use `psycopg2-binary` as a module dependency.

Secondarily:

> **For production use you are advised to use the source distribution.**

This means that any production software depending on `hgvs` will have to
install `psycopg2-binary`.

History of the two packages
===========================
Starting with Psycopg2 2.8, there are now two packages (explained in the
[2.7.4 release notes][psycopg2-274]):

- `psycopg2`: source distribution, advised for production.
- `psycopg2-binary`: "quickest way to install" (a "pre-compiled binary version")

There is substantial discussion in [an issue on the `psycopg2` project][gh-thread],
which I won't re-summarize here, but one takeaway is that many Python packages
now depend on `psycopg2-binary`, and others on `psycopg2`.

Ideally, all libraries just depend on `psycopg2`.

Alternate solutions to the split exist (like [`Provides-Dist` from PEP 345][provides-dist]).
However, the [`Provides-Dist` field is "rarely used"][provides-dist-rarely-used]
and thus ignored most of the time.

[`hgvs` switched to `psycopg2-binary`][hgvs-switch-to-binary] shortly after the 2.7.4 release.

[gh-thread]: psycopg/psycopg2#674
[hgvs-asyncpg]: biocommons#603
[hgvs-optional-deps]: biocommons#199
[hgvs-rest]: biocommons#199 (comment)
[hgvs-switch-to-binary]: biocommons@4c75a4e5
[provides-dist-rarely-used]: https://packaging.python.org/specifications/core-metadata/#provides-dist-multiple-use
[provides-dist]: https://www.python.org/dev/peps/pep-0345/#provides-dist-multiple-use
[psycopg2-274]: https://www.psycopg.org/articles/2018/02/08/psycopg-274-released/
[psycopg2-vs-psycopg2-binary]: https://www.psycopg.org/docs/install.html#psycopg-vs-psycopg-binary
  • Loading branch information
DavidCain committed Sep 24, 2021
1 parent 4c7b45f commit 316423a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"configparser>=3.3.0",
"ipython",
"parsley",
"psycopg2-binary",
"psycopg2",
"six",
],
setup_requires=[
Expand Down

0 comments on commit 316423a

Please sign in to comment.