Skip to content

Commit 951a487

Browse files
authored
feat: python 3.12 support (#32)
1 parent ce237a7 commit 951a487

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

.github/workflows/cicd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
python-version: ["3.8", "3.9", "3.10", "3.11"]
33+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
3434
steps:
3535
- uses: actions/checkout@v3
3636
- uses: actions/setup-python@v4

source/ftrack_api/cache.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@
1515
1616
'''
1717

18-
from future import standard_library
19-
standard_library.install_aliases()
2018
from builtins import str
2119
from six import string_types
2220
from builtins import object
23-
import collections
2421
from six.moves import collections_abc
2522
import functools
2623
import abc
2724
import copy
2825
import inspect
2926
import re
30-
import six
3127

3228
try:
3329
# Python 2.x

source/ftrack_api/event/hub.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from __future__ import absolute_import
55

6-
from future import standard_library
7-
standard_library.install_aliases()
86
from builtins import str
97
from builtins import range
108
from builtins import object

source/ftrack_api/plugin.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import collections
88
import os
99
import uuid
10-
import imp
1110
import traceback
1211

1312
try:
@@ -41,6 +40,26 @@ def getfullargspec(func):
4140
annotations={}
4241
)
4342

43+
try:
44+
from imp import load_source
45+
46+
except ImportError:
47+
# The imp module is deprecated in version 3.12. Use importlib instead.
48+
import importlib.util
49+
import importlib.machinery
50+
51+
def load_source(modname, filename):
52+
# https://docs.python.org/3/whatsnew/3.12.html#imp
53+
54+
loader = importlib.machinery.SourceFileLoader(modname, filename)
55+
module = importlib.util.module_from_spec(
56+
importlib.util.spec_from_file_location(modname, filename, loader=loader)
57+
)
58+
59+
loader.exec_module(module)
60+
61+
return module
62+
4463

4564
def discover(paths, positional_arguments=None, keyword_arguments=None):
4665
'''Find and load plugins in search *paths*.
@@ -77,7 +96,7 @@ def discover(paths, positional_arguments=None, keyword_arguments=None):
7796
unique_name = uuid.uuid4().hex
7897

7998
try:
80-
module = imp.load_source(unique_name, module_path)
99+
module = load_source(unique_name, module_path)
81100
except Exception as error:
82101
logger.warning(
83102
'Failed to load plugin from "{0}": {1}'

0 commit comments

Comments
 (0)