mirror of
https://github.com/soimort/you-get.git
synced 2025-03-11 18:08:50 +03:00
Update setup.py: compatibility for older python versions
This commit is contained in:
parent
1c1f982869
commit
873ffdb61e
27
setup.py
27
setup.py
@ -5,18 +5,21 @@ PACKAGE_NAME = 'you_get'
|
|||||||
|
|
||||||
PROJ_METADATA = '%s.json' % PROJ_NAME
|
PROJ_METADATA = '%s.json' % PROJ_NAME
|
||||||
|
|
||||||
import importlib.util
|
import sys
|
||||||
import importlib.machinery
|
if (sys.version_info >= (3, 12)):
|
||||||
|
import importlib.util
|
||||||
def load_source(modname, filename):
|
import importlib.machinery
|
||||||
loader = importlib.machinery.SourceFileLoader(modname, filename)
|
def load_source(modname, filename):
|
||||||
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
|
loader = importlib.machinery.SourceFileLoader(modname, filename)
|
||||||
module = importlib.util.module_from_spec(spec)
|
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
|
||||||
# The module is always executed and not cached in sys.modules.
|
module = importlib.util.module_from_spec(spec)
|
||||||
# Uncomment the following line to cache the module.
|
# The module is always executed and not cached in sys.modules.
|
||||||
# sys.modules[module.__name__] = module
|
# Uncomment the following line to cache the module.
|
||||||
loader.exec_module(module)
|
# sys.modules[module.__name__] = module
|
||||||
return module
|
loader.exec_module(module)
|
||||||
|
return module
|
||||||
|
else:
|
||||||
|
from imp import load_source
|
||||||
|
|
||||||
import os, json
|
import os, json
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user