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
c405c109
Commit
c405c109
authored
Jul 13, 2016
by
Jason R. Coombs
Committed by
GitHub
Jul 13, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #634 from stepshal/whitespace
Add missing whitespace.
parents
45de6ea8
f749ccab
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
190 additions
and
190 deletions
+190
-190
setuptools/archive_util.py
setuptools/archive_util.py
+1
-1
setuptools/depends.py
setuptools/depends.py
+6
-6
setuptools/dist.py
setuptools/dist.py
+68
-68
setuptools/package_index.py
setuptools/package_index.py
+37
-37
setuptools/py26compat.py
setuptools/py26compat.py
+1
-1
setuptools/sandbox.py
setuptools/sandbox.py
+34
-34
setuptools/site-patch.py
setuptools/site-patch.py
+5
-5
setuptools/tests/__init__.py
setuptools/tests/__init__.py
+36
-36
setuptools/tests/contexts.py
setuptools/tests/contexts.py
+1
-1
setuptools/tests/test_find_packages.py
setuptools/tests/test_find_packages.py
+1
-1
No files found.
setuptools/archive_util.py
View file @
c405c109
...
...
@@ -20,7 +20,7 @@ class UnrecognizedFormat(DistutilsError):
"""Couldn't recognize the archive type"""
def
default_filter
(
src
,
dst
):
def
default_filter
(
src
,
dst
):
"""The default progress/filter callback; returns True for all files"""
return
dst
...
...
setuptools/depends.py
View file @
c405c109
...
...
@@ -31,7 +31,7 @@ class Require:
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
'%s-%s'
%
(
self
.
name
,
self
.
requested_version
)
return
self
.
name
def
version_ok
(
self
,
version
):
...
...
@@ -52,7 +52,7 @@ class Require:
if
self
.
attribute
is
None
:
try
:
f
,
p
,
i
=
find_module
(
self
.
module
,
paths
)
f
,
p
,
i
=
find_module
(
self
.
module
,
paths
)
if
f
:
f
.
close
()
return
default
except
ImportError
:
...
...
@@ -83,7 +83,7 @@ def _iter_code(code):
from
array
import
array
from
dis
import
HAVE_ARGUMENT
,
EXTENDED_ARG
bytes
=
array
(
'b'
,
code
.
co_code
)
bytes
=
array
(
'b'
,
code
.
co_code
)
eof
=
len
(
code
.
co_code
)
ptr
=
0
...
...
@@ -107,7 +107,7 @@ def _iter_code(code):
arg
=
None
ptr
+=
1
yield
op
,
arg
yield
op
,
arg
def
find_module
(
module
,
paths
=
None
):
...
...
@@ -117,14 +117,14 @@ def find_module(module, paths=None):
while
parts
:
part
=
parts
.
pop
(
0
)
f
,
path
,
(
suffix
,
mode
,
kind
)
=
info
=
imp
.
find_module
(
part
,
paths
)
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
))
raise
ImportError
(
"Can't find %r in %s"
%
(
parts
,
module
))
return
info
...
...
setuptools/dist.py
View file @
c405c109
...
...
@@ -67,10 +67,10 @@ def check_importable(dist, attr, value):
try
:
ep
=
pkg_resources
.
EntryPoint
.
parse
(
'x='
+
value
)
assert
not
ep
.
extras
except
(
TypeError
,
ValueError
,
AttributeError
,
AssertionError
):
except
(
TypeError
,
ValueError
,
AttributeError
,
AssertionError
):
raise
DistutilsSetupError
(
"%r must be importable 'module:attrs' string (got %r)"
%
(
attr
,
value
)
%
(
attr
,
value
)
)
...
...
@@ -78,15 +78,15 @@ def assert_string_list(dist, attr, value):
"""Verify that value is a string list or None"""
try
:
assert
''
.
join
(
value
)
!=
value
except
(
TypeError
,
ValueError
,
AttributeError
,
AssertionError
):
except
(
TypeError
,
ValueError
,
AttributeError
,
AssertionError
):
raise
DistutilsSetupError
(
"%r must be a list of strings (got %r)"
%
(
attr
,
value
)
"%r must be a list of strings (got %r)"
%
(
attr
,
value
)
)
def
check_nsp
(
dist
,
attr
,
value
):
"""Verify that namespace packages are valid"""
assert_string_list
(
dist
,
attr
,
value
)
assert_string_list
(
dist
,
attr
,
value
)
for
nsp
in
value
:
if
not
dist
.
has_contents_for
(
nsp
):
raise
DistutilsSetupError
(
...
...
@@ -105,13 +105,13 @@ def check_nsp(dist, attr, value):
def
check_extras
(
dist
,
attr
,
value
):
"""Verify that extras_require mapping is valid"""
try
:
for
k
,
v
in
value
.
items
():
for
k
,
v
in
value
.
items
():
if
':'
in
k
:
k
,
m
=
k
.
split
(
':'
,
1
)
k
,
m
=
k
.
split
(
':'
,
1
)
if
pkg_resources
.
invalid_marker
(
m
):
raise
DistutilsSetupError
(
"Invalid environment marker: "
+
m
)
list
(
pkg_resources
.
parse_requirements
(
v
))
except
(
TypeError
,
ValueError
,
AttributeError
):
except
(
TypeError
,
ValueError
,
AttributeError
):
raise
DistutilsSetupError
(
"'extras_require' must be a dictionary whose values are "
"strings or lists of strings containing valid project/version "
...
...
@@ -153,9 +153,9 @@ def check_test_suite(dist, attr, value):
def
check_package_data
(
dist
,
attr
,
value
):
"""Verify that value is a dictionary of package names to glob lists"""
if
isinstance
(
value
,
dict
):
for
k
,
v
in
value
.
items
():
if
not
isinstance
(
k
,
str
):
break
if
isinstance
(
value
,
dict
):
for
k
,
v
in
value
.
items
():
if
not
isinstance
(
k
,
str
):
break
try
:
iter
(
v
)
except
TypeError
:
break
...
...
@@ -274,12 +274,12 @@ class Distribution(_Distribution):
# Make sure we have any eggs needed to interpret '
attrs
'
if attrs is not None:
self.dependency_links = attrs.pop('
dependency_links
', [])
assert_string_list(self,
'
dependency_links
',
self.dependency_links)
assert_string_list(self,
'
dependency_links
',
self.dependency_links)
if attrs and '
setup_requires
' in attrs:
self.fetch_build_eggs(attrs['
setup_requires
'])
for ep in pkg_resources.iter_entry_points('
distutils
.
setup_keywords
'):
vars(self).setdefault(ep.name, None)
_Distribution.__init__(self,attrs)
_Distribution.__init__(self,
attrs)
if isinstance(self.metadata.version, numbers.Number):
# Some people apparently take "version number" too literally :)
self.metadata.version = str(self.metadata.version)
...
...
@@ -311,9 +311,9 @@ class Distribution(_Distribution):
self._finalize_features()
return result
def _feature_attrname(self,name):
def _feature_attrname(self,
name):
"""Convert feature name to corresponding option attribute name"""
return '
with_
'+name.replace('
-
','
_
')
return '
with_
'+name.replace('
-
',
'
_
')
def fetch_build_eggs(self, requires):
"""Resolve pre-setup requirements"""
...
...
@@ -331,7 +331,7 @@ class Distribution(_Distribution):
self._set_global_opts_from_features()
for ep in pkg_resources.iter_entry_points('
distutils
.
setup_keywords
'):
value = getattr(self,
ep.name,
None)
value = getattr(self,
ep.name,
None)
if value is not None:
ep.require(installer=self.fetch_build_egg)
ep.load()(self, ep.name, value)
...
...
@@ -364,7 +364,7 @@ class Distribution(_Distribution):
cmd.package_index.to_scan = []
except AttributeError:
from setuptools.command.easy_install import easy_install
dist = self.__class__({'
script_args
':['
easy_install
']})
dist = self.__class__({'
script_args
':
['
easy_install
']})
dist.parse_config_files()
opts = dist.get_option_dict('
easy_install
')
keep = (
...
...
@@ -395,8 +395,8 @@ class Distribution(_Distribution):
go
=
[]
no
=
self
.
negative_opt
.
copy
()
for
name
,
feature
in
self
.
features
.
items
():
self
.
_set_feature
(
name
,
None
)
for
name
,
feature
in
self
.
features
.
items
():
self
.
_set_feature
(
name
,
None
)
feature
.
validate
(
self
)
if
feature
.
optional
:
...
...
@@ -417,25 +417,25 @@ class Distribution(_Distribution):
"""Add/remove features and resolve dependencies between them"""
# First, flag all the enabled items (and thus their dependencies)
for
name
,
feature
in
self
.
features
.
items
():
for
name
,
feature
in
self
.
features
.
items
():
enabled
=
self
.
feature_is_included
(
name
)
if
enabled
or
(
enabled
is
None
and
feature
.
include_by_default
()):
feature
.
include_in
(
self
)
self
.
_set_feature
(
name
,
1
)
self
.
_set_feature
(
name
,
1
)
# Then disable the rest, so that off-by-default features don't
# get flagged as errors when they're required by an enabled feature
for
name
,
feature
in
self
.
features
.
items
():
for
name
,
feature
in
self
.
features
.
items
():
if
not
self
.
feature_is_included
(
name
):
feature
.
exclude_from
(
self
)
self
.
_set_feature
(
name
,
0
)
self
.
_set_feature
(
name
,
0
)
def
get_command_class
(
self
,
command
):
"""Pluggable version of get_command_class()"""
if
command
in
self
.
cmdclass
:
return
self
.
cmdclass
[
command
]
for
ep
in
pkg_resources
.
iter_entry_points
(
'distutils.commands'
,
command
):
for
ep
in
pkg_resources
.
iter_entry_points
(
'distutils.commands'
,
command
):
ep
.
require
(
installer
=
self
.
fetch_build_egg
)
self
.
cmdclass
[
command
]
=
cmdclass
=
ep
.
load
()
return
cmdclass
...
...
@@ -458,15 +458,15 @@ class Distribution(_Distribution):
self
.
cmdclass
[
ep
.
name
]
=
cmdclass
return
_Distribution
.
get_command_list
(
self
)
def
_set_feature
(
self
,
name
,
status
):
def
_set_feature
(
self
,
name
,
status
):
"""Set feature's inclusion status"""
setattr
(
self
,
self
.
_feature_attrname
(
name
),
status
)
setattr
(
self
,
self
.
_feature_attrname
(
name
),
status
)
def
feature_is_included
(
self
,
name
):
def
feature_is_included
(
self
,
name
):
"""Return 1 if feature is included, 0 if excluded, 'None' if unknown"""
return
getattr
(
self
,
self
.
_feature_attrname
(
name
))
return
getattr
(
self
,
self
.
_feature_attrname
(
name
))
def
include_feature
(
self
,
name
):
def
include_feature
(
self
,
name
):
"""Request inclusion of feature named 'name'"""
if
self
.
feature_is_included
(
name
)
==
0
:
...
...
@@ -475,9 +475,9 @@ class Distribution(_Distribution):
descr
+
" is required, but was excluded or is not available"
)
self
.
features
[
name
].
include_in
(
self
)
self
.
_set_feature
(
name
,
1
)
self
.
_set_feature
(
name
,
1
)
def
include
(
self
,
**
attrs
):
def
include
(
self
,
**
attrs
):
"""Add items to distribution that are named in keyword arguments
For example, 'dist.exclude(py_modules=["x"])' would add 'x' to
...
...
@@ -492,14 +492,14 @@ class Distribution(_Distribution):
will try to call 'dist._include_foo({"bar":"baz"})', which can then
handle whatever special inclusion logic is needed.
"""
for
k
,
v
in
attrs
.
items
():
for
k
,
v
in
attrs
.
items
():
include
=
getattr
(
self
,
'_include_'
+
k
,
None
)
if
include
:
include
(
v
)
else
:
self
.
_include_misc
(
k
,
v
)
self
.
_include_misc
(
k
,
v
)
def
exclude_package
(
self
,
package
):
def
exclude_package
(
self
,
package
):
"""Remove packages, modules, and extensions in named package"""
pfx
=
package
+
'.'
...
...
@@ -521,7 +521,7 @@ class Distribution(_Distribution):
if
p
.
name
!=
package
and
not
p
.
name
.
startswith
(
pfx
)
]
def
has_contents_for
(
self
,
package
):
def
has_contents_for
(
self
,
package
):
"""Return true if 'exclude_package(package)' would do something"""
pfx
=
package
+
'.'
...
...
@@ -530,48 +530,48 @@ class Distribution(_Distribution):
if
p
==
package
or
p
.
startswith
(
pfx
):
return
True
def
_exclude_misc
(
self
,
name
,
value
):
def
_exclude_misc
(
self
,
name
,
value
):
"""Handle 'exclude()' for list/tuple attrs without a special handler"""
if
not
isinstance
(
value
,
sequence
):
if
not
isinstance
(
value
,
sequence
):
raise
DistutilsSetupError
(
"%s: setting must be a list or tuple (%r)"
%
(
name
,
value
)
)
try
:
old
=
getattr
(
self
,
name
)
old
=
getattr
(
self
,
name
)
except
AttributeError
:
raise
DistutilsSetupError
(
"%s: No such distribution setting"
%
name
)
if
old
is
not
None
and
not
isinstance
(
old
,
sequence
):
if
old
is
not
None
and
not
isinstance
(
old
,
sequence
):
raise
DistutilsSetupError
(
name
+
": this setting cannot be changed via include/exclude"
)
elif
old
:
setattr
(
self
,
name
,
[
item
for
item
in
old
if
item
not
in
value
])
setattr
(
self
,
name
,
[
item
for
item
in
old
if
item
not
in
value
])
def
_include_misc
(
self
,
name
,
value
):
def
_include_misc
(
self
,
name
,
value
):
"""Handle 'include()' for list/tuple attrs without a special handler"""
if
not
isinstance
(
value
,
sequence
):
if
not
isinstance
(
value
,
sequence
):
raise
DistutilsSetupError
(
"%s: setting must be a list (%r)"
%
(
name
,
value
)
)
try
:
old
=
getattr
(
self
,
name
)
old
=
getattr
(
self
,
name
)
except
AttributeError
:
raise
DistutilsSetupError
(
"%s: No such distribution setting"
%
name
)
if
old
is
None
:
setattr
(
self
,
name
,
value
)
elif
not
isinstance
(
old
,
sequence
):
setattr
(
self
,
name
,
value
)
elif
not
isinstance
(
old
,
sequence
):
raise
DistutilsSetupError
(
name
+
": this setting cannot be changed via include/exclude"
)
else
:
setattr
(
self
,
name
,
old
+
[
item
for
item
in
value
if
item
not
in
old
])
setattr
(
self
,
name
,
old
+
[
item
for
item
in
value
if
item
not
in
old
])
def
exclude
(
self
,
**
attrs
):
def
exclude
(
self
,
**
attrs
):
"""Remove items from distribution that are named in keyword arguments
For example, 'dist.exclude(py_modules=["x"])' would remove 'x' from
...
...
@@ -587,15 +587,15 @@ class Distribution(_Distribution):
will try to call 'dist._exclude_foo({"bar":"baz"})', which can then
handle whatever special exclusion logic is needed.
"""
for
k
,
v
in
attrs
.
items
():
for
k
,
v
in
attrs
.
items
():
exclude
=
getattr
(
self
,
'_exclude_'
+
k
,
None
)
if
exclude
:
exclude
(
v
)
else
:
self
.
_exclude_misc
(
k
,
v
)
self
.
_exclude_misc
(
k
,
v
)
def
_exclude_packages
(
self
,
packages
):
if
not
isinstance
(
packages
,
sequence
):
def
_exclude_packages
(
self
,
packages
):
if
not
isinstance
(
packages
,
sequence
):
raise
DistutilsSetupError
(
"packages: setting must be a list or tuple (%r)"
%
(
packages
,)
)
...
...
@@ -610,17 +610,17 @@ class Distribution(_Distribution):
command
=
args
[
0
]
aliases
=
self
.
get_option_dict
(
'aliases'
)
while
command
in
aliases
:
src
,
alias
=
aliases
[
command
]
src
,
alias
=
aliases
[
command
]
del
aliases
[
command
]
# ensure each alias can expand only once!
import
shlex
args
[:
1
]
=
shlex
.
split
(
alias
,
True
)
args
[:
1
]
=
shlex
.
split
(
alias
,
True
)
command
=
args
[
0
]
nargs
=
_Distribution
.
_parse_command_opts
(
self
,
parser
,
args
)
# Handle commands that want to consume all remaining arguments
cmd_class
=
self
.
get_command_class
(
command
)
if
getattr
(
cmd_class
,
'command_consumes_arguments'
,
None
):
if
getattr
(
cmd_class
,
'command_consumes_arguments'
,
None
):
self
.
get_option_dict
(
command
)[
'args'
]
=
(
"command line"
,
nargs
)
if
nargs
is
not
None
:
return
[]
...
...
@@ -639,20 +639,20 @@ class Distribution(_Distribution):
d
=
{}
for
cmd
,
opts
in
self
.
command_options
.
items
():
for
cmd
,
opts
in
self
.
command_options
.
items
():
for
opt
,
(
src
,
val
)
in
opts
.
items
():
for
opt
,
(
src
,
val
)
in
opts
.
items
():
if
src
!=
"command line"
:
continue
opt
=
opt
.
replace
(
'_'
,
'-'
)
opt
=
opt
.
replace
(
'_'
,
'-'
)
if
val
==
0
:
cmdobj
=
self
.
get_command_obj
(
cmd
)
neg_opt
=
self
.
negative_opt
.
copy
()
neg_opt
.
update
(
getattr
(
cmdobj
,
'negative_opt'
,
{}))
for
neg
,
pos
in
neg_opt
.
items
():
neg_opt
.
update
(
getattr
(
cmdobj
,
'negative_opt'
,
{}))
for
neg
,
pos
in
neg_opt
.
items
():
if
pos
==
opt
:
opt
=
neg
val
=
None
...
...
@@ -663,7 +663,7 @@ class Distribution(_Distribution):
elif
val
==
1
:
val
=
None
d
.
setdefault
(
cmd
,{})[
opt
]
=
val
d
.
setdefault
(
cmd
,
{})[
opt
]
=
val
return
d
...
...
@@ -677,7 +677,7 @@ class Distribution(_Distribution):
yield
module
for
ext
in
self
.
ext_modules
or
():
if
isinstance
(
ext
,
tuple
):
if
isinstance
(
ext
,
tuple
):
name
,
buildinfo
=
ext
else
:
name
=
ext
.
name
...
...
@@ -800,16 +800,16 @@ class Feature:
self
.
standard
=
standard
self
.
available
=
available
self
.
optional
=
optional
if
isinstance
(
require_features
,
(
str
,
Require
)):
if
isinstance
(
require_features
,
(
str
,
Require
)):
require_features
=
require_features
,
self
.
require_features
=
[
r
for
r
in
require_features
if
isinstance
(
r
,
str
)
r
for
r
in
require_features
if
isinstance
(
r
,
str
)
]
er
=
[
r
for
r
in
require_features
if
not
isinstance
(
r
,
str
)]
er
=
[
r
for
r
in
require_features
if
not
isinstance
(
r
,
str
)]
if
er
:
extras
[
'require_features'
]
=
er
if
isinstance
(
remove
,
str
):
if
isinstance
(
remove
,
str
):
remove
=
remove
,
self
.
remove
=
remove
self
.
extras
=
extras
...
...
@@ -824,7 +824,7 @@ class Feature:
"""Should this feature be included by default?"""
return
self
.
available
and
self
.
standard
def
include_in
(
self
,
dist
):
def
include_in
(
self
,
dist
):
"""Ensure feature and its requirements are included in distribution
You may override this in a subclass to perform additional operations on
...
...
@@ -844,7 +844,7 @@ class Feature:
for
f
in
self
.
require_features
:
dist
.
include_feature
(
f
)
def
exclude_from
(
self
,
dist
):
def
exclude_from
(
self
,
dist
):
"""Ensure feature is excluded from distribution
You may override this in a subclass to perform additional operations on
...
...
@@ -859,7 +859,7 @@ class Feature:
for
item
in
self
.
remove
:
dist
.
exclude_package
(
item
)
def
validate
(
self
,
dist
):
def
validate
(
self
,
dist
):
"""Verify that feature makes sense in context of distribution
This method is called by the distribution just before it parses its
...
...
setuptools/package_index.py
View file @
c405c109
...
...
@@ -37,7 +37,7 @@ PYPI_MD5 = re.compile(
'<a href="([^"#]+)">([^<]+)</a>
\
n
\
s+
\
\
(<
a
(?:title="MD5 hash"
\
n
\
s+)
'
'
href
=
"[^?]+
\
?:
a
ction=show_md5&digest=([0-9a-f]{32})"
>
md5
</
a
>
\\
)
'
)
URL_SCHEME = re.compile('
([
-+
.
a
-
z0
-
9
]{
2
,}):
',re.I).match
URL_SCHEME = re.compile('
([
-+
.
a
-
z0
-
9
]{
2
,}):
',
re.I).match
EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split()
__all__ = [
...
...
@@ -62,18 +62,18 @@ def parse_bdist_wininst(name):
if lower.endswith('
.
win32
.
exe
'):
base = name[:-10]
plat = '
win32
'
elif lower.startswith('
.
win32
-
py
',-16):
elif lower.startswith('
.
win32
-
py
',
-16):
py_ver = name[-7:-4]
base = name[:-16]
plat = '
win32
'
elif lower.endswith('
.
win
-
amd64
.
exe
'):
base = name[:-14]
plat = '
win
-
amd64
'
elif lower.startswith('
.
win
-
amd64
-
py
',-20):
elif lower.startswith('
.
win
-
amd64
-
py
',
-20):
py_ver = name[-7:-4]
base = name[:-20]
plat = '
win
-
amd64
'
return base,
py_ver,
plat
return base,
py_ver,
plat
def egg_info_for_url(url):
...
...
@@ -82,8 +82,8 @@ def egg_info_for_url(url):
base = urllib.parse.unquote(path.split('
/
')[-1])
if server=='
sourceforge
.
net
' and base=='
download
': # XXX Yuck
base = urllib.parse.unquote(path.split('
/
')[-2])
if '
#' in base: base, fragment = base.split('#',1)
return
base
,
fragment
if '
#' in base: base, fragment = base.split('#',
1)
return
base
,
fragment
def
distros_for_url
(
url
,
metadata
=
None
):
...
...
@@ -155,7 +155,7 @@ def interpret_distro_name(
# it is a bdist_dumb, not an sdist -- bail out
return
for p in range(1,len(parts)+1):
for p in range(1,
len(parts)+1):
yield Distribution(
location, metadata, '
-
'.join(parts[:p]), '
-
'.join(parts[p:]),
py_version=py_version, precedence = precedence,
...
...
@@ -209,7 +209,7 @@ def find_external_links(url, page):
for tag in ("<th>Home Page", "<th>Download URL"):
pos = page.find(tag)
if pos!=-1:
match = HREF.search(page,pos)
match = HREF.search(page,
pos)
if match:
yield urllib.parse.urljoin(url, htmldecode(match.group(1)))
...
...
@@ -279,12 +279,12 @@ class PackageIndex(Environment):
self, index_url="https://pypi.python.org/simple", hosts=('*',),
ca_bundle=None, verify_ssl=True, *args, **kw
):
Environment.__init__(self,
*args,
**kw)
Environment.__init__(self,
*args,
**kw)
self.index_url = index_url + "/"[:not index_url.endswith('/')]
self.scanned_urls = {}
self.fetched_urls = {}
self.package_pages = {}
self.allows = re.compile('|'.join(map(translate,hosts))).match
self.allows = re.compile('|'.join(map(translate,
hosts))).match
self.to_scan = []
if verify_ssl and ssl_support.is_available and (ca_bundle or ssl_support.find_ca_bundle()):
self.opener = ssl_support.opener_for(ca_bundle)
...
...
@@ -335,7 +335,7 @@ class PackageIndex(Environment):
for match in HREF.finditer(page):
link = urllib.parse.urljoin(base, htmldecode(match.group(1)))
self.process_url(link)
if url.startswith(self.index_url) and getattr(f,
'code',
None)!=404:
if url.startswith(self.index_url) and getattr(f,
'code',
None)!=404:
page = self.process_index(url, page)
def process_filename(self, fn, nested=False):
...
...
@@ -347,7 +347,7 @@ class PackageIndex(Environment):
if os.path.isdir(fn) and not nested:
path = os.path.realpath(fn)
for item in os.listdir(path):
self.process_filename(os.path.join(path,item), True)
self.process_filename(os.path.join(path,
item), True)
dists = distros_for_filename(fn)
if dists:
...
...
@@ -391,7 +391,7 @@ class PackageIndex(Environment):
dist.precedence = SOURCE_DIST
self.add(dist)
def process_index(self,
url,
page):
def process_index(self,
url,
page):
"""
Process
the
contents
of
a
PyPI
page
"""
def scan(link):
# Process a URL to see if it's for a package page
...
...
@@ -403,7 +403,7 @@ class PackageIndex(Environment):
# it's a package page, sanitize and index it
pkg = safe_name(parts[0])
ver = safe_version(parts[1])
self.package_pages.setdefault(pkg.lower(),{})[link] = True
self.package_pages.setdefault(pkg.lower(),
{})[link] = True
return to_filename(pkg), to_filename(ver)
return None, None
...
...
@@ -422,13 +422,13 @@ class PackageIndex(Environment):
base, frag = egg_info_for_url(new_url)
if base.endswith('.py') and not frag:
if ver:
new_url+='#egg=%s-%s' % (pkg,ver)
new_url+='#egg=%s-%s' % (pkg,
ver)
else:
self.need_version_info(url)
self.scan_url(new_url)
return PYPI_MD5.sub(
lambda m: '<a href="%s#md5=%s">%s</a>' % m.group(1,
3,
2), page
lambda m: '<a href="%s#md5=%s">%s</a>' % m.group(1,
3,
2), page
)
else:
return "" # no sense double-scanning non-package pages
...
...
@@ -441,7 +441,7 @@ class PackageIndex(Environment):
def scan_all(self, msg=None, *args):
if self.index_url not in self.fetched_urls:
if msg: self.warn(msg,*args)
if msg: self.warn(msg,
*args)
self.info(
"Scanning index of all packages (this may take a while)"
)
...
...
@@ -458,7 +458,7 @@ class PackageIndex(Environment):
# We couldn't find the target package, so search the index page too
self.not_found_in_index(requirement)
for url in list(self.package_pages.get(requirement.key,())):
for url in list(self.package_pages.get(requirement.key,
())):
# scan each page that might be related to the desired package
self.scan_url(url)
...
...
@@ -469,7 +469,7 @@ class PackageIndex(Environment):
if dist in requirement:
return dist
self.debug("%s does not match %s", requirement, dist)
return super(PackageIndex, self).obtain(requirement,installer)
return super(PackageIndex, self).obtain(requirement,
installer)
def check_hash(self, checker, filename, tfp):
"""
...
...
@@ -534,14 +534,14 @@ class PackageIndex(Environment):
of
`tmpdir`
,
and
the
local
filename
is
returned
.
Various
errors
may
be
raised
if
a
problem
occurs
during
downloading
.
"""
if not isinstance(spec,Requirement):
if not isinstance(spec,
Requirement):
scheme = URL_SCHEME(spec)
if scheme:
# It's a url, download it to tmpdir
found = self._download_url(scheme.group(1), spec, tmpdir)
base, fragment = egg_info_for_url(spec)
if base.endswith('.py'):
found = self.gen_setup(found,
fragment,
tmpdir)
found = self.gen_setup(found,
fragment,
tmpdir)
return found
elif os.path.exists(spec):
# Existing file or directory, just return it
...
...
@@ -554,7 +554,7 @@ class PackageIndex(Environment):
"Not a URL, existing file, or requirement spec: %r" %
(spec,)
)
return getattr(self.fetch_distribution(spec, tmpdir),
'location',
None)
return getattr(self.fetch_distribution(spec, tmpdir),
'location',
None)
def fetch_distribution(
self, requirement, tmpdir, force_scan=False, source=False,
...
...
@@ -590,7 +590,7 @@ class PackageIndex(Environment):
if dist.precedence==DEVELOP_DIST and not develop_ok:
if dist not in skipped:
self.warn("Skipping development or system egg: %s",dist)
self.warn("Skipping development or system egg: %s",
dist)
skipped[dist] = 1
continue
...
...
@@ -632,7 +632,7 @@ class PackageIndex(Environment):
``
location
``
of
the
downloaded
distribution
instead
of
a
distribution
object
.
"""
dist = self.fetch_distribution(requirement,
tmpdir,force_scan,
source)
dist = self.fetch_distribution(requirement,
tmpdir, force_scan,
source)
if dist is not None:
return dist.location
return None
...
...
@@ -670,7 +670,7 @@ class PackageIndex(Environment):
raise DistutilsError(
"Can't unambiguously interpret project/version identifier %r; "
"any dashes in the name or version should be escaped using "
"underscores. %r" % (fragment,dists)
"underscores. %r" % (fragment,
dists)
)
else:
raise DistutilsError(
...
...
@@ -689,7 +689,7 @@ class PackageIndex(Environment):
fp = self.open_url(strip_fragment(url))
if isinstance(fp, urllib.error.HTTPError):
raise DistutilsError(
"Can't download %s: %s %s" % (url, fp.code,fp.msg)
"Can't download %s: %s %s" % (url, fp.code,
fp.msg)
)
headers = fp.info()
blocknum = 0
...
...
@@ -700,7 +700,7 @@ class PackageIndex(Environment):
sizes = get_all_headers(headers, 'Content-Length')
size = max(map(int, sizes))
self.reporthook(url, filename, blocknum, bs, size)
with open(filename,'wb') as tfp:
with open(filename,
'wb') as tfp:
while True:
block = fp.read(bs)
if block:
...
...
@@ -759,14 +759,14 @@ class PackageIndex(Environment):
name, fragment = egg_info_for_url(url)
if name:
while '..' in name:
name = name.replace('..',
'.').replace('
\
\
',
'_')
name = name.replace('..',
'.').replace('
\
\
',
'_')
else:
name = "__downloaded__" # default if URL has no path contents
if name.endswith('.egg.zip'):
name = name[:-4] # strip the extra .zip before download
filename = os.path.join(tmpdir,name)
filename = os.path.join(tmpdir,
name)
# Download the file
#
...
...
@@ -787,7 +787,7 @@ class PackageIndex(Environment):
def _attempt_download(self, url, filename):
headers = self._download_to(url, filename)
if 'html' in headers.get('content-type','').lower():
if 'html' in headers.get('content-type',
'').lower():
return self._download_html(url, headers, filename)
else:
return filename
...
...
@@ -808,16 +808,16 @@ class PackageIndex(Environment):
raise DistutilsError("Unexpected HTML page found at "+url)
def _download_svn(self, url, filename):
url = url.split('#',1)[0] # remove any fragment for svn's sake
url = url.split('#',
1)[0] # remove any fragment for svn's sake
creds = ''
if url.lower().startswith('svn:') and '@' in url:
scheme, netloc, path, p, q, f = urllib.parse.urlparse(url)
if not netloc and path.startswith('//') and '/' in path[2:]:
netloc, path = path[2:].split('/',1)
netloc, path = path[2:].split('/',
1)
auth, host = splituser(netloc)
if auth:
if ':' in auth:
user, pw = auth.split(':',1)
user, pw = auth.split(':',
1)
creds = " --username=%s --password=%s" % (user, pw)
else:
creds = " --username="+auth
...
...
@@ -835,7 +835,7 @@ class PackageIndex(Environment):
scheme = scheme.split('+', 1)[-1]
# Some fragment identification fails
path = path.split('#',1)[0]
path = path.split('#',
1)[0]
rev = None
if '@' in path:
...
...
@@ -847,7 +847,7 @@ class PackageIndex(Environment):
return url, rev
def _download_git(self, url, filename):
filename = filename.split('#',1)[0]
filename = filename.split('#',
1)[0]
url, rev = self._vcs_split_rev_from_url(url, pop_prefix=True)
self.info("Doing git clone from %s to %s", url, filename)
...
...
@@ -863,7 +863,7 @@ class PackageIndex(Environment):
return filename
def _download_hg(self, url, filename):
filename = filename.split('#',1)[0]
filename = filename.split('#',
1)[0]
url, rev = self._vcs_split_rev_from_url(url, pop_prefix=True)
self.info("Doing hg clone from %s to %s", url, filename)
...
...
@@ -948,7 +948,7 @@ def _encode_auth(auth):
# convert back to a string
encoded = encoded_bytes.decode()
# strip the trailing carriage return
return encoded.replace('
\
n
','')
return encoded.replace('
\
n
',
'')
class Credential(object):
...
...
setuptools/py26compat.py
View file @
c405c109
...
...
@@ -19,5 +19,5 @@ def strip_fragment(url):
url
,
fragment
=
splittag
(
url
)
return
url
if
sys
.
version_info
>=
(
2
,
7
):
if
sys
.
version_info
>=
(
2
,
7
):
strip_fragment
=
lambda
x
:
x
setuptools/sandbox.py
View file @
c405c109
...
...
@@ -238,7 +238,7 @@ def run_setup(setup_script, args):
sys.path.insert(0, setup_dir)
# reset to include setup dir, w/clean callback list
working_set.__init__()
working_set.callbacks.append(lambda dist:dist.activate())
working_set.callbacks.append(lambda dist:
dist.activate())
def runner():
ns = dict(__file__=setup_script, __name__='__main__')
...
...
@@ -258,12 +258,12 @@ class AbstractSandbox:
def __init__(self):
self._attrs = [
name for name in dir(_os)
if not name.startswith('_') and hasattr(self,name)
if not name.startswith('_') and hasattr(self,
name)
]
def _copy(self, source):
for name in self._attrs:
setattr(os, name, getattr(source,name))
setattr(os, name, getattr(source,
name))
def run(self, func):
"""
Run
'func'
under
os
sandboxing
"""
...
...
@@ -282,24 +282,24 @@ class AbstractSandbox:
self._copy(_os)
def _mk_dual_path_wrapper(name):
original = getattr(_os,name)
original = getattr(_os,
name)
def wrap(self,
src,dst,*args,
**kw):
def wrap(self,
src, dst, *args,
**kw):
if self._active:
src,
dst = self._remap_pair(name,src,dst,*args,
**kw)
return original(src,
dst,*args,
**kw)
src,
dst = self._remap_pair(name, src, dst, *args,
**kw)
return original(src,
dst, *args,
**kw)
return wrap
for name in ["rename", "link", "symlink"]:
if hasattr(_os,name): locals()[name] = _mk_dual_path_wrapper(name)
if hasattr(_os,
name): locals()[name] = _mk_dual_path_wrapper(name)
def _mk_single_path_wrapper(name, original=None):
original = original or getattr(_os,name)
original = original or getattr(_os,
name)
def wrap(self,
path,*args,
**kw):
def wrap(self,
path, *args,
**kw):
if self._active:
path = self._remap_input(name,
path,*args,
**kw)
return original(path,
*args,
**kw)
path = self._remap_input(name,
path, *args,
**kw)
return original(path,
*args,
**kw)
return wrap
if _file:
...
...
@@ -310,51 +310,51 @@ class AbstractSandbox:
"remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat",
"startfile", "mkfifo", "mknod", "pathconf", "access"
]:
if hasattr(_os,name): locals()[name] = _mk_single_path_wrapper(name)
if hasattr(_os,
name): locals()[name] = _mk_single_path_wrapper(name)
def _mk_single_with_return(name):
original = getattr(_os,name)
original = getattr(_os,
name)
def wrap(self,
path,*args,
**kw):
def wrap(self,
path, *args,
**kw):
if self._active:
path = self._remap_input(name,
path,*args,
**kw)
return self._remap_output(name, original(path,
*args,
**kw))
return original(path,
*args,
**kw)
path = self._remap_input(name,
path, *args,
**kw)
return self._remap_output(name, original(path,
*args,
**kw))
return original(path,
*args,
**kw)
return wrap
for name in ['readlink', 'tempnam']:
if hasattr(_os,name): locals()[name] = _mk_single_with_return(name)
if hasattr(_os,
name): locals()[name] = _mk_single_with_return(name)
def _mk_query(name):
original = getattr(_os,name)
original = getattr(_os,
name)
def wrap(self,
*args,
**kw):
retval = original(*args,**kw)
def wrap(self,
*args,
**kw):
retval = original(*args,
**kw)
if self._active:
return self._remap_output(name, retval)
return retval
return wrap
for name in ['getcwd', 'tmpnam']:
if hasattr(_os,name): locals()[name] = _mk_query(name)
if hasattr(_os,
name): locals()[name] = _mk_query(name)
def _validate_path(self,path):
def _validate_path(self,
path):
"""
Called
to
remap
or
validate
any
path
,
whether
input
or
output
"""
return path
def _remap_input(self,
operation,path,*args,
**kw):
def _remap_input(self,
operation, path, *args,
**kw):
"""
Called
for
path
inputs
"""
return self._validate_path(path)
def _remap_output(self,
operation,
path):
def _remap_output(self,
operation,
path):
"""
Called
for
path
outputs
"""
return self._validate_path(path)
def _remap_pair(self,
operation,src,dst,*args,
**kw):
def _remap_pair(self,
operation, src, dst, *args,
**kw):
"""
Called
for
path
pairs
like
rename
,
link
,
and
symlink
operations
"""
return (
self._remap_input(operation+'-from',
src,*args,
**kw),
self._remap_input(operation+'-to',
dst,*args,
**kw)
self._remap_input(operation+'-from',
src, *args,
**kw),
self._remap_input(operation+'-to',
dst, *args,
**kw)
)
...
...
@@ -388,7 +388,7 @@ class DirectorySandbox(AbstractSandbox):
def __init__(self, sandbox, exceptions=_EXCEPTIONS):
self._sandbox = os.path.normcase(os.path.realpath(sandbox))
self._prefix = os.path.join(self._sandbox,'')
self._prefix = os.path.join(self._sandbox,
'')
self._exceptions = [
os.path.normcase(os.path.realpath(path))
for path in exceptions
...
...
@@ -403,12 +403,12 @@ class DirectorySandbox(AbstractSandbox):
def _file(self, path, mode='r', *args, **kw):
if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
self._violation("file", path, mode, *args, **kw)
return _file(path,
mode,*args,
**kw)
return _file(path,
mode, *args,
**kw)
def _open(self, path, mode='r', *args, **kw):
if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
self._violation("open", path, mode, *args, **kw)
return _open(path,
mode,*args,
**kw)
return _open(path,
mode, *args,
**kw)
def tmpnam(self):
self._violation("tmpnam")
...
...
@@ -448,13 +448,13 @@ class DirectorySandbox(AbstractSandbox):
"""
Called
for
path
pairs
like
rename
,
link
,
and
symlink
operations
"""
if not self._ok(src) or not self._ok(dst):
self._violation(operation, src, dst, *args, **kw)
return (src,dst)
return (src,
dst)
def open(self, file, flags, mode=0o777, *args, **kw):
"""
Called
for
low
-
level
os
.
open
()
"""
if flags & WRITE_FLAGS and not self._ok(file):
self._violation("os.open", file, flags, mode, *args, **kw)
return _os.open(file,
flags,
mode, *args, **kw)
return _os.open(file,
flags,
mode, *args, **kw)
WRITE_FLAGS = functools.reduce(
operator.or_, [getattr(_os, a, 0) for a in
...
...
setuptools/site-patch.py
View file @
c405c109
...
...
@@ -7,7 +7,7 @@ def __boot():
else
:
PYTHONPATH
=
PYTHONPATH
.
split
(
os
.
pathsep
)
pic
=
getattr
(
sys
,
'path_importer_cache'
,
{})
pic
=
getattr
(
sys
,
'path_importer_cache'
,
{})
stdpath
=
sys
.
path
[
len
(
PYTHONPATH
):]
mydir
=
os
.
path
.
dirname
(
__file__
)
#print "searching",stdpath,sys.path
...
...
@@ -25,14 +25,14 @@ def __boot():
else
:
try
:
import
imp
# Avoid import loop in Python >= 3.3
stream
,
path
,
descr
=
imp
.
find_module
(
'site'
,[
item
])
stream
,
path
,
descr
=
imp
.
find_module
(
'site'
,
[
item
])
except
ImportError
:
continue
if
stream
is
None
:
continue
try
:
# This should actually reload the current module
imp
.
load_module
(
'site'
,
stream
,
path
,
descr
)
imp
.
load_module
(
'site'
,
stream
,
path
,
descr
)
finally
:
stream
.
close
()
break
...
...
@@ -41,9 +41,9 @@ def __boot():
#print "loaded", __file__
known_paths
=
dict
([(
makepath
(
item
)[
1
],
1
)
for
item
in
sys
.
path
])
# 2.2 comp
known_paths
=
dict
([(
makepath
(
item
)[
1
],
1
)
for
item
in
sys
.
path
])
# 2.2 comp
oldpos
=
getattr
(
sys
,
'__egginsert'
,
0
)
# save old insertion position
oldpos
=
getattr
(
sys
,
'__egginsert'
,
0
)
# save old insertion position
sys
.
__egginsert
=
0
# and reset the current one
for
item
in
PYTHONPATH
:
...
...
setuptools/tests/__init__.py
View file @
c405c109
...
...
@@ -27,7 +27,7 @@ def makeSetup(**args):
distutils
.
core
.
_setup_stop_after
=
"commandline"
# Don't let system command line leak into tests!
args
.
setdefault
(
'script_args'
,[
'install'
])
args
.
setdefault
(
'script_args'
,
[
'install'
])
try
:
return
setuptools
.
setup
(
**
args
)
...
...
@@ -56,35 +56,35 @@ class TestDepends:
fc
=
six
.
get_function_code
(
f1
)
# unrecognized name
assert
dep
.
extract_constant
(
fc
,
'q'
,
-
1
)
is
None
assert
dep
.
extract_constant
(
fc
,
'q'
,
-
1
)
is
None
# constant assigned
dep
.
extract_constant
(
fc
,
'x'
,
-
1
)
==
"test"
dep
.
extract_constant
(
fc
,
'x'
,
-
1
)
==
"test"
# expression assigned
dep
.
extract_constant
(
fc
,
'y'
,
-
1
)
==
-
1
dep
.
extract_constant
(
fc
,
'y'
,
-
1
)
==
-
1
# recognized name, not assigned
dep
.
extract_constant
(
fc
,
'z'
,
-
1
)
is
None
dep
.
extract_constant
(
fc
,
'z'
,
-
1
)
is
None
def
testFindModule
(
self
):
with
pytest
.
raises
(
ImportError
):
dep
.
find_module
(
'no-such.-thing'
)
with
pytest
.
raises
(
ImportError
):
dep
.
find_module
(
'setuptools.non-existent'
)
f
,
p
,
i
=
dep
.
find_module
(
'setuptools.tests'
)
f
,
p
,
i
=
dep
.
find_module
(
'setuptools.tests'
)
f
.
close
()
@
needs_bytecode
def
testModuleExtract
(
self
):
from
email
import
__version__
assert
dep
.
get_module_constant
(
'email'
,
'__version__'
)
==
__version__
assert
dep
.
get_module_constant
(
'sys'
,
'version'
)
==
sys
.
version
assert
dep
.
get_module_constant
(
'setuptools.tests'
,
'__doc__'
)
==
__doc__
assert
dep
.
get_module_constant
(
'email'
,
'__version__'
)
==
__version__
assert
dep
.
get_module_constant
(
'sys'
,
'version'
)
==
sys
.
version
assert
dep
.
get_module_constant
(
'setuptools.tests'
,
'__doc__'
)
==
__doc__
@
needs_bytecode
def
testRequire
(
self
):
req
=
Require
(
'Email'
,
'1.0.3'
,
'email'
)
req
=
Require
(
'Email'
,
'1.0.3'
,
'email'
)
assert
req
.
name
==
'Email'
assert
req
.
module
==
'email'
...
...
@@ -101,12 +101,12 @@ class TestDepends:
assert
req
.
is_present
()
assert
req
.
is_current
()
req
=
Require
(
'Email 3000'
,
'03000'
,
'email'
,
format
=
LooseVersion
)
req
=
Require
(
'Email 3000'
,
'03000'
,
'email'
,
format
=
LooseVersion
)
assert
req
.
is_present
()
assert
not
req
.
is_current
()
assert
not
req
.
version_ok
(
'unknown'
)
req
=
Require
(
'Do-what-I-mean'
,
'1.0'
,
'd-w-i-m'
)
req
=
Require
(
'Do-what-I-mean'
,
'1.0'
,
'd-w-i-m'
)
assert
not
req
.
is_present
()
assert
not
req
.
is_current
()
...
...
@@ -125,22 +125,22 @@ class TestDepends:
class
TestDistro
:
def
setup_method
(
self
,
method
):
self
.
e1
=
Extension
(
'bar.ext'
,[
'bar.c'
])
self
.
e1
=
Extension
(
'bar.ext'
,
[
'bar.c'
])
self
.
e2
=
Extension
(
'c.y'
,
[
'y.c'
])
self
.
dist
=
makeSetup
(
packages
=
[
'a'
,
'a.b'
,
'a.b.c'
,
'b'
,
'c'
],
py_modules
=
[
'b.d'
,
'x'
],
py_modules
=
[
'b.d'
,
'x'
],
ext_modules
=
(
self
.
e1
,
self
.
e2
),
package_dir
=
{},
)
def
testDistroType
(
self
):
assert
isinstance
(
self
.
dist
,
setuptools
.
dist
.
Distribution
)
assert
isinstance
(
self
.
dist
,
setuptools
.
dist
.
Distribution
)
def
testExcludePackage
(
self
):
self
.
dist
.
exclude_package
(
'a'
)
assert
self
.
dist
.
packages
==
[
'b'
,
'c'
]
assert
self
.
dist
.
packages
==
[
'b'
,
'c'
]
self
.
dist
.
exclude_package
(
'b'
)
assert
self
.
dist
.
packages
==
[
'c'
]
...
...
@@ -169,7 +169,7 @@ class TestDistro:
assert
self
.
dist
.
ext_modules
==
[
self
.
e2
,
self
.
e1
]
def
testExcludePackages
(
self
):
self
.
dist
.
exclude
(
packages
=
[
'c'
,
'b'
,
'a'
])
self
.
dist
.
exclude
(
packages
=
[
'c'
,
'b'
,
'a'
])
assert
self
.
dist
.
packages
==
[]
assert
self
.
dist
.
py_modules
==
[
'x'
]
assert
self
.
dist
.
ext_modules
==
[
self
.
e1
]
...
...
@@ -199,13 +199,13 @@ class TestDistro:
with
pytest
.
raises
(
DistutilsSetupError
):
self
.
dist
.
exclude
(
nonexistent_option
=
'x'
)
with
pytest
.
raises
(
DistutilsSetupError
):
self
.
dist
.
include
(
packages
=
{
'x'
:
'y'
})
self
.
dist
.
include
(
packages
=
{
'x'
:
'y'
})
with
pytest
.
raises
(
DistutilsSetupError
):
self
.
dist
.
exclude
(
packages
=
{
'x'
:
'y'
})
self
.
dist
.
exclude
(
packages
=
{
'x'
:
'y'
})
with
pytest
.
raises
(
DistutilsSetupError
):
self
.
dist
.
include
(
ext_modules
=
{
'x'
:
'y'
})
self
.
dist
.
include
(
ext_modules
=
{
'x'
:
'y'
})
with
pytest
.
raises
(
DistutilsSetupError
):
self
.
dist
.
exclude
(
ext_modules
=
{
'x'
:
'y'
})
self
.
dist
.
exclude
(
ext_modules
=
{
'x'
:
'y'
})
with
pytest
.
raises
(
DistutilsSetupError
):
self
.
dist
.
include
(
package_dir
=
[
'q'
])
...
...
@@ -216,31 +216,31 @@ class TestDistro:
class
TestFeatures
:
def
setup_method
(
self
,
method
):
self
.
req
=
Require
(
'Distutils'
,
'1.0.3'
,
'distutils'
)
self
.
req
=
Require
(
'Distutils'
,
'1.0.3'
,
'distutils'
)
self
.
dist
=
makeSetup
(
features
=
{
'foo'
:
Feature
(
"foo"
,
standard
=
True
,
require_features
=
[
'baz'
,
self
.
req
]),
'foo'
:
Feature
(
"foo"
,
standard
=
True
,
require_features
=
[
'baz'
,
self
.
req
]),
'bar'
:
Feature
(
"bar"
,
standard
=
True
,
packages
=
[
'pkg.bar'
],
py_modules
=
[
'bar_et'
],
remove
=
[
'bar.ext'
],
),
'baz'
:
Feature
(
"baz"
,
optional
=
False
,
packages
=
[
'pkg.baz'
],
scripts
=
[
'scripts/baz_it'
],
libraries
=
[(
'libfoo'
,
'foo/foofoo.c'
)]
libraries
=
[(
'libfoo'
,
'foo/foofoo.c'
)]
),
'dwim'
:
Feature
(
"DWIM"
,
available
=
False
,
remove
=
'bazish'
),
},
script_args
=
[
'--without-bar'
,
'install'
],
packages
=
[
'pkg.bar'
,
'pkg.foo'
],
py_modules
=
[
'bar_et'
,
'bazish'
],
ext_modules
=
[
Extension
(
'bar.ext'
,[
'bar.c'
])]
ext_modules
=
[
Extension
(
'bar.ext'
,
[
'bar.c'
])]
)
def
testDefaults
(
self
):
assert
not
Feature
(
"test"
,
standard
=
True
,
remove
=
'x'
,
available
=
False
"test"
,
standard
=
True
,
remove
=
'x'
,
available
=
False
).
include_by_default
()
assert
Feature
(
"test"
,
standard
=
True
,
remove
=
'x'
).
include_by_default
()
assert
Feature
(
"test"
,
standard
=
True
,
remove
=
'x'
).
include_by_default
()
# Feature must have either kwargs, removes, or require_features
with
pytest
.
raises
(
DistutilsSetupError
):
Feature
(
"test"
)
...
...
@@ -252,16 +252,16 @@ class TestFeatures:
def
testFeatureOptions
(
self
):
dist
=
self
.
dist
assert
(
(
'with-dwim'
,
None
,
'include DWIM'
)
in
dist
.
feature_options
(
'with-dwim'
,
None
,
'include DWIM'
)
in
dist
.
feature_options
)
assert
(
(
'without-dwim'
,
None
,
'exclude DWIM (default)'
)
in
dist
.
feature_options
(
'without-dwim'
,
None
,
'exclude DWIM (default)'
)
in
dist
.
feature_options
)
assert
(
(
'with-bar'
,
None
,
'include bar (default)'
)
in
dist
.
feature_options
(
'with-bar'
,
None
,
'include bar (default)'
)
in
dist
.
feature_options
)
assert
(
(
'without-bar'
,
None
,
'exclude bar'
)
in
dist
.
feature_options
(
'without-bar'
,
None
,
'exclude bar'
)
in
dist
.
feature_options
)
assert
dist
.
feature_negopt
[
'without-foo'
]
==
'with-foo'
assert
dist
.
feature_negopt
[
'without-bar'
]
==
'with-bar'
...
...
@@ -277,7 +277,7 @@ class TestFeatures:
assert
(
not
'pkg.bar'
in
dist
.
packages
)
assert
(
'pkg.baz'
in
dist
.
packages
)
assert
(
'scripts/baz_it'
in
dist
.
scripts
)
assert
((
'libfoo'
,
'foo/foofoo.c'
)
in
dist
.
libraries
)
assert
((
'libfoo'
,
'foo/foofoo.c'
)
in
dist
.
libraries
)
assert
dist
.
ext_modules
==
[]
assert
dist
.
require_features
==
[
self
.
req
]
...
...
@@ -288,7 +288,7 @@ class TestFeatures:
def
testFeatureWithInvalidRemove
(
self
):
with
pytest
.
raises
(
SystemExit
):
makeSetup
(
features
=
{
'x'
:
Feature
(
'x'
,
remove
=
'y'
)})
makeSetup
(
features
=
{
'x'
:
Feature
(
'x'
,
remove
=
'y'
)})
class
TestCommandTests
:
...
...
@@ -298,7 +298,7 @@ class TestCommandTests:
assert
(
isinstance
(
test_cmd
,
distutils
.
cmd
.
Command
))
def
testLongOptSuiteWNoDefault
(
self
):
ts1
=
makeSetup
(
script_args
=
[
'test'
,
'--test-suite=foo.tests.suite'
])
ts1
=
makeSetup
(
script_args
=
[
'test'
,
'--test-suite=foo.tests.suite'
])
ts1
=
ts1
.
get_command_obj
(
'test'
)
ts1
.
ensure_finalized
()
assert
ts1
.
test_suite
==
'foo.tests.suite'
...
...
@@ -311,7 +311,7 @@ class TestCommandTests:
def
testDefaultWModuleOnCmdLine
(
self
):
ts3
=
makeSetup
(
test_suite
=
'bar.tests'
,
script_args
=
[
'test'
,
'-m'
,
'foo.tests'
]
script_args
=
[
'test'
,
'-m'
,
'foo.tests'
]
).
get_command_obj
(
'test'
)
ts3
.
ensure_finalized
()
assert
ts3
.
test_module
==
'foo.tests'
...
...
@@ -319,7 +319,7 @@ class TestCommandTests:
def
testConflictingOptions
(
self
):
ts4
=
makeSetup
(
script_args
=
[
'test'
,
'-m'
,
'bar.tests'
,
'-s'
,
'foo.tests.suite'
]
script_args
=
[
'test'
,
'-m'
,
'bar.tests'
,
'-s'
,
'foo.tests.suite'
]
).
get_command_obj
(
'test'
)
with
pytest
.
raises
(
DistutilsOptionError
):
ts4
.
ensure_finalized
()
...
...
setuptools/tests/contexts.py
View file @
c405c109
...
...
@@ -10,7 +10,7 @@ import pkg_resources
@
contextlib
.
contextmanager
def
tempdir
(
cd
=
lambda
dir
:
None
,
**
kwargs
):
def
tempdir
(
cd
=
lambda
dir
:
None
,
**
kwargs
):
temp_dir
=
tempfile
.
mkdtemp
(
**
kwargs
)
orig_dir
=
os
.
getcwd
()
try
:
...
...
setuptools/tests/test_find_packages.py
View file @
c405c109
...
...
@@ -32,7 +32,7 @@ def can_symlink():
def
has_symlink
():
bad_symlink
=
(
# Windows symlink directory detection is broken on Python 3.2
platform
.
system
()
==
'Windows'
and
sys
.
version_info
[:
2
]
==
(
3
,
2
)
platform
.
system
()
==
'Windows'
and
sys
.
version_info
[:
2
]
==
(
3
,
2
)
)
return
can_symlink
()
and
not
bad_symlink
...
...
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