mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 13:53:15 -07:00
Updates vendored setuptools to 44.1.1
This commit is contained in:
parent
3a2e09c26e
commit
d8da02cb69
55 changed files with 2910 additions and 1457 deletions
|
@ -1,11 +1,13 @@
|
|||
import sys
|
||||
import imp
|
||||
import marshal
|
||||
import contextlib
|
||||
from distutils.version import StrictVersion
|
||||
from imp import PKG_DIRECTORY, PY_COMPILED, PY_SOURCE, PY_FROZEN
|
||||
|
||||
from .py33compat import Bytecode
|
||||
|
||||
from .py27compat import find_module, PY_COMPILED, PY_FROZEN, PY_SOURCE
|
||||
from . import py27compat
|
||||
|
||||
|
||||
__all__ = [
|
||||
'Require', 'find_module', 'get_module_constant', 'extract_constant'
|
||||
|
@ -15,7 +17,8 @@ __all__ = [
|
|||
class Require:
|
||||
"""A prerequisite to building or installing a distribution"""
|
||||
|
||||
def __init__(self, name, requested_version, module, homepage='',
|
||||
def __init__(
|
||||
self, name, requested_version, module, homepage='',
|
||||
attribute=None, format=None):
|
||||
|
||||
if format is None and requested_version is not None:
|
||||
|
@ -79,23 +82,15 @@ class Require:
|
|||
return self.version_ok(version)
|
||||
|
||||
|
||||
def find_module(module, paths=None):
|
||||
"""Just like 'imp.find_module()', but with package support"""
|
||||
def maybe_close(f):
|
||||
@contextlib.contextmanager
|
||||
def empty():
|
||||
yield
|
||||
return
|
||||
if not f:
|
||||
return empty()
|
||||
|
||||
parts = module.split('.')
|
||||
|
||||
while parts:
|
||||
part = parts.pop(0)
|
||||
f, path, (suffix, mode, kind) = info = imp.find_module(part, paths)
|
||||
|
||||
if kind == PKG_DIRECTORY:
|
||||
parts = parts or ['__init__']
|
||||
paths = [path]
|
||||
|
||||
elif parts:
|
||||
raise ImportError("Can't find %r in %s" % (parts, module))
|
||||
|
||||
return info
|
||||
return contextlib.closing(f)
|
||||
|
||||
|
||||
def get_module_constant(module, symbol, default=-1, paths=None):
|
||||
|
@ -106,28 +101,23 @@ def get_module_constant(module, symbol, default=-1, paths=None):
|
|||
constant. Otherwise, return 'default'."""
|
||||
|
||||
try:
|
||||
f, path, (suffix, mode, kind) = find_module(module, paths)
|
||||
f, path, (suffix, mode, kind) = info = find_module(module, paths)
|
||||
except ImportError:
|
||||
# Module doesn't exist
|
||||
return None
|
||||
|
||||
try:
|
||||
with maybe_close(f):
|
||||
if kind == PY_COMPILED:
|
||||
f.read(8) # skip magic & date
|
||||
code = marshal.load(f)
|
||||
elif kind == PY_FROZEN:
|
||||
code = imp.get_frozen_object(module)
|
||||
code = py27compat.get_frozen_object(module, paths)
|
||||
elif kind == PY_SOURCE:
|
||||
code = compile(f.read(), path, 'exec')
|
||||
else:
|
||||
# Not something we can parse; we'll have to import it. :(
|
||||
if module not in sys.modules:
|
||||
imp.load_module(module, f, path, (suffix, mode, kind))
|
||||
return getattr(sys.modules[module], symbol, None)
|
||||
|
||||
finally:
|
||||
if f:
|
||||
f.close()
|
||||
imported = py27compat.get_module(module, paths, info)
|
||||
return getattr(imported, symbol, None)
|
||||
|
||||
return extract_constant(code, symbol, default)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue