mirror of
https://github.com/niess/python-appimage.git
synced 2026-03-14 12:20:14 +01:00
Python 2 compat for local requirements
(cherry picked from commit c34610e63cc9b509d324bc0ffb09c100063af74e)
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
__all__ = ['decode']
|
||||
import sys
|
||||
|
||||
|
||||
__all__ = ['decode', 'find_spec', 'isolation_flag']
|
||||
|
||||
|
||||
def decode(s):
|
||||
@@ -8,3 +11,21 @@ def decode(s):
|
||||
return s.decode()
|
||||
except Exception:
|
||||
return str(s)
|
||||
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
from collections import namedtuple
|
||||
import imp
|
||||
|
||||
ModuleSpec = namedtuple('ModuleSpec', ('name', 'origin'))
|
||||
|
||||
def find_spec(name):
|
||||
return ModuleSpec(name, imp.find_module(name)[1])
|
||||
|
||||
isolation_flag = '-sE'
|
||||
|
||||
else:
|
||||
import importlib
|
||||
find_spec = importlib.util.find_spec
|
||||
|
||||
isolation_flag = '-I'
|
||||
|
||||
Reference in New Issue
Block a user