Skip to content

Commit c7830f1

Browse files
supakeenCaselITvytas7
authored
chore: py312 compat; imp is gone, use importlib (#24)
* chore: py312 compat; imp is gone, use importlib The long-deprecated `imp` module is gone in Python 3.12. Use the `importlib` module to provide the same functionality. * ci: drop py35, add py311 * add python 3.12 to the pipeline * fix type in previous commit * declare support for python 3.11 and 3.12. Remove 3.5 * Update setup.py --------- Co-authored-by: Federico Caselli <[email protected]> Co-authored-by: Vytautas Liuolia <[email protected]>
1 parent 2f060dc commit c7830f1

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

.github/workflows/tests.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ jobs:
2323
toxenv:
2424
- "pep8"
2525
include:
26-
- python-version: "3.5"
27-
os: ubuntu-20.04
28-
toxenv: py35
2926
- python-version: "3.6"
3027
os: ubuntu-20.04
3128
toxenv: py36
@@ -41,6 +38,12 @@ jobs:
4138
- python-version: "3.10"
4239
os: ubuntu-20.04
4340
toxenv: py310
41+
- python-version: "3.11"
42+
os: ubuntu-20.04
43+
toxenv: py311
44+
- python-version: "3.12.0-alpha - 3.12"
45+
os: ubuntu-20.04
46+
toxenv: py312
4447
- python-version: pypy3
4548
os: ubuntu-20.04
4649
toxenv: pypy3

setup.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import imp
1+
import importlib.machinery
2+
import importlib.util
23
import io
34
from os import path
45

56
from setuptools import find_packages, setup
67

7-
VERSION = imp.load_source('version', path.join('.', 'token_bucket', 'version.py'))
8-
VERSION = VERSION.__version__
8+
loader = importlib.machinery.SourceFileLoader(
9+
'version', path.join('.', 'token_bucket', 'version.py')
10+
)
11+
spec = importlib.util.spec_from_loader(loader.name, loader)
12+
module = importlib.util.module_from_spec(spec)
13+
14+
loader.exec_module(module)
915

16+
VERSION = module.__version__
1017

1118
setup(
1219
name='token_bucket',
@@ -28,20 +35,21 @@
2835
'Programming Language :: Python',
2936
'Programming Language :: Python :: Implementation :: CPython',
3037
'Programming Language :: Python :: Implementation :: PyPy',
31-
'Programming Language :: Python :: 3.5',
3238
'Programming Language :: Python :: 3.6',
3339
'Programming Language :: Python :: 3.7',
3440
'Programming Language :: Python :: 3.8',
3541
'Programming Language :: Python :: 3.9',
3642
'Programming Language :: Python :: 3.10',
43+
'Programming Language :: Python :: 3.11',
44+
'Programming Language :: Python :: 3.12',
3745
],
3846
keywords='web http https cloud rate limiting token bucket throttling',
3947
author='kgriffs',
4048
author_email='[email protected]',
4149
url='https://github.com/falconry/token-bucket',
4250
license='Apache 2.0',
4351
packages=find_packages(exclude=['tests']),
44-
python_requires='>=3.5',
52+
python_requires='>=3.6',
4553
install_requires=[],
4654
setup_requires=['pytest-runner'],
4755
tests_require=['pytest'],

0 commit comments

Comments
 (0)