Skip to content

Commit

Permalink
Merge pull request #511 from reef-technologies/py313
Browse files Browse the repository at this point in the history
Drop python 3.7 & add python 3.13 support
  • Loading branch information
mjurbanski-reef authored Oct 13, 2024
2 parents 5b5ac44 + 8fc39e7 commit a4a67b1
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 195 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"]
extras: [ "" ]
exclude:
- os: "macos-latest"
python-version: "pypy3.10"
- os: "windows-latest"
python-version: "pypy3.10"
# Workaround for https://github.com/actions/setup-python/issues/696
- os: "macos-latest"
python-version: 3.7
- os: "macos-latest"
python-version: 3.8
- os: "macos-latest"
Expand All @@ -107,8 +105,6 @@ jobs:
extras: "full"
os: "ubuntu-latest"
# Workaround for https://github.com/actions/setup-python/issues/696
- os: "macos-13"
python-version: 3.7
- os: "macos-13"
python-version: 3.8
- os: "macos-13"
Expand Down Expand Up @@ -150,4 +146,4 @@ jobs:
sudo apt-get install -y graphviz plantuml
python -m pip install --upgrade nox pdm
- name: Build the docs
run: nox --non-interactive -vs doc
run: nox --non-interactive -vs doc
10 changes: 3 additions & 7 deletions b2sdk/_internal/sync/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from __future__ import annotations

import contextlib
import functools
import logging
import os
from abc import ABCMeta, abstractmethod
Expand Down Expand Up @@ -113,23 +114,18 @@ def __init__(
self.size = size
self.encryption_settings_provider = encryption_settings_provider
self.large_file_sha1 = None
# TODO: Remove once we drop Python 3.7 support
self.cached_upload_source = None

def get_bytes(self) -> int:
"""
Return file size.
"""
return self.size

@property
# TODO: Use @functools.cached_property once we drop Python 3.7 support
@functools.cached_property
def _upload_source(self) -> UploadSourceLocalFile:
""" Upload source if the file was to be uploaded in full """
# NOTE: We're caching this to ensure that sha1 is not recalculated.
if self.cached_upload_source is None:
self.cached_upload_source = UploadSourceLocalFile(self.local_full_path)
return self.cached_upload_source
return UploadSourceLocalFile(self.local_full_path)

def get_all_sources(self) -> list[OutboundTransferSource]:
""" Get list of sources required to complete this upload """
Expand Down
6 changes: 1 addition & 5 deletions b2sdk/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
######################################################################
from __future__ import annotations

from importlib.metadata import version as _version
from sys import version_info as _version_info

try:
from importlib.metadata import version as _version
except ModuleNotFoundError: # python 3.7
from importlib_metadata import version as _version

__all__ = [
"VERSION",
"PYTHON_VERSION",
Expand Down
4 changes: 4 additions & 0 deletions changelog.d/+drop_py37.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Remove Python 3.7 support in new releases.
Under Python 3.7 `pip` will keep resolving the latest version of the package that supports active interpreter.
Python 3.8 is now the minimum supported version, [until it reaches EOL in October 2024](https://devguide.python.org/versions/).
We encourage use of latest stable Python release.
2 changes: 2 additions & 0 deletions changelog.d/+official_python313_support.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Declare official support for Python 3.13 in b2sdk.
Test b2sdk against Python 3.13 in CI.
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'3.10',
'3.11',
'3.12',
'3.13',
] if NOX_PYTHONS is None else NOX_PYTHONS.split(',')


Expand All @@ -52,7 +53,7 @@ def _detect_python_nox_id() -> str:
PYTHON_VERSIONS = [_detect_python_nox_id()]
print(f"CI job mode; using provided interpreter only; PYTHON_VERSIONS={PYTHON_VERSIONS!r}")

PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-1]
PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-2] if len(PYTHON_VERSIONS) > 1 else PYTHON_VERSIONS[0]

PY_PATHS = ['b2sdk', 'test', 'noxfile.py']

Expand Down
313 changes: 147 additions & 166 deletions pdm.lock

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies = [
"requests<3.0.0,>=2.9.1",
"typing-extensions>=4.7.1; python_version < '3.12'",
]
requires-python = ">=3.7"
requires-python = ">=3.8"
readme = "README.md"
license = {text = "MIT"}
keywords = ["backblaze", "b2", "cloud", "storage"]
Expand All @@ -22,12 +22,12 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

[project.urls]
Expand Down Expand Up @@ -169,9 +169,7 @@ test = [
"pytest-timeout==2.1.0",
"tqdm<5.0.0,>=4.5.0",
"eval_type_backport>=0.1.3,<1; python_version<'3.10'", # used with pydantic
# remove `and platform_python_implementation!='PyPy'` after dropping Python 3.7 support as that
# will allow us to update pydantic to a version which installs properly under PyPy
"pydantic>=2.0.1,<3; python_version>='3.8' and platform_python_implementation!='PyPy'",
"pydantic>=2.0.1",
"pywin32>=306; sys_platform == \"win32\" and platform_python_implementation!='PyPy'",
]
release = [
Expand Down
9 changes: 6 additions & 3 deletions test/unit/scan/test_folder_traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ def test_invalid_name(self, tmp_path):
]

@pytest.mark.skipif(
platform.system() == 'Windows' and platform.python_implementation() == 'PyPy',
reason=
"PyPy on Windows force-decodes non-UTF-8 filenames, which makes it impossible to test this case"
platform.system() == 'Windows' and
(platform.python_implementation() == 'PyPy' or sys.version_info >= (3, 13)),
reason=(
"PyPy on Windows force-decodes non-UTF-8 filenames, which makes it impossible to test this case. "
"Python 3.13 does so similarly on Windows."
)
)
def test_invalid_unicode_filename(self, tmp_path):
# Create a directory structure below with initial scanning point at tmp_path/dir:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v0/test_version_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def easy(bbb):
assert easy(5) == 5
assert easy(bbb=5) == 5
assert easy.__name__ == 'easy'
assert easy.__doc__ == ' easy docstring '
assert easy.__doc__.strip() == 'easy docstring'
assert len(w) == 0

with warnings.catch_warnings(record=True) as w:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1/test_version_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def easy(bbb):
assert easy(5) == 5
assert easy(bbb=5) == 5
assert easy.__name__ == 'easy'
assert easy.__doc__ == ' easy docstring '
assert easy.__doc__.strip() == 'easy docstring'
assert len(w) == 0

with warnings.catch_warnings(record=True) as w:
Expand Down

0 comments on commit a4a67b1

Please sign in to comment.