Skip to content

Commit

Permalink
Add inital support for 3.12
Browse files Browse the repository at this point in the history
- Move to version 6.6.0dev0
- Make CI pass for 3.12
  - Drop support for swift unless someone speaks up and wants to help support it
    - This will cause a temporary coverage reduction
  - Move python_requires + GitHub actions to >= 3.11 only
- Leave swift for one more release + document deprecating support due to no one to help maintain
- Fix remaining s3path 3.12 fun
  - Move to 3.12 private _generate_prefix until we workout correct way
  - Move last missed uses of private configuration_map

Test:
- Run `/tmp/tb_312/bin/pre-commit run -a`
- Run tox in py312
  - `/tmp/tb_312/bin/tox`
  • Loading branch information
cooperlees committed May 19, 2024
1 parent c43b77f commit 58c3ded
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.11", "3.12"]
os: [macOS-latest, windows-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.11", "3.12"]
os: [ubuntu-latest]

steps:
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ classifiers =
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
description = Mirroring tool that implements the client (mirror) side of PEP 381
long_description = file:README.md
long_description_content_type = text/markdown
Expand All @@ -15,7 +16,7 @@ project_urls =
Source Code = https://github.com/pypa/bandersnatch
Change Log = https://github.com/pypa/bandersnatch/blob/master/CHANGES.md
url = https://github.com/pypa/bandersnatch/
version = 6.5.0
version = 6.6.0dev0

[options]
install_requires =
Expand All @@ -29,7 +30,7 @@ install_requires =
package_dir =
=src
packages = find:
python_requires = >=3.10
python_requires = >=3.11

[options.packages.find]
where=src
Expand Down
4 changes: 2 additions & 2 deletions src/bandersnatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def version_str(self) -> str:

__version_info__ = _VersionInfo(
major=6,
minor=5,
minor=6,
micro=0,
releaselevel="",
releaselevel="dev0",
serial=0, # Not currently in use with Bandersnatch versioning
)
__version__ = __version_info__.version_str
6 changes: 3 additions & 3 deletions src/bandersnatch/tests/plugins/test_storage_plugin_s3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime

import pytest
from s3path import S3Path
from s3path import configuration_map, S3Path

from bandersnatch.tests.mock_config import mock_config
from bandersnatch_storage_plugins import s3
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_plugin_init(s3_mock: S3Path) -> None:
backend.initialize_plugin()

path = s3.S3Path("/tmp/pypi")
resource, _ = path._accessor.configuration_map.get_configuration(path)
resource, _ = configuration_map.get_configuration(path)
assert resource.meta.client.meta.endpoint_url == "http://localhost:9090"

config_loader = mock_config(
Expand All @@ -198,7 +198,7 @@ def test_plugin_init(s3_mock: S3Path) -> None:
backend.initialize_plugin()

path = s3.S3Path("/tmp/pypi")
resource, _ = path._accessor.configuration_map.get_configuration(path)
resource, _ = configuration_map.get_configuration(path)
assert resource.meta.client.meta.endpoint_url == "http://localhost:9090"


Expand Down
15 changes: 12 additions & 3 deletions src/bandersnatch/tests/plugins/test_storage_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
from bandersnatch.package import Package
from bandersnatch.storage import PATH_TYPES
from bandersnatch.tests.mock_config import mock_config
from bandersnatch_storage_plugins import filesystem, swift
from bandersnatch_storage_plugins import filesystem

if sys.version_info < (3, 12):
from bandersnatch_storage_plugins import swift


if TYPE_CHECKING:
import swiftclient
Expand Down Expand Up @@ -567,12 +571,16 @@ def tearDown(self) -> None:
class BaseStoragePluginTestCase(BasePluginTestCase):
plugin_map = {
"filesystem": filesystem.FilesystemStorage,
"swift": swift.SwiftStorage,
}
# Both switch plugons somehow now cause typing error but bug was already there
# - Keeping due to dropping swift support in 7.0
if sys.version_info < (3, 12):
plugin_map["swift"] = swift.SwiftStorage # type: ignore
path_backends = {
"filesystem": pathlib.Path,
"swift": swift.SwiftPath,
}
if sys.version_info < (3, 12):
path_backends["swift"] = swift.SwiftPath # type: ignore

base_find_contents = r"""
.lock
Expand Down Expand Up @@ -952,6 +960,7 @@ class TestFilesystemStoragePlugin(BaseStoragePluginTestCase):
)


@unittest.skipIf(sys.version_info >= (3, 12), "Dropping support for swift in 3.12")
class TestSwiftStoragePlugin(BaseStoragePluginTestCase):
backend = "swift"
base_find_contents = BaseStoragePluginTestCase.base_find_contents.replace(
Expand Down
11 changes: 10 additions & 1 deletion src/bandersnatch_storage_plugins/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import os
import pathlib
import sys
import tempfile
from collections.abc import Generator, Iterator
from fnmatch import fnmatch
Expand All @@ -19,6 +20,9 @@
from s3path import S3Path as _S3Path
from s3path import configuration_map, register_configuration_parameter

if sys.version_info >= (3, 12):
from s3path.accessor import _generate_prefix

if TYPE_CHECKING:
from s3path.accessor import _S3DirEntry

Expand All @@ -40,9 +44,14 @@ def glob(self, pattern: str) -> Iterator[S3Path]:
resource, _ = configuration_map.get_configuration(self)
bucket = resource.Bucket(bucket_name)

if sys.version_info >= (3, 12):
prefix = _generate_prefix(self)
else:
prefix = self._accessor.generate_prefix(self)

kwargs = {
"Bucket": bucket_name,
"Prefix": self._accessor.generate_prefix(self),
"Prefix": prefix,
"Delimiter": "",
}
continuation_token = None
Expand Down

0 comments on commit 58c3ded

Please sign in to comment.