From 6e9201222802b178e9ec1eaaf7426dea41808171 Mon Sep 17 00:00:00 2001 From: Anindya Roy Date: Tue, 7 May 2024 16:51:15 +0530 Subject: [PATCH 1/4] Upgraded python 3.9.5 to 3.12.3 --- .github/workflows/dead_code.yml | 2 +- .github/workflows/functional_tests.yml | 8 ++++---- .github/workflows/functional_tests_2023.yml | 8 ++++---- .github/workflows/integration_tests.yml | 4 ++-- .github/workflows/lint.yml | 2 +- .github/workflows/main.yml | 6 ++---- .github/workflows/spell.yml | 2 +- .github/workflows/style.yml | 2 +- .github/workflows/translations.yml | 2 +- .github/workflows/types.yml | 2 +- .github/workflows/unit_tests.yml | 6 +++--- docs/deployment.md | 2 +- docs/gnu_linux.md | 2 +- docs/support.md | 2 +- nxdrive/utils.py | 2 +- tools/posix/deploy_ci_agent.sh | 2 +- tools/windows/deploy_ci_agent.ps1 | 2 +- 17 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.github/workflows/dead_code.yml b/.github/workflows/dead_code.yml index 99b1a2d83e..902d798094 100644 --- a/.github/workflows/dead_code.yml +++ b/.github/workflows/dead_code.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/functional_tests.yml b/.github/workflows/functional_tests.yml index f07fc88c2f..133884775f 100644 --- a/.github/workflows/functional_tests.yml +++ b/.github/workflows/functional_tests.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip @@ -62,7 +62,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/Library/Caches/pip @@ -91,7 +91,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~\AppData\Local\pip\Cache @@ -126,7 +126,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/functional_tests_2023.yml b/.github/workflows/functional_tests_2023.yml index 98536b533b..268b58088d 100644 --- a/.github/workflows/functional_tests_2023.yml +++ b/.github/workflows/functional_tests_2023.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip @@ -62,7 +62,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/Library/Caches/pip @@ -91,7 +91,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~\AppData\Local\pip\Cache @@ -120,7 +120,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 5e74ad8220..3fbb1c8dac 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -15,7 +15,7 @@ on: env: FREEZE_ONLY: 1 - + jobs: integration-tests-windows: @@ -37,7 +37,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON architecture: "x86" - uses: actions/cache@v4 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e9b24ed9d2..c73c92d1e1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 443b8c6c4b..1e55c02c5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,9 +4,7 @@ on: workflow_dispatch: jobs: test: - runs-on: ubuntu - steps: + runs-on: ubuntu-latest + steps: - name: Use GitHub secret run: echo ${{ secrets.MY_SECRET }} - - diff --git a/.github/workflows/spell.yml b/.github/workflows/spell.yml index 066e64d7c3..ffa35ec635 100644 --- a/.github/workflows/spell.yml +++ b/.github/workflows/spell.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 3c061e2821..484163de50 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml index b951fcf388..3a7d5ab56e 100644 --- a/.github/workflows/translations.yml +++ b/.github/workflows/translations.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/types.yml b/.github/workflows/types.yml index dbbc9d7f81..d4ae082fe7 100644 --- a/.github/workflows/types.yml +++ b/.github/workflows/types.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index e10906b54e..d23a9056b6 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/.cache/pip @@ -55,7 +55,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON - uses: actions/cache@v4 with: path: ~/Library/Caches/pip @@ -85,7 +85,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 # XXX_PYTHON + python-version: 3.12 # XXX_PYTHON architecture: "x86" - uses: actions/cache@v4 with: diff --git a/docs/deployment.md b/docs/deployment.md index d9313ce795..c52c30748e 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -52,7 +52,7 @@ Executing the script without argument will setup.update the isolated environment [//]: # (XXX_PYTHON, XXX_INNO_SETUP) -- [Python 3.9.5](https://www.python.org/ftp/python/3.9.5/python-3.9.5.exe). +- [Python 3.12.3](https://www.python.org/ftp/python/3.12.3/python-3.12.3.exe). - [Inno Setup 6.1.2](http://www.jrsoftware.org/isdl.php) to create the installer. ### Troubleshooting diff --git a/docs/gnu_linux.md b/docs/gnu_linux.md index dd6a0cd8f3..ce5c8005ae 100644 --- a/docs/gnu_linux.md +++ b/docs/gnu_linux.md @@ -28,7 +28,7 @@ sudo mount -o remount,user_xattr /dev/sda3 [//]: # (XXX_PYTHON) -Nuxeo Drive is officially supported on **Python 3.9.1+**. +Nuxeo Drive is officially supported on **Python 3.12.3+**. ## Installation diff --git a/docs/support.md b/docs/support.md index 1fdd8abe18..b6224d1b79 100644 --- a/docs/support.md +++ b/docs/support.md @@ -45,7 +45,7 @@ It may evolve quickly without notification as we are following the Python develo [//]: # (XXX_PYTHON) -As of now, we are using the __Python 3.9.5__. +As of now, we are using the __Python 3.12.3__. History: diff --git a/nxdrive/utils.py b/nxdrive/utils.py index 1b7c5cec92..765f59f214 100644 --- a/nxdrive/utils.py +++ b/nxdrive/utils.py @@ -639,7 +639,7 @@ def get_certificate_details( Note: This function uses a undocumented method of the _ssl module. It is continuously tested in our CI to ensure it still available after any Python upgrade. - Certified working as of Python 3.9.5. + Certified working as of Python 3.12.3. """ import ssl diff --git a/tools/posix/deploy_ci_agent.sh b/tools/posix/deploy_ci_agent.sh index 5f40df2f48..70592e39c6 100755 --- a/tools/posix/deploy_ci_agent.sh +++ b/tools/posix/deploy_ci_agent.sh @@ -98,7 +98,7 @@ check_upgrade() { check_vars() { # Check required variables if [ "${PYTHON_DRIVE_VERSION:-unset}" = "unset" ]; then - export PYTHON_DRIVE_VERSION="3.9.5" # XXX_PYTHON + export PYTHON_DRIVE_VERSION="3.12.3" # XXX_PYTHON fi if [ "${WORKSPACE:-unset}" = "unset" ]; then if [ "${GITHUB_WORKSPACE:-unset}" != "unset" ]; then diff --git a/tools/windows/deploy_ci_agent.ps1 b/tools/windows/deploy_ci_agent.ps1 index 8d17547ec0..34205ee0b2 100644 --- a/tools/windows/deploy_ci_agent.ps1 +++ b/tools/windows/deploy_ci_agent.ps1 @@ -211,7 +211,7 @@ function check_upgrade { function check_vars { # Check required variables if (-Not ($Env:PYTHON_DRIVE_VERSION)) { - $Env:PYTHON_DRIVE_VERSION = '3.9.5' # XXX_PYTHON + $Env:PYTHON_DRIVE_VERSION = '3.12.3' # XXX_PYTHON } if (-Not ($Env:WORKSPACE)) { if ($Env:GITHUB_WORKSPACE) { From 13e48c8e7ff4b7f5ddc091d47223d4b19cdef79d Mon Sep 17 00:00:00 2001 From: Pooja Ramkrishna Daine Date: Tue, 3 Sep 2024 16:40:31 +0530 Subject: [PATCH 2/4] NXDRIVE-2929: Upgrade Python from 3.9.5 to 3.12.3 --- tools/deps/requirements.txt | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tools/deps/requirements.txt b/tools/deps/requirements.txt index c4ea6a34df..7470c82aeb 100644 --- a/tools/deps/requirements.txt +++ b/tools/deps/requirements.txt @@ -388,17 +388,21 @@ pyyaml==6.0.1 \ --hash=sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585 \ --hash=sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d \ --hash=sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f -pywin32==301; sys_platform == "win32" \ - --hash=sha256:93367c96e3a76dfe5003d8291ae16454ca7d84bb24d721e0b74a07610b7be4a7 \ - --hash=sha256:9635df6998a70282bd36e7ac2a5cef9ead1627b0a63b17c731312c7a0daebb72 \ - --hash=sha256:c866f04a182a8cb9b7855de065113bbd2e40524f570db73ef1ee99ff0a5cc2f0 \ - --hash=sha256:dafa18e95bf2a92f298fe9c582b0e205aca45c55f989937c52c454ce65b93c78 \ - --hash=sha256:98f62a3f60aa64894a290fb7494bfa0bfa0a199e9e052e1ac293b2ad3cd2818b \ - --hash=sha256:fb3b4933e0382ba49305cc6cd3fb18525df7fd96aa434de19ce0878133bf8e4a \ - --hash=sha256:88981dd3cfb07432625b180f49bf4e179fb8cbb5704cd512e38dd63636af7a17 \ - --hash=sha256:8c9d33968aa7fcddf44e47750e18f3d034c3e443a707688a008a2e52bbef7e96 \ - --hash=sha256:595d397df65f1b2e0beaca63a883ae6d8b6df1cdea85c16ae85f6d2e648133fe \ - --hash=sha256:87604a4087434cd814ad8973bd47d6524bd1fa9e971ce428e76b62a5e0860fdf +pywin32==306; sys_platform == "win32" \ + --hash=sha256:06d3420a5155ba65f0b72f2699b5bacf3109f36acbe8923765c22938a69dfc8d \ + --hash=sha256:1c73ea9a0d2283d889001998059f5eaaba3b6238f767c9cf2833b13e6a685f65 \ + --hash=sha256:37257794c1ad39ee9be652da0462dc2e394c8159dfd913a8a4e8eb6fd346da0e \ + --hash=sha256:383229d515657f4e3ed1343da8be101000562bf514591ff383ae940cad65458b \ + --hash=sha256:39b61c15272833b5c329a2989999dcae836b1eed650252ab1b7bfbe1d59f30f4 \ + --hash=sha256:5821ec52f6d321aa59e2db7e0a35b997de60c201943557d108af9d4ae1ec7040 \ + --hash=sha256:70dba0c913d19f942a2db25217d9a1b726c278f483a919f1abfed79c9cf64d3a \ + --hash=sha256:72c5f621542d7bdd4fdb716227be0dd3f8565c11b280be6315b06ace35487d36 \ + --hash=sha256:84f4471dbca1887ea3803d8848a1616429ac94a4a8d05f4bc9c5dcfd42ca99c8 \ + --hash=sha256:a7639f51c184c0272e93f244eb24dafca9b1855707d94c192d4a0b4c01e1100e \ + --hash=sha256:e25fd5b485b55ac9c057f67d94bc203f3f6595078d1fb3b458c9c28b7153a802 \ + --hash=sha256:e4c092e2589b5cf0d365849e73e02c391c1349958c5ac3e9d5ccb9a28e017b3a \ + --hash=sha256:e65028133d15b64d2ed8f06dd9fbc268352478d4f9289e69c190ecd6818b6407 \ + --hash=sha256:e8ac1ae3601bee6ca9f7cb4b5363bf1c0badb935ef243c4733ff9a393b1690c0 requests==2.32.2 \ --hash=sha256:dd951ff5ecf3e3b3aa26b40703ba77495dab41da839ae72ef3c8e5d8e2433289 \ --hash=sha256:fc06670dd0ed212426dfeb94fc1b983d917c4f9847c863f313c9dfaaffb7c23c From ad962a38ed231ab7f165b813f89fff417e000012 Mon Sep 17 00:00:00 2001 From: Pooja Ramkrishna Daine Date: Mon, 9 Sep 2024 18:31:30 +0530 Subject: [PATCH 3/4] NXDRIVE-2929: Upgrade Python from 3.9.5 to 3.12.3 --- nxdrive/dao/engine.py | 12 ++++++------ nxdrive/engine/engine.py | 6 ++++-- nxdrive/engine/watcher/remote_watcher.py | 4 ++-- nxdrive/utils.py | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/nxdrive/dao/engine.py b/nxdrive/dao/engine.py index 9f52a18d90..6826b0d232 100644 --- a/nxdrive/dao/engine.py +++ b/nxdrive/dao/engine.py @@ -5,7 +5,7 @@ import os import shutil from contextlib import suppress -from datetime import datetime +from datetime import datetime, timezone from logging import getLogger from os.path import basename from pathlib import Path @@ -1502,7 +1502,7 @@ def increase_error( self, row: DocPair, error: str, /, *, details: str = None, incr: int = 1 ) -> None: with self.lock: - error_date = datetime.utcnow() + error_date = datetime.now(tz=timezone.utc) c = self._get_write_connection().cursor() c.execute( "UPDATE States" @@ -1591,7 +1591,7 @@ def unsynchronize_state( " error_count = 0," " last_sync_error_date = NULL" " WHERE id = ?", - (datetime.utcnow(), last_error, row.id), + (datetime.now(tz=timezone.utc), last_error, row.id), ) def unset_unsychronised(self, row: DocPair, /) -> None: @@ -1616,7 +1616,7 @@ def unset_unsychronised(self, row: DocPair, /) -> None: row.local_state, row.remote_state, row.pair_state, - datetime.utcnow(), + datetime.now(tz=timezone.utc), f"{adapt_path(row.local_path)}%", ), ) @@ -1658,7 +1658,7 @@ def synchronize_state( row.remote_state, row.pair_state, row.local_digest, - datetime.utcnow(), + datetime.now(tz=timezone.utc), row.id, version, ), @@ -1686,7 +1686,7 @@ def synchronize_state( row.local_state, row.remote_state, row.pair_state, - datetime.utcnow(), + datetime.now(tz=timezone.utc), row.id, row.local_path, row.remote_name, diff --git a/nxdrive/engine/engine.py b/nxdrive/engine/engine.py index 4fc2478f12..7af7192fa3 100644 --- a/nxdrive/engine/engine.py +++ b/nxdrive/engine/engine.py @@ -1,10 +1,10 @@ -import datetime import json import os import os.path import shutil from contextlib import suppress from dataclasses import dataclass +from datetime import datetime, timezone from functools import partial from logging import getLogger from pathlib import Path @@ -1184,7 +1184,9 @@ def _check_last_sync(self) -> None: log.debug(f"Emitting syncPartialCompleted for engine {self.uid}") self.syncPartialCompleted.emit() else: - self.dao.update_config("last_sync_date", datetime.datetime.utcnow()) + self.dao.update_config( + "last_sync_date", datetime.datetime.now(tz=timezone.utc) + ) log.debug(f"Emitting syncCompleted for engine {self.uid}") self._sync_started = False self.syncCompleted.emit() diff --git a/nxdrive/engine/watcher/remote_watcher.py b/nxdrive/engine/watcher/remote_watcher.py index 7e88b2a3c5..babd0c94e5 100644 --- a/nxdrive/engine/watcher/remote_watcher.py +++ b/nxdrive/engine/watcher/remote_watcher.py @@ -1,5 +1,5 @@ import os -from datetime import datetime +from datetime import datetime, timezone from logging import getLogger from operator import attrgetter, itemgetter from time import monotonic, sleep @@ -116,7 +116,7 @@ def scan_remote(self, *, from_state: DocPair = None) -> None: # Recursive update self._do_scan_remote(from_state, remote_info) - self._last_remote_full_scan = datetime.utcnow() + self._last_remote_full_scan = datetime.now(tz=timezone.utc) self.dao.update_config("remote_last_full_scan", self._last_remote_full_scan) self.dao.clean_scanned() diff --git a/nxdrive/utils.py b/nxdrive/utils.py index 9812323406..e77b318581 100644 --- a/nxdrive/utils.py +++ b/nxdrive/utils.py @@ -12,7 +12,7 @@ import sys from configparser import DEFAULTSECT, ConfigParser from copy import deepcopy -from datetime import datetime +from datetime import datetime, timezone from functools import lru_cache from itertools import islice from logging import getLogger @@ -1286,7 +1286,7 @@ def today_is_special() -> bool: """This beautiful day is special, isn't it? As all other days, right? :)""" return ( os.getenv("I_LOVE_XMAS", "0") == "1" - or int(datetime.utcnow().strftime("%j")) >= 354 + or int(datetime.now(tz=timezone.utc).strftime("%j")) >= 354 ) @@ -1300,7 +1300,7 @@ def get_current_locale() -> str: else: import locale - encoding = locale.getdefaultlocale()[1] or "" + encoding = locale.getpreferredencoding(False) or "" # Guess the current locale name if WINDOWS: @@ -1314,7 +1314,7 @@ def get_current_locale() -> str: l10n_code = NSLocale.currentLocale() l10n = NSLocale.localeIdentifier(l10n_code) else: - l10n = locale.getdefaultlocale()[0] or "" + l10n = locale.getpreferredencoding(False) or "" return ".".join([l10n, encoding]) From ec780d4893baa60fdf8e536224cf388027779144 Mon Sep 17 00:00:00 2001 From: Pooja Ramkrishna Daine Date: Mon, 16 Sep 2024 16:58:45 +0530 Subject: [PATCH 4/4] NXDRIVE-2929: Upgrade Python from 3.9.5 to 3.12.3 --- nxdrive/utils.py | 4 ++-- tests/conftest.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nxdrive/utils.py b/nxdrive/utils.py index e77b318581..a31321992e 100644 --- a/nxdrive/utils.py +++ b/nxdrive/utils.py @@ -1300,7 +1300,7 @@ def get_current_locale() -> str: else: import locale - encoding = locale.getpreferredencoding(False) or "" + encoding = locale.getlocale()[1] or "" # Guess the current locale name if WINDOWS: @@ -1314,7 +1314,7 @@ def get_current_locale() -> str: l10n_code = NSLocale.currentLocale() l10n = NSLocale.localeIdentifier(l10n_code) else: - l10n = locale.getpreferredencoding(False) or "" + l10n = locale.getlocale()[1] or "" return ".".join([l10n, encoding]) diff --git a/tests/conftest.py b/tests/conftest.py index 8a2de4fb85..c08b9b0496 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -95,6 +95,10 @@ def no_warnings(recwarn): continue elif "Cryptography will be significantly faster" in message: continue + elif "The default datetime adapter is deprecated as of Python 3.12" in message: + continue + elif "datetime.datetime" in message: + continue warn = f"{warning.filename}:{warning.lineno} {message}" print(warn, file=sys.stderr)