Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NXDRIVE-2929: Upgrade Python from 3.9.5 to 3.12.3. #5197

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/dead_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +63,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
Expand Down Expand Up @@ -93,7 +93,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
Expand Down Expand Up @@ -129,7 +129,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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/functional_tests_2023.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +63,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
Expand Down Expand Up @@ -93,7 +93,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
Expand Down Expand Up @@ -123,7 +123,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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added .github/workflows/main.yml
Empty file.
2 changes: 1 addition & 1 deletion .github/workflows/spell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,7 +56,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
Expand Down Expand Up @@ -87,7 +87,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:
Expand Down
2 changes: 1 addition & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/gnu_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 6 additions & 6 deletions nxdrive/dao/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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
Expand Down Expand Up @@ -1503,7 +1503,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"
Expand Down Expand Up @@ -1592,7 +1592,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:
Expand All @@ -1617,7 +1617,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)}%",
),
)
Expand Down Expand Up @@ -1659,7 +1659,7 @@ def synchronize_state(
row.remote_state,
row.pair_state,
row.local_digest,
datetime.utcnow(),
datetime.now(tz=timezone.utc),
row.id,
version,
),
Expand Down Expand Up @@ -1687,7 +1687,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,
Expand Down
6 changes: 4 additions & 2 deletions nxdrive/engine/engine.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -1182,7 +1182,9 @@
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(

Check warning on line 1185 in nxdrive/engine/engine.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/engine/engine.py#L1185

Added line #L1185 was not covered by tests
"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()
Expand Down
4 changes: 2 additions & 2 deletions nxdrive/engine/watcher/remote_watcher.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -116,7 +116,7 @@

# 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)

Check warning on line 119 in nxdrive/engine/watcher/remote_watcher.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/engine/watcher/remote_watcher.py#L119

Added line #L119 was not covered by tests
self.dao.update_config("remote_last_full_scan", self._last_remote_full_scan)
self.dao.clean_scanned()

Expand Down
10 changes: 5 additions & 5 deletions nxdrive/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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
Expand Down Expand Up @@ -646,7 +646,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
Expand Down Expand Up @@ -1287,7 +1287,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
)


Expand All @@ -1301,7 +1301,7 @@ def get_current_locale() -> str:
else:
import locale

encoding = locale.getdefaultlocale()[1] or ""
encoding = locale.getlocale()[1] or ""

# Guess the current locale name
if WINDOWS:
Expand All @@ -1315,7 +1315,7 @@ def get_current_locale() -> str:
l10n_code = NSLocale.currentLocale()
l10n = NSLocale.localeIdentifier(l10n_code)
else:
l10n = locale.getdefaultlocale()[0] or ""
l10n = locale.getlocale()[1] or ""

return ".".join([l10n, encoding])

Expand Down
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 15 additions & 11 deletions tools/deps/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,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.3 \
--hash=sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760 \
--hash=sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6
Expand Down
2 changes: 1 addition & 1 deletion tools/posix/deploy_ci_agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/windows/deploy_ci_agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,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) {
Expand Down
Loading