Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
e6e3b8df
Commit
e6e3b8df
authored
May 17, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modernize syntax
--HG-- extra : amend_source : eeaee0372ea8d1d39475a722234c03f6a0247722
parent
7c471a14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
59 deletions
+16
-59
setuptools/depends.py
setuptools/depends.py
+16
-59
No files found.
setuptools/depends.py
View file @
e6e3b8df
from
__future__
import
generators
import
sys
,
imp
,
marshal
import
sys
import
imp
import
marshal
from
imp
import
PKG_DIRECTORY
,
PY_COMPILED
,
PY_SOURCE
,
PY_FROZEN
from
distutils.version
import
StrictVersion
,
LooseVersion
from
distutils.version
import
StrictVersion
__all__
=
[
'Require'
,
'find_module'
,
'get_module_constant'
,
'extract_constant'
...
...
@@ -10,9 +11,8 @@ __all__ = [
class
Require
:
"""A prerequisite to building or installing a distribution"""
def
__init__
(
self
,
name
,
requested_version
,
module
,
homepage
=
''
,
attribute
=
None
,
format
=
None
):
def
__init__
(
self
,
name
,
requested_version
,
module
,
homepage
=
''
,
attribute
=
None
,
format
=
None
):
if
format
is
None
and
requested_version
is
not
None
:
format
=
StrictVersion
...
...
@@ -25,20 +25,17 @@ class Require:
self
.
__dict__
.
update
(
locals
())
del
self
.
self
def
full_name
(
self
):
"""Return full package/distribution name, w/version"""
if
self
.
requested_version
is
not
None
:
return
'%s-%s'
%
(
self
.
name
,
self
.
requested_version
)
return
self
.
name
def
version_ok
(
self
,
version
):
def
version_ok
(
self
,
version
):
"""Is 'version' sufficiently up-to-date?"""
return
self
.
attribute
is
None
or
self
.
format
is
None
or
\
str
(
version
)
!=
"unknown"
and
version
>=
self
.
requested_version
def
get_version
(
self
,
paths
=
None
,
default
=
"unknown"
):
"""Get version number of installed module, 'None', or 'default'
...
...
@@ -59,20 +56,18 @@ class Require:
except
ImportError
:
return
None
v
=
get_module_constant
(
self
.
module
,
self
.
attribute
,
default
,
paths
)
v
=
get_module_constant
(
self
.
module
,
self
.
attribute
,
default
,
paths
)
if
v
is
not
None
and
v
is
not
default
and
self
.
format
is
not
None
:
return
self
.
format
(
v
)
return
v
def
is_present
(
self
,
paths
=
None
):
def
is_present
(
self
,
paths
=
None
):
"""Return true if dependency is present on 'paths'"""
return
self
.
get_version
(
paths
)
is
not
None
def
is_current
(
self
,
paths
=
None
):
def
is_current
(
self
,
paths
=
None
):
"""Return true if dependency is present and up-to-date on 'paths'"""
version
=
self
.
get_version
(
paths
)
if
version
is
None
:
...
...
@@ -113,14 +108,6 @@ def _iter_code(code):
yield
op
,
arg
def
find_module
(
module
,
paths
=
None
):
"""Just like 'imp.find_module()', but with package support"""
...
...
@@ -140,28 +127,6 @@ def find_module(module, paths=None):
return
info
def
get_module_constant
(
module
,
symbol
,
default
=-
1
,
paths
=
None
):
"""Find 'module' by searching 'paths', and extract 'symbol'
...
...
@@ -171,7 +136,7 @@ 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
)
=
find_module
(
module
,
paths
)
except
ImportError
:
# Module doesn't exist
return
None
...
...
@@ -187,23 +152,17 @@ def get_module_constant(module, symbol, default=-1, paths=None):
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
)
imp
.
load_module
(
module
,
f
,
path
,
(
suffix
,
mode
,
kind
))
return
getattr
(
sys
.
modules
[
module
],
symbol
,
None
)
finally
:
if
f
:
f
.
close
()
return
extract_constant
(
code
,
symbol
,
default
)
return
extract_constant
(
code
,
symbol
,
default
)
def
extract_constant
(
code
,
symbol
,
default
=-
1
):
def
extract_constant
(
code
,
symbol
,
default
=-
1
):
"""Extract the constant value of 'symbol' from 'code'
If the name 'symbol' is bound to a constant value by the Python code
...
...
@@ -236,11 +195,9 @@ def extract_constant(code,symbol,default=-1):
return
const
else
:
const
=
default
if
sys
.
platform
.
startswith
(
'java'
)
or
sys
.
platform
==
'cli'
:
# XXX it'd be better to test assertions about bytecode instead...
del
extract_constant
,
get_module_constant
__all__
.
remove
(
'extract_constant'
)
__all__
.
remove
(
'get_module_constant'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment