From 2b85e812f8cee84b68807aea548fd26030a7bbd8 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 23 May 2024 13:09:05 -0700 Subject: [PATCH] Chore(deps): Use psycopg as recommended (#6811) --- Dockerfile | 10 +++++++-- Pipfile | 2 +- Pipfile.lock | 43 ++++++++++++++++++++------------------- src/paperless/settings.py | 2 +- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index d13f1b9ac..d8ff8c8b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,7 +83,6 @@ ARG RUNTIME_PACKAGES="\ icc-profiles-free \ imagemagick \ # PostgreSQL - libpq5 \ postgresql-client \ # MySQL / MariaDB mariadb-client \ @@ -223,7 +222,13 @@ RUN --mount=type=cache,target=/root/.cache/pip/,id=pip-cache \ && apt-get install --yes --quiet --no-install-recommends ${BUILD_PACKAGES} \ && python3 -m pip install --no-cache-dir --upgrade wheel \ && echo "Installing Python requirements" \ - && python3 -m pip install --default-timeout=1000 --requirement requirements.txt \ + && curl --fail --silent --show-error --location \ + --output psycopg_c-3.1.19-cp311-cp311-linux_x86_64.whl \ + https://github.com/paperless-ngx/builder/releases/download/psycopg-3.1.19/psycopg_c-3.1.19-cp311-cp311-linux_x86_64.whl \ + && curl --fail --silent --show-error --location \ + --output psycopg_c-3.1.19-cp311-cp311-linux_aarch64.whl \ + https://github.com/paperless-ngx/builder/releases/download/psycopg-3.1.19/psycopg_c-3.1.19-cp311-cp311-linux_aarch64.whl \ + && python3 -m pip install --default-timeout=1000 --find-links . --requirement requirements.txt \ && echo "Patching whitenoise for compression speedup" \ && curl --fail --silent --show-error --location --output 484.patch https://github.com/evansd/whitenoise/pull/484.patch \ && patch -d /usr/local/lib/python3.11/site-packages --verbose -p2 < 484.patch \ @@ -236,6 +241,7 @@ RUN --mount=type=cache,target=/root/.cache/pip/,id=pip-cache \ && apt-get --yes purge ${BUILD_PACKAGES} \ && apt-get --yes autoremove --purge \ && apt-get clean --yes \ + && rm --recursive --force --verbose *.whl \ && rm --recursive --force --verbose /var/lib/apt/lists/* \ && rm --recursive --force --verbose /tmp/* \ && rm --recursive --force --verbose /var/tmp/* \ diff --git a/Pipfile b/Pipfile index aee4c5ba4..7a01efca1 100644 --- a/Pipfile +++ b/Pipfile @@ -37,7 +37,7 @@ nltk = "*" ocrmypdf = "~=15.4" pathvalidate = "*" pdf2image = "*" -psycopg2 = "*" +psycopg = {version = "*", extras = ["c"]} python-dateutil = "*" python-dotenv = "*" python-gnupg = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 0ab8c2316..8bc530b33 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "4bb46e902c6ceb6e3647772809b7941e318f1408472c4eaf0a1d2f0360ddac3a" + "sha256": "01fe0c491cf8d9429174033c720df637a4a1a4c168e79ea2c7c2d482d5f94f07" }, "pipfile-spec": 6, "requires": {}, @@ -900,6 +900,7 @@ "sha256:19b4e485cd07b7d83e3fe3b72132e7df70bfac22b14fe4bf7a23822c3a35bff5", "sha256:1a2569a1f15ae6c8c64108a2cd2b4a858fc1e13d25846be0666fc144715e32ab", "sha256:1a7aca7964ac4bb07680d5c9d63b9d7028cace3e2d43175cb50bba8c5ad33316", + "sha256:1b590b39ef90c6b22ec0be925b211298e810b4856909c8ca60d27ffbca6c12e6", "sha256:1d8a701774dfc42a2f0b8ccdfe7dbc140500d1049e0632a611985d943fcf12df", "sha256:1e275ea572389e41e8b039ac076a46cb87ee6b8542df3fff26f5baab43713bca", "sha256:2304d3c93f2258ccf2cf7a6ba8c761d76ef84948d87bf9664e14d203da2cd264", @@ -955,6 +956,7 @@ "sha256:79d1fb9252e7e2cfe4de6e9a6610c7cbb99b9708e2c3e29057f487de5a9eaefa", "sha256:7ce7ad8abebe737ad6143d9d3bf94b88b93365ea30a5b81f6877ec9c0dee0a48", "sha256:7ed07b3062b055d7a7f9d6557a251cc655eed0b3152b76de619516621c56f5d3", + "sha256:7ff762670cada8e05b32bf1e4dc50b140790909caa8303cfddc4d702b71ea184", "sha256:8268cbcd48c5375f46e000adb1390572c98879eb4f77910c6053d25cc3ac2c67", "sha256:875a3f90d7eb5c5d77e529080d95140eacb3c6d13ad5b616ee8095447b1d22e7", "sha256:89feb82ca055af0fe797a2323ec9043b26bc371365847dbe83c7fd2e2f181c34", @@ -972,6 +974,7 @@ "sha256:a233bb68625a85126ac9f1fc66d24337d6e8a0f9207b688eec2e7c880f012ec0", "sha256:a2f6a1bc2460e643785a2cde17293bd7a8f990884b822f7bca47bee0a82fc66b", "sha256:a6d17e0370d2516d5bb9062c7b4cb731cff921fc875644c3d751ad857ba9c5b1", + "sha256:a6d2092797b388342c1bc932077ad232f914351932353e2e8706851c870bca1f", "sha256:ab67ed772c584b7ef2379797bf14b82df9aa5f7438c5b9a09624dd834c1c1aaf", "sha256:ac6540c9fff6e3813d29d0403ee7a81897f1d8ecc09a8ff84d2eea70ede1cdbf", "sha256:ae4073a60ab98529ab8a72ebf429f2a8cc612619a8c04e08bed27450d52103c0", @@ -990,6 +993,7 @@ "sha256:bcc98f911f10278d1daf14b87d65325851a1d29153caaf146877ec37031d5f36", "sha256:be49ad33819d7dcc28a309b86d4ed98e1a65f3075c6acd3cd4fe32103235222b", "sha256:bec4bd9133420c5c52d562469c754f27c5c9e36ee06abc169612c959bd7dbb07", + "sha256:c2faf60c583af0d135e853c86ac2735ce178f0e338a3c7f9ae8f622fd2eb788c", "sha256:c689d0d5381f56de7bd6966a4541bff6e08bf8d3871bbd89a0c6ab18aa699573", "sha256:c7079d5eb1c1315a858bbf180000757db8ad904a89476653232db835c3114001", "sha256:cb3942960f0beb9f46e2a71a3aca220d1ca32feb5a398656be934320804c0df9", @@ -1374,25 +1378,22 @@ "markers": "python_full_version >= '3.7.0'", "version": "==3.0.43" }, - "psycopg2": { - "hashes": [ - "sha256:121081ea2e76729acfb0673ff33755e8703d45e926e416cb59bae3a86c6a4981", - "sha256:38a8dcc6856f569068b47de286b472b7c473ac7977243593a288ebce0dc89516", - "sha256:426f9f29bde126913a20a96ff8ce7d73fd8a216cfb323b1f04da402d452853c3", - "sha256:5e0d98cade4f0e0304d7d6f25bbfbc5bd186e07b38eac65379309c4ca3193efa", - "sha256:7e2dacf8b009a1c1e843b5213a87f7c544b2b042476ed7755be813eaf4e8347a", - "sha256:a7653d00b732afb6fc597e29c50ad28087dcb4fbfb28e86092277a559ae4e693", - "sha256:ade01303ccf7ae12c356a5e10911c9e1c51136003a9a1d92f7aa9d010fb98372", - "sha256:bac58c024c9922c23550af2a581998624d6e02350f4ae9c5f0bc642c633a2d5e", - "sha256:c92811b2d4c9b6ea0285942b2e7cac98a59e166d59c588fe5cfe1eda58e72d59", - "sha256:d1454bde93fb1e224166811694d600e746430c006fbb031ea06ecc2ea41bf156", - "sha256:d735786acc7dd25815e89cc4ad529a43af779db2e25aa7c626de864127e5a024", - "sha256:de80739447af31525feddeb8effd640782cf5998e1a4e9192ebdf829717e3913", - "sha256:ff432630e510709564c01dafdbe996cb552e0b9f3f065eb89bdce5bd31fabf4c" + "psycopg": { + "extras": [ + "c" + ], + "hashes": [ + "sha256:92d7b78ad82426cdcf1a0440678209faa890c6e1721361c2f8901f0dccd62961", + "sha256:dca5e5521c859f6606686432ae1c94e8766d29cc91f2ee595378c510cc5b0731" ], - "index": "pypi", "markers": "python_version >= '3.7'", - "version": "==2.9.9" + "version": "==3.1.19" + }, + "psycopg-c": { + "hashes": [ + "sha256:8e90f53c430e7d661cb3a9298e2761847212ead1b24c5fb058fc9d0fd9616017" + ], + "version": "==3.1.19" }, "pycparser": { "hashes": [ @@ -4267,12 +4268,12 @@ }, "types-setuptools": { "hashes": [ - "sha256:3a8ccea3e3f1f639856a1dd622be282f74e94e00fdc364630240f999cc9594fc", - "sha256:bd3964c08cffd5a057d9cabe61641c86a41a1b5dd2b652b8d371eed64d89d726" + "sha256:275fb72048b0203d3fbef268298ea78a0913cd114a74872d93f8638ccc5b7c63", + "sha256:52b264eff8913b5d85848d83bd98efea935fc6129d681d370eb957783880b720" ], "index": "pypi", "markers": "python_version >= '3.8'", - "version": "==69.5.0.20240513" + "version": "==69.5.0.20240519" }, "types-tqdm": { "hashes": [ diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 5c7aa6c19..831e4e953 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -613,7 +613,7 @@ def _parse_db_settings() -> dict: } else: # Default to PostgresDB - engine = "django.db.backends.postgresql_psycopg2" + engine = "django.db.backends.postgresql" options = { "sslmode": os.getenv("PAPERLESS_DBSSLMODE", "prefer"), "sslrootcert": os.getenv("PAPERLESS_DBSSLROOTCERT", None),