Skip to content

Commit

Permalink
fix missing importlib functions for python < 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jooste committed Sep 19, 2022
1 parent 9406976 commit b4e2dae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bluesky/resourcepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
import shutil
import itertools
from pathlib import Path
from importlib.resources import files
from importlib.readers import MultiplexedPath
try:
from importlib.resources import files
from importlib.readers import MultiplexedPath
except ImportError:
# Python < 3.9 only provides deprecated resources API
from importlib_resources import files
from importlib_resources.readers import MultiplexedPath


class ResourcePath(MultiplexedPath):
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Always prefer setuptools over distutils
import os
import sys
from pathlib import Path
from setuptools import setup, find_packages, Extension
import configparser
Expand All @@ -16,6 +17,9 @@
with open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as f:
install_requires = f.readlines()

# If Python version < 3.9, add importlib_resources requirement
if sys.version_info.major == 3 and sys.version_info.minor < 9:
install_requires.append('importlib_resources')

# get extra requirements from setup.cfg
parser = configparser.ConfigParser()
Expand Down

0 comments on commit b4e2dae

Please sign in to comment.