Skip to content

Commit 5ddc1cb

Browse files
committed
fix(test): add support for python 3.13, fix deprecated library
1 parent 78fa51b commit 5ddc1cb

File tree

9 files changed

+57
-105
lines changed

9 files changed

+57
-105
lines changed

.github/README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This directory contains the complete CI/CD setup for the python-simple-ioc proje
77
### 🚀 Main CI Workflow (`ci.yml`)
88
- **Purpose**: Primary continuous integration for every push and PR
99
- **Features**:
10-
- Tests against Python 3.9, 3.10, 3.11, and 3.12
10+
- Tests against Python 3.9, 3.10, 3.11, 3.12, and 3.13
1111
- Runs flake8 linting (required to pass)
1212
- Executes core tests using smart dependency detection
1313
- Optional mypy type checking (non-blocking)
@@ -28,12 +28,6 @@ This directory contains the complete CI/CD setup for the python-simple-ioc proje
2828
- **Focus**: Core functionality verification
2929

3030

31-
### 📚 Documentation (`docs.yml`)
32-
- **Purpose**: Build and deploy documentation to GitHub Pages
33-
- **Features**:
34-
- Builds Sphinx documentation with warnings as errors
35-
- Deploys to GitHub Pages on push to main/master
36-
- Uses proper GitHub Pages permissions and concurrency
3731

3832
### 🏷️ Release Automation (`release.yml`)
3933
- **Purpose**: Automated package building and PyPI publishing
@@ -75,10 +69,6 @@ Add these to your GitHub repository settings:
7569
- `PYPI_API_TOKEN`: Your PyPI API token for publishing releases
7670
- `TEST_PYPI_API_TOKEN`: Your Test PyPI API token for testing
7771

78-
### GitHub Pages Setup
79-
1. Go to repository Settings → Pages
80-
2. Select "GitHub Actions" as the source
81-
3. The `docs.yml` workflow will automatically deploy documentation
8272

8373
### Branch Protection
8474
Consider setting up branch protection rules for `main`/`master`:

.github/workflows-badges.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Add these badges to your README.md:
55
```markdown
66
[![CI](https://github.com/rande/python-simple-ioc/actions/workflows/ci.yml/badge.svg)](https://github.com/rande/python-simple-ioc/actions/workflows/ci.yml)
77
[![Tests](https://github.com/rande/python-simple-ioc/actions/workflows/tests.yml/badge.svg)](https://github.com/rande/python-simple-ioc/actions/workflows/tests.yml)
8-
[![Docs](https://github.com/rande/python-simple-ioc/actions/workflows/docs.yml/badge.svg)](https://github.com/rande/python-simple-ioc/actions/workflows/docs.yml)
98
[![Test Matrix](https://github.com/rande/python-simple-ioc/actions/workflows/test-matrix.yml/badge.svg)](https://github.com/rande/python-simple-ioc/actions/workflows/test-matrix.yml)
109
```
1110

@@ -14,7 +13,7 @@ Add these badges to your README.md:
1413
### ci.yml
1514
- Main CI workflow that runs on every push and PR
1615
- Runs flake8 linting and the standard test suite
17-
- Tests against Python 3.9, 3.10, 3.11, and 3.12
16+
- Tests against Python 3.9, 3.10, 3.11, 3.12, and 3.13
1817

1918
### tests.yml
2019
- Comprehensive test workflow with separate jobs for:

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
python-version: ['3.9', '3.10', '3.11', '3.12']
16+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1717

1818
steps:
1919
- uses: actions/checkout@v4
2020

2121
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525

.github/workflows/docs.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions/checkout@v4
1919

2020
- name: Set up Python
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.11'
2424

.github/workflows/test-matrix.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
os: [ubuntu-latest] # Add more OS options if needed: macos-latest, windows-latest
17-
python-version: ['3.9', '3.10', '3.11', '3.12']
17+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1818
# exclude:
1919
# # Reduce matrix size by excluding some combinations
2020
# - os: macos-latest
@@ -26,7 +26,7 @@ jobs:
2626
- uses: actions/checkout@v4
2727

2828
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v5
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232

.github/workflows/tests.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ['3.9', '3.10', '3.11', '3.12']
14+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1515

1616
steps:
1717
- uses: actions/checkout@v4
1818

1919
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@v5
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323

@@ -39,13 +39,13 @@ jobs:
3939
runs-on: ubuntu-latest
4040
strategy:
4141
matrix:
42-
python-version: ['3.9', '3.10', '3.11', '3.12']
42+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
4343

4444
steps:
4545
- uses: actions/checkout@v4
4646

4747
- name: Set up Python ${{ matrix.python-version }}
48-
uses: actions/setup-python@v4
48+
uses: actions/setup-python@v5
4949
with:
5050
python-version: ${{ matrix.python-version }}
5151

@@ -82,7 +82,7 @@ jobs:
8282
- uses: actions/checkout@v4
8383

8484
- name: Set up Python ${{ matrix.python-version }}
85-
uses: actions/setup-python@v4
85+
uses: actions/setup-python@v5
8686
with:
8787
python-version: ${{ matrix.python-version }}
8888

@@ -118,9 +118,11 @@ jobs:
118118
missing.append(extra)
119119
120120
if test_exists and not missing:
121-
print('::set-output name=should_run::true')
121+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
122+
f.write('should_run=true\\n')
122123
else:
123-
print('::set-output name=should_run::false')
124+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
125+
f.write('should_run=false\\n')
124126
if missing:
125127
print(f'Missing dependencies: {missing}')
126128
if not test_exists:
@@ -137,13 +139,13 @@ jobs:
137139
runs-on: ubuntu-latest
138140
strategy:
139141
matrix:
140-
python-version: ['3.9', '3.12']
142+
python-version: ['3.9', '3.13']
141143

142144
steps:
143145
- uses: actions/checkout@v4
144146

145147
- name: Set up Python ${{ matrix.python-version }}
146-
uses: actions/setup-python@v4
148+
uses: actions/setup-python@v5
147149
with:
148150
python-version: ${{ matrix.python-version }}
149151

@@ -229,7 +231,7 @@ jobs:
229231
- uses: actions/checkout@v4
230232

231233
- name: Set up Python
232-
uses: actions/setup-python@v4
234+
uses: actions/setup-python@v5
233235
with:
234236
python-version: '3.11'
235237

@@ -244,7 +246,7 @@ jobs:
244246
sphinx-build -nW -b html -d docs/_build/doctrees docs docs/_build/html
245247
246248
- name: Upload documentation artifacts
247-
uses: actions/upload-artifact@v3
249+
uses: actions/upload-artifact@v4
248250
with:
249251
name: documentation
250252
path: docs/_build/html/
@@ -257,7 +259,7 @@ jobs:
257259
- uses: actions/checkout@v4
258260

259261
- name: Set up Python
260-
uses: actions/setup-python@v4
262+
uses: actions/setup-python@v5
261263
with:
262264
python-version: '3.11'
263265

ioc/locator.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,44 @@ class PackageLocator(BaseLocator):
8585
If the package path is not given, ``'resources'`` is assumed.
8686
"""
8787

88-
def __init__(self, package_name, package_path='resources'):
89-
from pkg_resources import ResourceManager, get_provider
90-
self.manager = ResourceManager()
91-
self.provider = get_provider(package_name)
88+
def __init__(self, package_name: str, package_path: str = 'resources') -> None:
89+
try:
90+
# Python 3.9+
91+
from importlib import resources
92+
self.resources = resources
93+
except ImportError:
94+
# Fallback for older Python versions
95+
import importlib_resources as resources
96+
self.resources = resources
97+
98+
self.package_name = package_name
9299
self.package_path = package_path
93100

94-
def locate(self, resource):
101+
def locate(self, resource: str) -> str:
95102
pieces = split_resource_path(resource)
96-
p = '/'.join((self.package_path,) + tuple(pieces))
97-
if not self.provider.has_resource(p):
103+
104+
try:
105+
# Try to access the resource
106+
package = self.resources.files(self.package_name)
107+
if self.package_path:
108+
package = package / self.package_path
109+
110+
for piece in pieces:
111+
package = package / piece
112+
113+
if not package.is_file():
114+
raise ResourceNotFound(resource)
115+
116+
# For Python 3.9+, we need to handle the path properly
117+
if hasattr(package, '__fspath__'):
118+
return str(package)
119+
else:
120+
# Use as_file context manager for temporary access
121+
with self.resources.as_file(package) as path:
122+
return str(path)
123+
except (AttributeError, FileNotFoundError, ModuleNotFoundError):
98124
raise ResourceNotFound(resource)
99125

100-
return self.provider.get_resource_filename(self.manager, p)
101-
102126
class FunctionLocator(BaseLocator):
103127
"""A locator that is passed a function which does the searching. The
104128
function becomes the name of the resource passed and has to return

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "ioc"
77
version = "0.0.16"
88
description = "A small dependency injection container based on Symfony2 Dependency Component"
99
readme = "README.txt"
10-
license = {file = "LICENSE"}
10+
license = "Apache-2.0"
1111
authors = [
1212
{name = "Thomas Rabaix", email = "[email protected]"}
1313
]
@@ -29,6 +29,7 @@ classifiers = [
2929
"Programming Language :: Python :: 3.10",
3030
"Programming Language :: Python :: 3.11",
3131
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: 3.13",
3233
"Topic :: Software Development :: Libraries :: Python Modules",
3334
"Topic :: Utilities",
3435
]
@@ -96,12 +97,12 @@ ignore_errors = false
9697
module = [
9798
"yaml.*",
9899
"werkzeug.*",
99-
"pkg_resources.*",
100100
"element.*",
101101
"tornado.*",
102102
"redis.*",
103103
"jinja2.*",
104104
"flask.*",
105+
"importlib_resources.*",
105106
]
106107
ignore_missing_imports = true
107108

0 commit comments

Comments
 (0)