Skip to content

Commit

Permalink
chore: py312 compat; imp is gone, use importlib (#24)
Browse files Browse the repository at this point in the history
* 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 <CaselIT@users.noreply.github.com>
Co-authored-by: Vytautas Liuolia <vytautas.liuolia@gmail.com>
  • Loading branch information
3 people committed Jul 1, 2023
1 parent 2f060dc commit c7830f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ jobs:
toxenv:
- "pep8"
include:
- python-version: "3.5"
os: ubuntu-20.04
toxenv: py35
- python-version: "3.6"
os: ubuntu-20.04
toxenv: py36
Expand All @@ -41,6 +38,12 @@ jobs:
- python-version: "3.10"
os: ubuntu-20.04
toxenv: py310
- python-version: "3.11"
os: ubuntu-20.04
toxenv: py311
- python-version: "3.12.0-alpha - 3.12"
os: ubuntu-20.04
toxenv: py312
- python-version: pypy3
os: ubuntu-20.04
toxenv: pypy3
Expand Down
18 changes: 13 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import imp
import importlib.machinery
import importlib.util
import io
from os import path

from setuptools import find_packages, setup

VERSION = imp.load_source('version', path.join('.', 'token_bucket', 'version.py'))
VERSION = VERSION.__version__
loader = importlib.machinery.SourceFileLoader(
'version', path.join('.', 'token_bucket', 'version.py')
)
spec = importlib.util.spec_from_loader(loader.name, loader)
module = importlib.util.module_from_spec(spec)

loader.exec_module(module)

VERSION = module.__version__

setup(
name='token_bucket',
Expand All @@ -28,20 +35,21 @@
'Programming Language :: Python',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'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',
],
keywords='web http https cloud rate limiting token bucket throttling',
author='kgriffs',
author_email='mail@kgriffs.com',
url='https://github.com/falconry/token-bucket',
license='Apache 2.0',
packages=find_packages(exclude=['tests']),
python_requires='>=3.5',
python_requires='>=3.6',
install_requires=[],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
Expand Down

0 comments on commit c7830f1

Please sign in to comment.