blob: 50934d83d2c6af78c0a57ecb2d87f43c2a01903d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
Psycopg 3 -- PostgreSQL database adapter for Python
===================================================
Psycopg 3 is a modern implementation of a PostgreSQL adapter for Python.
Installation
------------
Quick version::
pip install --upgrade pip # upgrade pip to at least 20.3
pip install "psycopg[binary,pool]" # install binary dependencies
For further information about installation please check `the documentation`__.
.. __: https://www.psycopg.org/psycopg3/docs/basic/install.html
Hacking
-------
In order to work on the Psycopg source code you need to have the ``libpq``
PostgreSQL client library installed in the system. For instance, on Debian
systems, you can obtain it by running::
sudo apt install libpq5
After which you can clone this repository::
git clone https://github.com/psycopg/psycopg.git
cd psycopg
Please note that the repository contains the source code of several Python
packages: that's why you don't see a ``setup.py`` here. The packages may have
different requirements:
- The ``psycopg`` directory contains the pure python implementation of
``psycopg``. The package has only a runtime dependency on the ``libpq``, the
PostgreSQL client library, which should be installed in your system.
- The ``psycopg_c`` directory contains an optimization module written in
C/Cython. In order to build it you will need a few development tools: please
look at `Local installation`__ in the docs for the details.
.. __: https://www.psycopg.org/psycopg3/docs/basic/install.html#local-installation
- The ``psycopg_pool`` directory contains the `connection pools`__
implementations. This is kept as a separate package to allow a different
release cycle.
.. __: https://www.psycopg.org/psycopg3/docs/advanced/pool.html
You can create a local virtualenv and install there the packages `in
development mode`__, together with their development and testing
requirements::
python -m venv .venv
source .venv/bin/activate
pip install -e "./psycopg[dev,test]" # for the base Python package
pip install -e ./psycopg_pool # for the connection pool
pip install ./psycopg_c # for the C speedup module
.. __: https://pip.pypa.io/en/stable/reference/pip_install/#install-editable
Please add ``--config-settings editable_mode=strict`` to the ``pip install
-e`` above if you experience `editable mode broken`__.
.. __: https://github.com/pypa/setuptools/issues/3557
Now hack away! You can run the tests using::
psql -c 'create database psycopg_test'
export PSYCOPG_TEST_DSN="dbname=psycopg_test"
pytest
|