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
fb7ab81a
Commit
fb7ab81a
authored
Aug 16, 2020
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Python 2 compatibility
parent
4eb5b32f
Changes
68
Show whitespace changes
Inline
Side-by-side
Showing
68 changed files
with
185 additions
and
806 deletions
+185
-806
bootstrap.py
bootstrap.py
+0
-2
pkg_resources/__init__.py
pkg_resources/__init__.py
+5
-34
pkg_resources/tests/test_pkg_resources.py
pkg_resources/tests/test_pkg_resources.py
+8
-30
pkg_resources/tests/test_resources.py
pkg_resources/tests/test_resources.py
+0
-4
pkg_resources/tests/test_working_set.py
pkg_resources/tests/test_working_set.py
+0
-2
setup.cfg
setup.cfg
+0
-1
setuptools/__init__.py
setuptools/__init__.py
+5
-15
setuptools/build_meta.py
setuptools/build_meta.py
+4
-17
setuptools/command/alias.py
setuptools/command/alias.py
+0
-2
setuptools/command/bdist_egg.py
setuptools/command/bdist_egg.py
+5
-15
setuptools/command/build_ext.py
setuptools/command/build_ext.py
+2
-14
setuptools/command/build_py.py
setuptools/command/build_py.py
+1
-7
setuptools/command/develop.py
setuptools/command/develop.py
+1
-5
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+17
-38
setuptools/command/egg_info.py
setuptools/command/egg_info.py
+4
-8
setuptools/command/py36compat.py
setuptools/command/py36compat.py
+0
-2
setuptools/command/rotate.py
setuptools/command/rotate.py
+1
-3
setuptools/command/sdist.py
setuptools/command/sdist.py
+8
-38
setuptools/command/setopt.py
setuptools/command/setopt.py
+1
-2
setuptools/command/test.py
setuptools/command/test.py
+2
-8
setuptools/command/upload_docs.py
setuptools/command/upload_docs.py
+6
-10
setuptools/config.py
setuptools/config.py
+2
-10
setuptools/depends.py
setuptools/depends.py
+6
-7
setuptools/dist.py
setuptools/dist.py
+11
-37
setuptools/extension.py
setuptools/extension.py
+0
-2
setuptools/installer.py
setuptools/installer.py
+3
-5
setuptools/lib2to3_ex.py
setuptools/lib2to3_ex.py
+0
-3
setuptools/monkey.py
setuptools/monkey.py
+1
-3
setuptools/msvc.py
setuptools/msvc.py
+2
-4
setuptools/namespaces.py
setuptools/namespaces.py
+0
-4
setuptools/package_index.py
setuptools/package_index.py
+16
-17
setuptools/py27compat.py
setuptools/py27compat.py
+0
-60
setuptools/py31compat.py
setuptools/py31compat.py
+0
-32
setuptools/py33compat.py
setuptools/py33compat.py
+0
-59
setuptools/sandbox.py
setuptools/sandbox.py
+3
-12
setuptools/ssl_support.py
setuptools/ssl_support.py
+3
-2
setuptools/tests/__init__.py
setuptools/tests/__init__.py
+1
-8
setuptools/tests/contexts.py
setuptools/tests/contexts.py
+3
-3
setuptools/tests/namespaces.py
setuptools/tests/namespaces.py
+0
-2
setuptools/tests/server.py
setuptools/tests/server.py
+10
-11
setuptools/tests/test_archive_util.py
setuptools/tests/test_archive_util.py
+1
-5
setuptools/tests/test_build_ext.py
setuptools/tests/test_build_ext.py
+1
-3
setuptools/tests/test_build_meta.py
setuptools/tests/test_build_meta.py
+2
-18
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+1
-23
setuptools/tests/test_develop.py
setuptools/tests/test_develop.py
+2
-5
setuptools/tests/test_dist.py
setuptools/tests/test_dist.py
+6
-14
setuptools/tests/test_dist_info.py
setuptools/tests/test_dist_info.py
+0
-4
setuptools/tests/test_easy_install.py
setuptools/tests/test_easy_install.py
+0
-8
setuptools/tests/test_egg_info.py
setuptools/tests/test_egg_info.py
+1
-51
setuptools/tests/test_extern.py
setuptools/tests/test_extern.py
+0
-2
setuptools/tests/test_find_packages.py
setuptools/tests/test_find_packages.py
+1
-10
setuptools/tests/test_integration.py
setuptools/tests/test_integration.py
+1
-1
setuptools/tests/test_manifest.py
setuptools/tests/test_manifest.py
+2
-4
setuptools/tests/test_msvc14.py
setuptools/tests/test_msvc14.py
+0
-2
setuptools/tests/test_namespaces.py
setuptools/tests/test_namespaces.py
+0
-2
setuptools/tests/test_packageindex.py
setuptools/tests/test_packageindex.py
+5
-6
setuptools/tests/test_sdist.py
setuptools/tests/test_sdist.py
+25
-52
setuptools/tests/test_setopt.py
setuptools/tests/test_setopt.py
+2
-8
setuptools/tests/test_setuptools.py
setuptools/tests/test_setuptools.py
+1
-2
setuptools/tests/test_test.py
setuptools/tests/test_test.py
+0
-5
setuptools/tests/test_virtualenv.py
setuptools/tests/test_virtualenv.py
+0
-11
setuptools/tests/test_wheel.py
setuptools/tests/test_wheel.py
+0
-2
setuptools/tests/test_windows_wrappers.py
setuptools/tests/test_windows_wrappers.py
+0
-2
setuptools/tests/text.py
setuptools/tests/text.py
+0
-5
setuptools/tests/textwrap.py
setuptools/tests/textwrap.py
+0
-2
setuptools/unicode_utils.py
setuptools/unicode_utils.py
+2
-4
setuptools/wheel.py
setuptools/wheel.py
+1
-5
tools/tox_pip.py
tools/tox_pip.py
+0
-12
No files found.
bootstrap.py
View file @
fb7ab81a
...
@@ -5,8 +5,6 @@ environment by creating a minimal egg-info directory and then invoking the
...
@@ -5,8 +5,6 @@ environment by creating a minimal egg-info directory and then invoking the
egg-info command to flesh out the egg-info directory.
egg-info command to flesh out the egg-info directory.
"""
"""
from
__future__
import
unicode_literals
import
os
import
os
import
sys
import
sys
import
textwrap
import
textwrap
...
...
pkg_resources/__init__.py
View file @
fb7ab81a
# coding: utf-8
"""
"""
Package resource API
Package resource API
--------------------
--------------------
...
@@ -15,8 +14,6 @@ The package resource API is designed to work with normal filesystem packages,
...
@@ -15,8 +14,6 @@ The package resource API is designed to work with normal filesystem packages,
method.
method.
"""
"""
from
__future__
import
absolute_import
import
sys
import
sys
import
os
import
os
import
io
import
io
...
@@ -54,9 +51,6 @@ try:
...
@@ -54,9 +51,6 @@ try:
except
NameError
:
except
NameError
:
FileExistsError
=
OSError
FileExistsError
=
OSError
from
pkg_resources.extern
import
six
from
pkg_resources.extern.six.moves
import
map
,
filter
# capture these to bypass sandboxing
# capture these to bypass sandboxing
from
os
import
utime
from
os
import
utime
try
:
try
:
...
@@ -83,18 +77,9 @@ __import__('pkg_resources.extern.packaging.specifiers')
...
@@ -83,18 +77,9 @@ __import__('pkg_resources.extern.packaging.specifiers')
__import__
(
'pkg_resources.extern.packaging.requirements'
)
__import__
(
'pkg_resources.extern.packaging.requirements'
)
__import__
(
'pkg_resources.extern.packaging.markers'
)
__import__
(
'pkg_resources.extern.packaging.markers'
)
if
sys
.
version_info
<
(
3
,
5
):
__metaclass__
=
type
if
(
3
,
0
)
<
sys
.
version_info
<
(
3
,
5
):
raise
RuntimeError
(
"Python 3.5 or later is required"
)
raise
RuntimeError
(
"Python 3.5 or later is required"
)
if
six
.
PY2
:
# Those builtin exceptions are only defined in Python 3
PermissionError
=
None
NotADirectoryError
=
None
# declare some globals that will be defined later to
# declare some globals that will be defined later to
# satisfy the linters.
# satisfy the linters.
require
=
None
require
=
None
...
@@ -474,7 +459,7 @@ run_main = run_script
...
@@ -474,7 +459,7 @@ run_main = run_script
def get_distribution(dist):
def get_distribution(dist):
"""Return a current distribution object for a Requirement or string"""
"""Return a current distribution object for a Requirement or string"""
if isinstance(dist, s
ix.string_types
):
if isinstance(dist, s
tr
):
dist = Requirement.parse(dist)
dist = Requirement.parse(dist)
if isinstance(dist, Requirement):
if isinstance(dist, Requirement):
dist = get_provider(dist)
dist = get_provider(dist)
...
@@ -1418,8 +1403,6 @@ class NullProvider:
...
@@ -1418,8 +1403,6 @@ class NullProvider:
return ""
return ""
path = self._get_metadata_path(name)
path = self._get_metadata_path(name)
value = self._get(path)
value = self._get(path)
if six.PY2:
return value
try:
try:
return value.decode('utf-8')
return value.decode('utf-8')
except UnicodeDecodeError as exc:
except UnicodeDecodeError as exc:
...
@@ -1910,8 +1893,7 @@ class FileMetadata(EmptyProvider):
...
@@ -1910,8 +1893,7 @@ class FileMetadata(EmptyProvider):
return metadata
return metadata
def _warn_on_replacement(self, metadata):
def _warn_on_replacement(self, metadata):
# Python 2.7 compat for: replacement_char = '�'
replacement_char = '�'
replacement_char = b'
\
xef
\
xbf
\
xbd
'.decode('utf-8')
if replacement_char in metadata:
if replacement_char in metadata:
tmpl = "
{
self
.
path
}
could
not
be
properly
decoded
in
UTF
-
8
"
tmpl = "
{
self
.
path
}
could
not
be
properly
decoded
in
UTF
-
8
"
msg = tmpl.format(**locals())
msg = tmpl.format(**locals())
...
@@ -2109,8 +2091,6 @@ class NoDists:
...
@@ -2109,8 +2091,6 @@ class NoDists:
"""
"""
def __bool__(self):
def __bool__(self):
return False
return False
if six.PY2:
__nonzero__ = __bool__
def __call__(self, fullpath):
def __call__(self, fullpath):
return iter(())
return iter(())
...
@@ -2127,12 +2107,7 @@ def safe_listdir(path):
...
@@ -2127,12 +2107,7 @@ def safe_listdir(path):
except OSError as e:
except OSError as e:
# Ignore the directory if does not exist, not a directory or
# Ignore the directory if does not exist, not a directory or
# permission denied
# permission denied
ignorable = (
if e.errno not in (errno.ENOTDIR, errno.EACCES, errno.ENOENT):
e.errno in (errno.ENOTDIR, errno.EACCES, errno.ENOENT)
# Python 2 on Windows needs to be handled this way :(
or getattr(e, "
winerror
", None) == 267
)
if not ignorable:
raise
raise
return ()
return ()
...
@@ -2406,7 +2381,7 @@ def _set_parent_ns(packageName):
...
@@ -2406,7 +2381,7 @@ def _set_parent_ns(packageName):
def yield_lines(strs):
def yield_lines(strs):
"""Yield non-empty/non-comment lines of a string or sequence"""
"""Yield non-empty/non-comment lines of a string or sequence"""
if isinstance(strs, s
ix.string_types
):
if isinstance(strs, s
tr
):
for s in strs.splitlines():
for s in strs.splitlines():
s = s.strip()
s = s.strip()
# skip blank lines/comments
# skip blank lines/comments
...
@@ -2844,10 +2819,6 @@ class Distribution:
...
@@ -2844,10 +2819,6 @@ class Distribution:
)
)
)
)
if
not
hasattr
(
object
,
'__dir__'
):
# python 2.7 not supported
del
__dir__
@
classmethod
@
classmethod
def
from_filename
(
cls
,
filename
,
metadata
=
None
,
**
kw
):
def
from_filename
(
cls
,
filename
,
metadata
=
None
,
**
kw
):
return
cls
.
from_location
(
return
cls
.
from_location
(
...
...
pkg_resources/tests/test_pkg_resources.py
View file @
fb7ab81a
# coding: utf-8
from
__future__
import
unicode_literals
import
sys
import
sys
import
tempfile
import
tempfile
import
os
import
os
...
@@ -20,16 +17,11 @@ except ImportError:
...
@@ -20,16 +17,11 @@ except ImportError:
from
pkg_resources
import
(
from
pkg_resources
import
(
DistInfoDistribution
,
Distribution
,
EggInfoDistribution
,
DistInfoDistribution
,
Distribution
,
EggInfoDistribution
,
)
)
from
setuptools.extern
import
six
from
pkg_resources.extern.six.moves
import
map
from
pkg_resources.extern.six
import
text_type
,
string_types
import
pytest
import
pytest
import
pkg_resources
import
pkg_resources
__metaclass__
=
type
def
timestamp
(
dt
):
def
timestamp
(
dt
):
"""
"""
...
@@ -42,7 +34,7 @@ def timestamp(dt):
...
@@ -42,7 +34,7 @@ def timestamp(dt):
return
time
.
mktime
(
dt
.
timetuple
())
return
time
.
mktime
(
dt
.
timetuple
())
class
EggRemover
(
text_type
):
class
EggRemover
(
str
):
def
__call__
(
self
):
def
__call__
(
self
):
if
self
in
sys
.
path
:
if
self
in
sys
.
path
:
sys
.
path
.
remove
(
self
)
sys
.
path
.
remove
(
self
)
...
@@ -143,7 +135,7 @@ class TestResourceManager:
...
@@ -143,7 +135,7 @@ class TestResourceManager:
path
=
mgr
.
get_cache_path
(
'foo'
)
path
=
mgr
.
get_cache_path
(
'foo'
)
type_
=
str
(
type
(
path
))
type_
=
str
(
type
(
path
))
message
=
"Unexpected type from get_cache_path: "
+
type_
message
=
"Unexpected type from get_cache_path: "
+
type_
assert
isinstance
(
path
,
str
ing_types
),
message
assert
isinstance
(
path
,
str
),
message
def
test_get_cache_path_race
(
self
,
tmpdir
):
def
test_get_cache_path_race
(
self
,
tmpdir
):
# Patch to os.path.isdir to create a race condition
# Patch to os.path.isdir to create a race condition
...
@@ -225,13 +217,6 @@ def test_get_metadata__bad_utf8(tmpdir):
...
@@ -225,13 +217,6 @@ def test_get_metadata__bad_utf8(tmpdir):
metadata
=
'née'
.
encode
(
'iso-8859-1'
)
metadata
=
'née'
.
encode
(
'iso-8859-1'
)
dist
=
make_test_distribution
(
metadata_path
,
metadata
=
metadata
)
dist
=
make_test_distribution
(
metadata_path
,
metadata
=
metadata
)
if
six
.
PY2
:
# In Python 2, get_metadata() doesn't do any decoding.
actual
=
dist
.
get_metadata
(
filename
)
assert
actual
==
metadata
return
# Otherwise, we are in the Python 3 case.
with
pytest
.
raises
(
UnicodeDecodeError
)
as
excinfo
:
with
pytest
.
raises
(
UnicodeDecodeError
)
as
excinfo
:
dist
.
get_metadata
(
filename
)
dist
.
get_metadata
(
filename
)
...
@@ -247,25 +232,18 @@ def test_get_metadata__bad_utf8(tmpdir):
...
@@ -247,25 +232,18 @@ def test_get_metadata__bad_utf8(tmpdir):
assert
actual
.
endswith
(
metadata_path
),
'actual: {}'
.
format
(
actual
)
assert
actual
.
endswith
(
metadata_path
),
'actual: {}'
.
format
(
actual
)
# TODO: remove this in favor of Path.touch() when Python 2 is dropped.
def
touch_file
(
path
):
"""
Create an empty file.
"""
with
open
(
path
,
'w'
):
pass
def
make_distribution_no_version
(
tmpdir
,
basename
):
def
make_distribution_no_version
(
tmpdir
,
basename
):
"""
"""
Create a distribution directory with no file containing the version.
Create a distribution directory with no file containing the version.
"""
"""
# Convert the LocalPath object to a string before joining.
dist_dir
=
tmpdir
/
basename
dist_dir
=
os
.
path
.
join
(
str
(
tmpdir
),
basename
)
dist_dir
.
ensure_dir
()
os
.
mkdir
(
dist_dir
)
# Make the directory non-empty so distributions_from_metadata()
# Make the directory non-empty so distributions_from_metadata()
# will detect it and yield it.
# will detect it and yield it.
touch_file
(
os
.
path
.
join
(
dist_dir
,
'temp.txt'
))
dist_dir
.
join
(
'temp.txt'
).
ensure
()
if
sys
.
version_info
<
(
3
,
6
):
dist_dir
=
str
(
dist_dir
)
dists
=
list
(
pkg_resources
.
distributions_from_metadata
(
dist_dir
))
dists
=
list
(
pkg_resources
.
distributions_from_metadata
(
dist_dir
))
assert
len
(
dists
)
==
1
assert
len
(
dists
)
==
1
...
...
pkg_resources/tests/test_resources.py
View file @
fb7ab81a
from
__future__
import
unicode_literals
import
os
import
os
import
sys
import
sys
import
string
import
string
import
platform
import
platform
import
itertools
import
itertools
from
pkg_resources.extern.six.moves
import
map
import
pytest
import
pytest
from
pkg_resources.extern
import
packaging
from
pkg_resources.extern
import
packaging
...
...
pkg_resources/tests/test_working_set.py
View file @
fb7ab81a
...
@@ -9,8 +9,6 @@ import pkg_resources
...
@@ -9,8 +9,6 @@ import pkg_resources
from
.test_resources
import
Metadata
from
.test_resources
import
Metadata
__metaclass__
=
type
def
strip_comments
(
s
):
def
strip_comments
(
s
):
return
'
\
n
'
.
join
(
return
'
\
n
'
.
join
(
...
...
setup.cfg
View file @
fb7ab81a
...
@@ -70,7 +70,6 @@ tests =
...
@@ -70,7 +70,6 @@ tests =
coverage>=4.5.1
coverage>=4.5.1
pytest-cov>=2.5.1
pytest-cov>=2.5.1
paver; python_version>="3.6"
paver; python_version>="3.6"
futures; python_version=="2.7"
pip>=19.1 # For proper file:// URLs support.
pip>=19.1 # For proper file:// URLs support.
jaraco.envs
jaraco.envs
...
...
setuptools/__init__.py
View file @
fb7ab81a
...
@@ -13,27 +13,19 @@ from distutils.util import convert_path
...
@@ -13,27 +13,19 @@ from distutils.util import convert_path
from
._deprecation_warning
import
SetuptoolsDeprecationWarning
from
._deprecation_warning
import
SetuptoolsDeprecationWarning
from
setuptools.extern.six
import
PY3
,
string_types
from
setuptools.extern.six.moves
import
filter
,
map
import
setuptools.version
import
setuptools.version
from
setuptools.extension
import
Extension
from
setuptools.extension
import
Extension
from
setuptools.dist
import
Distribution
from
setuptools.dist
import
Distribution
from
setuptools.depends
import
Require
from
setuptools.depends
import
Require
from
.
import
monkey
from
.
import
monkey
__metaclass__
=
type
__all__
=
[
__all__
=
[
'setup'
,
'Distribution'
,
'Command'
,
'Extension'
,
'Require'
,
'setup'
,
'Distribution'
,
'Command'
,
'Extension'
,
'Require'
,
'SetuptoolsDeprecationWarning'
,
'SetuptoolsDeprecationWarning'
,
'find_packages'
'find_packages'
,
'find_namespace_packages'
,
]
]
if
PY3
:
__all__
.
append
(
'find_namespace_packages'
)
__version__
=
setuptools
.
version
.
__version__
__version__
=
setuptools
.
version
.
__version__
bootstrap_install_from
=
None
bootstrap_install_from
=
None
...
@@ -122,9 +114,7 @@ class PEP420PackageFinder(PackageFinder):
...
@@ -122,9 +114,7 @@ class PEP420PackageFinder(PackageFinder):
find_packages
=
PackageFinder
.
find
find_packages
=
PackageFinder
.
find
find_namespace_packages
=
PEP420PackageFinder
.
find
if
PY3
:
find_namespace_packages
=
PEP420PackageFinder
.
find
def
_install_setup_requires
(
attrs
):
def
_install_setup_requires
(
attrs
):
...
@@ -187,7 +177,7 @@ class Command(_Command):
...
@@ -187,7 +177,7 @@ class Command(_Command):
if
val
is
None
:
if
val
is
None
:
setattr
(
self
,
option
,
default
)
setattr
(
self
,
option
,
default
)
return
default
return
default
elif
not
isinstance
(
val
,
str
ing_types
):
elif
not
isinstance
(
val
,
str
):
raise
DistutilsOptionError
(
"'%s' must be a %s (got `%s`)"
raise
DistutilsOptionError
(
"'%s' must be a %s (got `%s`)"
%
(
option
,
what
,
val
))
%
(
option
,
what
,
val
))
return
val
return
val
...
@@ -201,11 +191,11 @@ class Command(_Command):
...
@@ -201,11 +191,11 @@ class Command(_Command):
val
=
getattr
(
self
,
option
)
val
=
getattr
(
self
,
option
)
if
val
is
None
:
if
val
is
None
:
return
return
elif
isinstance
(
val
,
str
ing_types
):
elif
isinstance
(
val
,
str
):
setattr
(
self
,
option
,
re
.
split
(
r',\
s*|
\s+'
,
val
))
setattr
(
self
,
option
,
re
.
split
(
r',\
s*|
\s+'
,
val
))
else
:
else
:
if
isinstance
(
val
,
list
):
if
isinstance
(
val
,
list
):
ok
=
all
(
isinstance
(
v
,
str
ing_types
)
for
v
in
val
)
ok
=
all
(
isinstance
(
v
,
str
)
for
v
in
val
)
else
:
else
:
ok
=
False
ok
=
False
if
not
ok
:
if
not
ok
:
...
...
setuptools/build_meta.py
View file @
fb7ab81a
...
@@ -32,10 +32,10 @@ import sys
...
@@ -32,10 +32,10 @@ import sys
import
tokenize
import
tokenize
import
shutil
import
shutil
import
contextlib
import
contextlib
import
tempfile
import
setuptools
import
setuptools
import
distutils
import
distutils
from
setuptools.py31compat
import
TemporaryDirectory
from
pkg_resources
import
parse_requirements
from
pkg_resources
import
parse_requirements
...
@@ -91,19 +91,6 @@ def no_install_setup_requires():
...
@@ -91,19 +91,6 @@ def no_install_setup_requires():
setuptools
.
_install_setup_requires
=
orig
setuptools
.
_install_setup_requires
=
orig
def
_to_str
(
s
):
"""
Convert a filename to a string (on Python 2, explicitly
a byte string, not Unicode) as distutils checks for the
exact type str.
"""
if
sys
.
version_info
[
0
]
==
2
and
not
isinstance
(
s
,
str
):
# Assume it's Unicode, as that's what the PEP says
# should be provided.
return
s
.
encode
(
sys
.
getfilesystemencoding
())
return
s
def
_get_immediate_subdirectories
(
a_dir
):
def
_get_immediate_subdirectories
(
a_dir
):
return
[
name
for
name
in
os
.
listdir
(
a_dir
)
return
[
name
for
name
in
os
.
listdir
(
a_dir
)
if
os
.
path
.
isdir
(
os
.
path
.
join
(
a_dir
,
name
))]
if
os
.
path
.
isdir
(
os
.
path
.
join
(
a_dir
,
name
))]
...
@@ -168,8 +155,8 @@ class _BuildMetaBackend(object):
...
@@ -168,8 +155,8 @@ class _BuildMetaBackend(object):
def
prepare_metadata_for_build_wheel
(
self
,
metadata_directory
,
def
prepare_metadata_for_build_wheel
(
self
,
metadata_directory
,
config_settings
=
None
):
config_settings
=
None
):
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
'dist_info'
,
'--egg-base'
,
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
_to_str
(
metadata_directory
)
]
'dist_info'
,
'--egg-base'
,
metadata_directory
]
with
no_install_setup_requires
():
with
no_install_setup_requires
():
self
.
run_setup
()
self
.
run_setup
()
...
@@ -207,7 +194,7 @@ class _BuildMetaBackend(object):
...
@@ -207,7 +194,7 @@ class _BuildMetaBackend(object):
# Build in a temporary directory, then copy to the target.
# Build in a temporary directory, then copy to the target.
os
.
makedirs
(
result_directory
,
exist_ok
=
True
)
os
.
makedirs
(
result_directory
,
exist_ok
=
True
)
with
TemporaryDirectory
(
dir
=
result_directory
)
as
tmp_dist_dir
:
with
tempfile
.
TemporaryDirectory
(
dir
=
result_directory
)
as
tmp_dist_dir
:
sys
.
argv
=
(
sys
.
argv
[:
1
]
+
setup_command
+
sys
.
argv
=
(
sys
.
argv
[:
1
]
+
setup_command
+
[
'--dist-dir'
,
tmp_dist_dir
]
+
[
'--dist-dir'
,
tmp_dist_dir
]
+
config_settings
[
"--global-option"
])
config_settings
[
"--global-option"
])
...
...
setuptools/command/alias.py
View file @
fb7ab81a
from
distutils.errors
import
DistutilsOptionError
from
distutils.errors
import
DistutilsOptionError
from
setuptools.extern.six.moves
import
map
from
setuptools.command.setopt
import
edit_config
,
option_base
,
config_file
from
setuptools.command.setopt
import
edit_config
,
option_base
,
config_file
...
...
setuptools/command/bdist_egg.py
View file @
fb7ab81a
...
@@ -13,24 +13,16 @@ import textwrap
...
@@ -13,24 +13,16 @@ import textwrap
import
marshal
import
marshal
import
warnings
import
warnings
from
setuptools.extern
import
six
from
pkg_resources
import
get_build_platform
,
Distribution
,
ensure_directory
from
pkg_resources
import
get_build_platform
,
Distribution
,
ensure_directory
from
pkg_resources
import
EntryPoint
from
pkg_resources
import
EntryPoint
from
setuptools.extension
import
Library
from
setuptools.extension
import
Library
from
setuptools
import
Command
,
SetuptoolsDeprecationWarning
from
setuptools
import
Command
,
SetuptoolsDeprecationWarning
try
:
from
sysconfig
import
get_path
,
get_python_version
# Python 2.7 or >=3.2
from
sysconfig
import
get_path
,
get_python_version
def
_get_purelib
():
return
get_path
(
"purelib"
)
except
ImportError
:
from
distutils.sysconfig
import
get_python_lib
,
get_python_version
def
_get_purelib
():
def
_get_purelib
():
return
get_python_lib
(
False
)
return
get_path
(
"purelib"
)
def
strip_module
(
filename
):
def
strip_module
(
filename
):
...
@@ -420,9 +412,7 @@ def scan_module(egg_dir, base, name, stubs):
...
@@ -420,9 +412,7 @@ def scan_module(egg_dir, base, name, stubs):
return True # Extension module
return True # Extension module
pkg = base[len(egg_dir) + 1:].replace(os.sep, '.')
pkg = base[len(egg_dir) + 1:].replace(os.sep, '.')
module = pkg + (pkg and '.' or '') + os.path.splitext(name)[0]
module = pkg + (pkg and '.' or '') + os.path.splitext(name)[0]
if six.PY2:
if sys.version_info < (3, 7):
skip = 8 # skip magic & date
elif sys.version_info < (3, 7):
skip = 12 # skip magic & date & file size
skip = 12 # skip magic & date & file size
else:
else:
skip = 16 # skip magic & reserved? & date & file size
skip = 16 # skip magic & reserved? & date & file size
...
@@ -453,7 +443,7 @@ def iter_symbols(code):
...
@@ -453,7 +443,7 @@ def iter_symbols(code):
for name in code.co_names:
for name in code.co_names:
yield name
yield name
for const in code.co_consts:
for const in code.co_consts:
if isinstance(const, s
ix.string_types
):
if isinstance(const, s
tr
):
yield const
yield const
elif isinstance(const, CodeType):
elif isinstance(const, CodeType):
for name in iter_symbols(const):
for name in iter_symbols(const):
...
...
setuptools/command/build_ext.py
View file @
fb7ab81a
import
os
import
os
import
sys
import
sys
import
itertools
import
itertools
from
importlib.machinery
import
EXTENSION_SUFFIXES
from
distutils.command.build_ext
import
build_ext
as
_du_build_ext
from
distutils.command.build_ext
import
build_ext
as
_du_build_ext
from
distutils.file_util
import
copy_file
from
distutils.file_util
import
copy_file
from
distutils.ccompiler
import
new_compiler
from
distutils.ccompiler
import
new_compiler
...
@@ -9,15 +10,6 @@ from distutils.errors import DistutilsError
...
@@ -9,15 +10,6 @@ from distutils.errors import DistutilsError
from
distutils
import
log
from
distutils
import
log
from
setuptools.extension
import
Library
from
setuptools.extension
import
Library
from
setuptools.extern
import
six
if
six
.
PY2
:
import
imp
EXTENSION_SUFFIXES
=
[
s
for
s
,
_
,
tp
in
imp
.
get_suffixes
()
if
tp
==
imp
.
C_EXTENSION
]
else
:
from
importlib.machinery
import
EXTENSION_SUFFIXES
try
:
try
:
# Attempt to use Cython for building extensions, if available
# Attempt to use Cython for building extensions, if available
...
@@ -115,11 +107,7 @@ class build_ext(_build_ext):
...
@@ -115,11 +107,7 @@ class build_ext(_build_ext):
filename
=
_build_ext
.
get_ext_filename
(
self
,
fullname
)
filename
=
_build_ext
.
get_ext_filename
(
self
,
fullname
)
if
fullname
in
self
.
ext_map
:
if
fullname
in
self
.
ext_map
:
ext
=
self
.
ext_map
[
fullname
]
ext
=
self
.
ext_map
[
fullname
]
use_abi3
=
(
use_abi3
=
getattr
(
ext
,
'py_limited_api'
)
and
get_abi3_suffix
()
not
six
.
PY2
and
getattr
(
ext
,
'py_limited_api'
)
and
get_abi3_suffix
()
)
if
use_abi3
:
if
use_abi3
:
so_ext
=
get_config_var
(
'EXT_SUFFIX'
)
so_ext
=
get_config_var
(
'EXT_SUFFIX'
)
filename
=
filename
[:
-
len
(
so_ext
)]
filename
=
filename
[:
-
len
(
so_ext
)]
...
...
setuptools/command/build_py.py
View file @
fb7ab81a
...
@@ -9,9 +9,6 @@ import distutils.errors
...
@@ -9,9 +9,6 @@ import distutils.errors
import
itertools
import
itertools
import
stat
import
stat
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
,
filter
,
filterfalse
try
:
try
:
from
setuptools.lib2to3_ex
import
Mixin2to3
from
setuptools.lib2to3_ex
import
Mixin2to3
except
ImportError
:
except
ImportError
:
...
@@ -73,9 +70,6 @@ class build_py(orig.build_py, Mixin2to3):
...
@@ -73,9 +70,6 @@ class build_py(orig.build_py, Mixin2to3):
return
orig
.
build_py
.
__getattr__
(
self
,
attr
)
return
orig
.
build_py
.
__getattr__
(
self
,
attr
)
def
build_module
(
self
,
module
,
module_file
,
package
):
def
build_module
(
self
,
module
,
module_file
,
package
):
if
six
.
PY2
and
isinstance
(
package
,
six
.
string_types
):
# avoid errors on Python 2 when unicode is passed (#190)
package
=
package
.
split
(
'.'
)
outfile
,
copied
=
orig
.
build_py
.
build_module
(
self
,
module
,
module_file
,
outfile
,
copied
=
orig
.
build_py
.
build_module
(
self
,
module
,
module_file
,
package
)
package
)
if
copied
:
if
copied
:
...
@@ -249,7 +243,7 @@ def _unique_everseen(iterable, key=None):
...
@@ -249,7 +243,7 @@ def _unique_everseen(iterable, key=None):
seen
=
set
()
seen
=
set
()
seen_add
=
seen
.
add
seen_add
=
seen
.
add
if
key
is
None
:
if
key
is
None
:
for
element
in
filterfalse
(
seen
.
__contains__
,
iterable
):
for
element
in
itertools
.
filterfalse
(
seen
.
__contains__
,
iterable
):
seen_add
(
element
)
seen_add
(
element
)
yield
element
yield
element
else
:
else
:
...
...
setuptools/command/develop.py
View file @
fb7ab81a
...
@@ -5,15 +5,11 @@ import os
...
@@ -5,15 +5,11 @@ import os
import
glob
import
glob
import
io
import
io
from
setuptools.extern
import
six
import
pkg_resources
import
pkg_resources
from
setuptools.command.easy_install
import
easy_install
from
setuptools.command.easy_install
import
easy_install
from
setuptools
import
namespaces
from
setuptools
import
namespaces
import
setuptools
import
setuptools
__metaclass__
=
type
class
develop
(
namespaces
.
DevelopInstaller
,
easy_install
):
class
develop
(
namespaces
.
DevelopInstaller
,
easy_install
):
"""Set up package for development"""
"""Set up package for development"""
...
@@ -108,7 +104,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
...
@@ -108,7 +104,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
return
path_to_setup
return
path_to_setup
def
install_for_development
(
self
):
def
install_for_development
(
self
):
if
not
six
.
PY2
and
getattr
(
self
.
distribution
,
'use_2to3'
,
False
):
if
getattr
(
self
.
distribution
,
'use_2to3'
,
False
):
# If we run 2to3 we can not do this inplace:
# If we run 2to3 we can not do this inplace:
# Ensure metadata is up-to-date
# Ensure metadata is up-to-date
...
...
setuptools/command/easy_install.py
View file @
fb7ab81a
...
@@ -38,18 +38,15 @@ import contextlib
...
@@ -38,18 +38,15 @@ import contextlib
import
subprocess
import
subprocess
import
shlex
import
shlex
import
io
import
io
import
configparser
from
sysconfig
import
get_config_vars
,
get_path
from
sysconfig
import
get_config_vars
,
get_path
from
setuptools
import
SetuptoolsDeprecationWarning
from
setuptools
import
SetuptoolsDeprecationWarning
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
configparser
,
map
from
setuptools
import
Command
from
setuptools
import
Command
from
setuptools.sandbox
import
run_setup
from
setuptools.sandbox
import
run_setup
from
setuptools.py27compat
import
rmtree_safe
from
setuptools.command
import
setopt
from
setuptools.command
import
setopt
from
setuptools.archive_util
import
unpack_archive
from
setuptools.archive_util
import
unpack_archive
from
setuptools.package_index
import
(
from
setuptools.package_index
import
(
...
@@ -65,8 +62,6 @@ from pkg_resources import (
...
@@ -65,8 +62,6 @@ from pkg_resources import (
)
)
import
pkg_resources
import
pkg_resources
__metaclass__
=
type
# Turn on PEP440Warnings
# Turn on PEP440Warnings
warnings
.
filterwarnings
(
"default"
,
category
=
pkg_resources
.
PEP440Warning
)
warnings
.
filterwarnings
(
"default"
,
category
=
pkg_resources
.
PEP440Warning
)
...
@@ -96,23 +91,11 @@ def samefile(p1, p2):
...
@@ -96,23 +91,11 @@ def samefile(p1, p2):
return
norm_p1
==
norm_p2
return
norm_p1
==
norm_p2
if
six
.
PY2
:
def
_to_bytes
(
s
):
def
_to_bytes
(
s
):
return
s
def
isascii
(
s
):
try
:
six
.
text_type
(
s
,
'ascii'
)
return
True
except
UnicodeError
:
return
False
else
:
def
_to_bytes
(
s
):
return
s
.
encode
(
'utf8'
)
return
s
.
encode
(
'utf8'
)
def
isascii
(
s
):
def
isascii
(
s
):
try
:
try
:
s
.
encode
(
'ascii'
)
s
.
encode
(
'ascii'
)
return
True
return
True
...
@@ -341,7 +324,7 @@ class easy_install(Command):
...
@@ -341,7 +324,7 @@ class easy_install(Command):
self
.
local_index
=
Environment
(
self
.
shadow_path
+
sys
.
path
)
self
.
local_index
=
Environment
(
self
.
shadow_path
+
sys
.
path
)
if
self
.
find_links
is
not
None
:
if
self
.
find_links
is
not
None
:
if
isinstance
(
self
.
find_links
,
s
ix
.
string_types
):
if
isinstance
(
self
.
find_links
,
s
tr
):
self
.
find_links
=
self
.
find_links
.
split
()
self
.
find_links
=
self
.
find_links
.
split
()
else
:
else
:
self
.
find_links
=
[]
self
.
find_links
=
[]
...
@@ -650,7 +633,7 @@ class easy_install(Command):
...
@@ -650,7 +633,7 @@ class easy_install(Command):
# cast to str as workaround for #709 and #710 and #712
# cast to str as workaround for #709 and #710 and #712
yield
str
(
tmpdir
)
yield
str
(
tmpdir
)
finally
:
finally
:
os
.
path
.
exists
(
tmpdir
)
and
rmtree
(
rmtree_safe
(
tmpdir
)
)
os
.
path
.
exists
(
tmpdir
)
and
rmtree
(
tmpdir
)
def
easy_install
(
self
,
spec
,
deps
=
False
):
def
easy_install
(
self
,
spec
,
deps
=
False
):
with
self
.
_tmpdir
()
as
tmpdir
:
with
self
.
_tmpdir
()
as
tmpdir
:
...
@@ -1318,7 +1301,7 @@ class easy_install(Command):
...
@@ -1318,7 +1301,7 @@ class easy_install(Command):
if
not
self
.
user
:
if
not
self
.
user
:
return
return
home
=
convert_path
(
os
.
path
.
expanduser
(
"~"
))
home
=
convert_path
(
os
.
path
.
expanduser
(
"~"
))
for
name
,
path
in
s
ix
.
iteritems
(
self
.
config_vars
):
for
name
,
path
in
s
elf
.
config_vars
.
items
(
):
if
path
.
startswith
(
home
)
and
not
os
.
path
.
isdir
(
path
):
if
path
.
startswith
(
home
)
and
not
os
.
path
.
isdir
(
path
):
self
.
debug_print
(
"os.makedirs('%s', 0o700)"
%
path
)
self
.
debug_print
(
"os.makedirs('%s', 0o700)"
%
path
)
os
.
makedirs
(
path
,
0o700
)
os
.
makedirs
(
path
,
0o700
)
...
@@ -1499,7 +1482,7 @@ def extract_wininst_cfg(dist_filename):
...
@@ -1499,7 +1482,7 @@ def extract_wininst_cfg(dist_filename):
# Now the config is in bytes, but for RawConfigParser, it should
# Now the config is in bytes, but for RawConfigParser, it should
# be text, so decode it.
# be text, so decode it.
config
=
config
.
decode
(
sys
.
getfilesystemencoding
())
config
=
config
.
decode
(
sys
.
getfilesystemencoding
())
cfg
.
readfp
(
six
.
StringIO
(
config
))
cfg
.
readfp
(
io
.
StringIO
(
config
))
except
configparser
.
Error
:
except
configparser
.
Error
:
return
None
return
None
if
not
cfg
.
has_section
(
'metadata'
)
or
not
cfg
.
has_section
(
'Setup'
):
if
not
cfg
.
has_section
(
'metadata'
)
or
not
cfg
.
has_section
(
'Setup'
):
...
@@ -1534,9 +1517,7 @@ def get_exe_prefixes(exe_filename):
...
@@ -1534,9 +1517,7 @@ def get_exe_prefixes(exe_filename):
if
name
.
endswith
(
'-nspkg.pth'
):
if
name
.
endswith
(
'-nspkg.pth'
):
continue
continue
if
parts
[
0
].
upper
()
in
(
'PURELIB'
,
'PLATLIB'
):
if
parts
[
0
].
upper
()
in
(
'PURELIB'
,
'PLATLIB'
):
contents
=
z
.
read
(
name
)
contents
=
z
.
read
(
name
).
decode
()
if
not
six
.
PY2
:
contents
=
contents
.
decode
()
for
pth
in
yield_lines
(
contents
):
for
pth
in
yield_lines
(
contents
):
pth
=
pth
.
strip
().
replace
(
'
\
\
'
,
'/'
)
pth
=
pth
.
strip
().
replace
(
'
\
\
'
,
'/'
)
if
not
pth
.
startswith
(
'import'
):
if
not
pth
.
startswith
(
'import'
):
...
@@ -1700,7 +1681,8 @@ def auto_chmod(func, arg, exc):
...
@@ -1700,7 +1681,8 @@ def auto_chmod(func, arg, exc):
chmod
(
arg
,
stat
.
S_IWRITE
)
chmod
(
arg
,
stat
.
S_IWRITE
)
return
func
(
arg
)
return
func
(
arg
)
et
,
ev
,
_
=
sys
.
exc_info
()
et
,
ev
,
_
=
sys
.
exc_info
()
six
.
reraise
(
et
,
(
ev
[
0
],
ev
[
1
]
+
(
" %s %s"
%
(
func
,
arg
))))
# TODO: This code doesn't make sense. What is it trying to do?
raise
(
ev
[
0
],
ev
[
1
]
+
(
" %s %s"
%
(
func
,
arg
)))
def
update_dist_caches
(
dist_path
,
fix_zipimporter_caches
):
def
update_dist_caches
(
dist_path
,
fix_zipimporter_caches
):
...
@@ -2263,9 +2245,6 @@ def get_win_launcher(type):
...
@@ -2263,9 +2245,6 @@ def get_win_launcher(type):
def
load_launcher_manifest
(
name
):
def
load_launcher_manifest
(
name
):
manifest
=
pkg_resources
.
resource_string
(
__name__
,
'launcher manifest.xml'
)
manifest
=
pkg_resources
.
resource_string
(
__name__
,
'launcher manifest.xml'
)
if
six
.
PY2
:
return
manifest
%
vars
()
else
:
return
manifest
.
decode
(
'utf-8'
)
%
vars
()
return
manifest
.
decode
(
'utf-8'
)
%
vars
()
...
...
setuptools/command/egg_info.py
View file @
fb7ab81a
...
@@ -16,9 +16,6 @@ import warnings
...
@@ -16,9 +16,6 @@ import warnings
import
time
import
time
import
collections
import
collections
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
from
setuptools
import
Command
from
setuptools
import
Command
from
setuptools.command.sdist
import
sdist
from
setuptools.command.sdist
import
sdist
from
setuptools.command.sdist
import
walk_revctrl
from
setuptools.command.sdist
import
walk_revctrl
...
@@ -267,7 +264,6 @@ class egg_info(InfoCommon, Command):
...
@@ -267,7 +264,6 @@ class egg_info(InfoCommon, Command):
to the file.
to the file.
"""
"""
log.info("writing %s to %s", what, filename)
log.info("writing %s to %s", what, filename)
if not six.PY2:
data = data.encode("utf-8")
data = data.encode("utf-8")
if not self.dry_run:
if not self.dry_run:
f = open(filename, '
wb
')
f = open(filename, '
wb
')
...
@@ -647,7 +643,7 @@ def _write_requirements(stream, reqs):
...
@@ -647,7 +643,7 @@ def _write_requirements(stream, reqs):
def
write_requirements
(
cmd
,
basename
,
filename
):
def
write_requirements
(
cmd
,
basename
,
filename
):
dist
=
cmd
.
distribution
dist
=
cmd
.
distribution
data
=
six
.
StringIO
()
data
=
io
.
StringIO
()
_write_requirements
(
data
,
dist
.
install_requires
)
_write_requirements
(
data
,
dist
.
install_requires
)
extras_require
=
dist
.
extras_require
or
{}
extras_require
=
dist
.
extras_require
or
{}
for
extra
in
sorted
(
extras_require
):
for
extra
in
sorted
(
extras_require
):
...
@@ -687,12 +683,12 @@ def write_arg(cmd, basename, filename, force=False):
...
@@ -687,12 +683,12 @@ def write_arg(cmd, basename, filename, force=False):
def
write_entries
(
cmd
,
basename
,
filename
):
def
write_entries
(
cmd
,
basename
,
filename
):
ep
=
cmd
.
distribution
.
entry_points
ep
=
cmd
.
distribution
.
entry_points
if
isinstance
(
ep
,
s
ix
.
string_types
)
or
ep
is
None
:
if
isinstance
(
ep
,
s
tr
)
or
ep
is
None
:
data
=
ep
data
=
ep
elif
ep
is
not
None
:
elif
ep
is
not
None
:
data
=
[]
data
=
[]
for
section
,
contents
in
sorted
(
ep
.
items
()):
for
section
,
contents
in
sorted
(
ep
.
items
()):
if
not
isinstance
(
contents
,
s
ix
.
string_types
):
if
not
isinstance
(
contents
,
s
tr
):
contents
=
EntryPoint
.
parse_group
(
section
,
contents
)
contents
=
EntryPoint
.
parse_group
(
section
,
contents
)
contents
=
'
\
n
'
.
join
(
sorted
(
map
(
str
,
contents
.
values
())))
contents
=
'
\
n
'
.
join
(
sorted
(
map
(
str
,
contents
.
values
())))
data
.
append
(
'[%s]
\
n
%s
\
n
\
n
'
%
(
section
,
contents
))
data
.
append
(
'[%s]
\
n
%s
\
n
\
n
'
%
(
section
,
contents
))
...
...
setuptools/command/py36compat.py
View file @
fb7ab81a
...
@@ -3,8 +3,6 @@ from glob import glob
...
@@ -3,8 +3,6 @@ from glob import glob
from
distutils.util
import
convert_path
from
distutils.util
import
convert_path
from
distutils.command
import
sdist
from
distutils.command
import
sdist
from
setuptools.extern.six.moves
import
filter
class
sdist_add_defaults
:
class
sdist_add_defaults
:
"""
"""
...
...
setuptools/command/rotate.py
View file @
fb7ab81a
...
@@ -4,8 +4,6 @@ from distutils.errors import DistutilsOptionError
...
@@ -4,8 +4,6 @@ from distutils.errors import DistutilsOptionError
import
os
import
os
import
shutil
import
shutil
from
setuptools.extern
import
six
from
setuptools
import
Command
from
setuptools
import
Command
...
@@ -38,7 +36,7 @@ class rotate(Command):
...
@@ -38,7 +36,7 @@ class rotate(Command):
self
.
keep
=
int
(
self
.
keep
)
self
.
keep
=
int
(
self
.
keep
)
except
ValueError
as
e
:
except
ValueError
as
e
:
raise
DistutilsOptionError
(
"--keep must be an integer"
)
from
e
raise
DistutilsOptionError
(
"--keep must be an integer"
)
from
e
if
isinstance
(
self
.
match
,
s
ix
.
string_types
):
if
isinstance
(
self
.
match
,
s
tr
):
self
.
match
=
[
self
.
match
=
[
convert_path
(
p
.
strip
())
for
p
in
self
.
match
.
split
(
','
)
convert_path
(
p
.
strip
())
for
p
in
self
.
match
.
split
(
','
)
]
]
...
...
setuptools/command/sdist.py
View file @
fb7ab81a
...
@@ -5,7 +5,7 @@ import sys
...
@@ -5,7 +5,7 @@ import sys
import
io
import
io
import
contextlib
import
contextlib
from
setuptools.extern
import
six
,
ordered_set
from
setuptools.extern
import
ordered_set
from
.py36compat
import
sdist_add_defaults
from
.py36compat
import
sdist_add_defaults
...
@@ -98,33 +98,7 @@ class sdist(sdist_add_defaults, orig.sdist):
...
@@ -98,33 +98,7 @@ class sdist(sdist_add_defaults, orig.sdist):
if
orig_val
is
not
NoValue
:
if
orig_val
is
not
NoValue
:
setattr
(
os
,
'link'
,
orig_val
)
setattr
(
os
,
'link'
,
orig_val
)
def
__read_template_hack
(
self
):
# This grody hack closes the template file (MANIFEST.in) if an
# exception occurs during read_template.
# Doing so prevents an error when easy_install attempts to delete the
# file.
try
:
orig
.
sdist
.
read_template
(
self
)
except
Exception
:
_
,
_
,
tb
=
sys
.
exc_info
()
tb
.
tb_next
.
tb_frame
.
f_locals
[
'template'
].
close
()
raise
# Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle
# has been fixed, so only override the method if we're using an earlier
# Python.
has_leaky_handle
=
(
sys
.
version_info
<
(
2
,
7
,
2
)
or
(
3
,
0
)
<=
sys
.
version_info
<
(
3
,
1
,
4
)
or
(
3
,
2
)
<=
sys
.
version_info
<
(
3
,
2
,
1
)
)
if
has_leaky_handle
:
read_template
=
__read_template_hack
def
_add_defaults_optional
(
self
):
def
_add_defaults_optional
(
self
):
if
six
.
PY2
:
sdist_add_defaults
.
_add_defaults_optional
(
self
)
else
:
super
().
_add_defaults_optional
()
super
().
_add_defaults_optional
()
if
os
.
path
.
isfile
(
'pyproject.toml'
):
if
os
.
path
.
isfile
(
'pyproject.toml'
):
self
.
filelist
.
append
(
'pyproject.toml'
)
self
.
filelist
.
append
(
'pyproject.toml'
)
...
@@ -158,9 +132,6 @@ class sdist(sdist_add_defaults, orig.sdist):
...
@@ -158,9 +132,6 @@ class sdist(sdist_add_defaults, orig.sdist):
def
_add_defaults_data_files
(
self
):
def
_add_defaults_data_files
(
self
):
try
:
try
:
if
six
.
PY2
:
sdist_add_defaults
.
_add_defaults_data_files
(
self
)
else
:
super
().
_add_defaults_data_files
()
super
().
_add_defaults_data_files
()
except
TypeError
:
except
TypeError
:
log
.
warn
(
"data_files contains unexpected objects"
)
log
.
warn
(
"data_files contains unexpected objects"
)
...
@@ -207,7 +178,6 @@ class sdist(sdist_add_defaults, orig.sdist):
...
@@ -207,7 +178,6 @@ class sdist(sdist_add_defaults, orig.sdist):
manifest
=
open
(
self
.
manifest
,
'rb'
)
manifest
=
open
(
self
.
manifest
,
'rb'
)
for
line
in
manifest
:
for
line
in
manifest
:
# The manifest must contain UTF-8. See #303.
# The manifest must contain UTF-8. See #303.
if
not
six
.
PY2
:
try
:
try
:
line
=
line
.
decode
(
'UTF-8'
)
line
=
line
.
decode
(
'UTF-8'
)
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
...
...
setuptools/command/setopt.py
View file @
fb7ab81a
...
@@ -3,8 +3,7 @@ from distutils import log
...
@@ -3,8 +3,7 @@ from distutils import log
from
distutils.errors
import
DistutilsOptionError
from
distutils.errors
import
DistutilsOptionError
import
distutils
import
distutils
import
os
import
os
import
configparser
from
setuptools.extern.six.moves
import
configparser
from
setuptools
import
Command
from
setuptools
import
Command
...
...
setuptools/command/test.py
View file @
fb7ab81a
...
@@ -8,17 +8,12 @@ from distutils.errors import DistutilsError, DistutilsOptionError
...
@@ -8,17 +8,12 @@ from distutils.errors import DistutilsError, DistutilsOptionError
from
distutils
import
log
from
distutils
import
log
from
unittest
import
TestLoader
from
unittest
import
TestLoader
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
,
filter
from
pkg_resources
import
(
resource_listdir
,
resource_exists
,
normalize_path
,
from
pkg_resources
import
(
resource_listdir
,
resource_exists
,
normalize_path
,
working_set
,
_namespace_packages
,
evaluate_marker
,
working_set
,
_namespace_packages
,
evaluate_marker
,
add_activation_listener
,
require
,
EntryPoint
)
add_activation_listener
,
require
,
EntryPoint
)
from
setuptools
import
Command
from
setuptools
import
Command
from
.build_py
import
_unique_everseen
from
.build_py
import
_unique_everseen
__metaclass__
=
type
class
ScanningLoader
(
TestLoader
):
class
ScanningLoader
(
TestLoader
):
...
@@ -129,8 +124,7 @@ class test(Command):
...
@@ -129,8 +124,7 @@ class test(Command):
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
def
project_on_sys_path
(
self
,
include_dists
=
[]):
def
project_on_sys_path
(
self
,
include_dists
=
[]):
with_2to3
=
not
six
.
PY2
and
getattr
(
with_2to3
=
getattr
(
self
.
distribution
,
'use_2to3'
,
False
)
self
.
distribution
,
'use_2to3'
,
False
)
if
with_2to3
:
if
with_2to3
:
# If we run 2to3 we can not do this inplace:
# If we run 2to3 we can not do this inplace:
...
@@ -241,7 +235,7 @@ class test(Command):
...
@@ -241,7 +235,7 @@ class test(Command):
# Purge modules under test from sys.modules. The test loader will
# Purge modules under test from sys.modules. The test loader will
# re-import them from the build location. Required when 2to3 is used
# re-import them from the build location. Required when 2to3 is used
# with namespace packages.
# with namespace packages.
if
not
six
.
PY2
and
getattr
(
self
.
distribution
,
'use_2to3'
,
False
):
if
getattr
(
self
.
distribution
,
'use_2to3'
,
False
):
module
=
self
.
test_suite
.
split
(
'.'
)[
0
]
module
=
self
.
test_suite
.
split
(
'.'
)[
0
]
if
module
in
_namespace_packages
:
if
module
in
_namespace_packages
:
del_modules
=
[]
del_modules
=
[]
...
...
setuptools/command/upload_docs.py
View file @
fb7ab81a
...
@@ -15,17 +15,15 @@ import tempfile
...
@@ -15,17 +15,15 @@ import tempfile
import
shutil
import
shutil
import
itertools
import
itertools
import
functools
import
functools
import
http.client
from
setuptools.extern
import
six
import
urllib.parse
from
setuptools.extern.six.moves
import
http_client
,
urllib
from
pkg_resources
import
iter_entry_points
from
pkg_resources
import
iter_entry_points
from
.upload
import
upload
from
.upload
import
upload
def
_encode
(
s
):
def
_encode
(
s
):
errors
=
'strict'
if
six
.
PY2
else
'surrogateescape'
return
s
.
encode
(
'utf-8'
,
'surrogateescape'
)
return
s
.
encode
(
'utf-8'
,
errors
)
class
upload_docs
(
upload
):
class
upload_docs
(
upload
):
...
@@ -152,9 +150,7 @@ class upload_docs(upload):
...
@@ -152,9 +150,7 @@ class upload_docs(upload):
}
}
# set up the authentication
# set up the authentication
credentials
=
_encode
(
self
.
username
+
':'
+
self
.
password
)
credentials
=
_encode
(
self
.
username
+
':'
+
self
.
password
)
credentials
=
standard_b64encode
(
credentials
)
credentials
=
standard_b64encode
(
credentials
).
decode
(
'ascii'
)
if
not
six
.
PY2
:
credentials
=
credentials
.
decode
(
'ascii'
)
auth
=
"Basic "
+
credentials
auth
=
"Basic "
+
credentials
body
,
ct
=
self
.
_build_multipart
(
data
)
body
,
ct
=
self
.
_build_multipart
(
data
)
...
@@ -169,9 +165,9 @@ class upload_docs(upload):
...
@@ -169,9 +165,9 @@ class upload_docs(upload):
urllib
.
parse
.
urlparse
(
self
.
repository
)
urllib
.
parse
.
urlparse
(
self
.
repository
)
assert
not
params
and
not
query
and
not
fragments
assert
not
params
and
not
query
and
not
fragments
if
schema
==
'http'
:
if
schema
==
'http'
:
conn
=
http
_
client
.
HTTPConnection
(
netloc
)
conn
=
http
.
client
.
HTTPConnection
(
netloc
)
elif
schema
==
'https'
:
elif
schema
==
'https'
:
conn
=
http
_
client
.
HTTPSConnection
(
netloc
)
conn
=
http
.
client
.
HTTPSConnection
(
netloc
)
else
:
else
:
raise
AssertionError
(
"unsupported schema "
+
schema
)
raise
AssertionError
(
"unsupported schema "
+
schema
)
...
...
setuptools/config.py
View file @
fb7ab81a
from
__future__
import
absolute_import
,
unicode_literals
import
ast
import
ast
import
io
import
io
import
os
import
os
...
@@ -15,10 +14,6 @@ import contextlib
...
@@ -15,10 +14,6 @@ import contextlib
from
distutils.errors
import
DistutilsOptionError
,
DistutilsFileError
from
distutils.errors
import
DistutilsOptionError
,
DistutilsFileError
from
setuptools.extern.packaging.version
import
LegacyVersion
,
parse
from
setuptools.extern.packaging.version
import
LegacyVersion
,
parse
from
setuptools.extern.packaging.specifiers
import
SpecifierSet
from
setuptools.extern.packaging.specifiers
import
SpecifierSet
from
setuptools.extern.six
import
string_types
,
PY3
__metaclass__
=
type
class
StaticModule
:
class
StaticModule
:
...
@@ -324,7 +319,7 @@ class ConfigHandler:
...
@@ -324,7 +319,7 @@ class ConfigHandler:
"""
"""
include_directive
=
'file:'
include_directive
=
'file:'
if
not
isinstance
(
value
,
str
ing_types
):
if
not
isinstance
(
value
,
str
):
return
value
return
value
if
not
value
.
startswith
(
include_directive
):
if
not
value
.
startswith
(
include_directive
):
...
@@ -559,7 +554,7 @@ class ConfigMetadataHandler(ConfigHandler):
...
@@ -559,7 +554,7 @@ class ConfigMetadataHandler(ConfigHandler):
if
callable
(
version
):
if
callable
(
version
):
version
=
version
()
version
=
version
()
if
not
isinstance
(
version
,
str
ing_types
):
if
not
isinstance
(
version
,
str
):
if
hasattr
(
version
,
'__iter__'
):
if
hasattr
(
version
,
'__iter__'
):
version
=
'.'
.
join
(
map
(
str
,
version
))
version
=
'.'
.
join
(
map
(
str
,
version
))
else
:
else
:
...
@@ -614,9 +609,6 @@ class ConfigOptionsHandler(ConfigHandler):
...
@@ -614,9 +609,6 @@ class ConfigOptionsHandler(ConfigHandler):
return
self
.
_parse_list
(
value
)
return
self
.
_parse_list
(
value
)
findns
=
trimmed_value
==
find_directives
[
1
]
findns
=
trimmed_value
==
find_directives
[
1
]
if
findns
and
not
PY3
:
raise
DistutilsOptionError
(
'find_namespace: directive is unsupported on Python < 3.3'
)
# Read function arguments from a dedicated section.
# Read function arguments from a dedicated section.
find_kwargs
=
self
.
parse_section_packages__find
(
find_kwargs
=
self
.
parse_section_packages__find
(
...
...
setuptools/depends.py
View file @
fb7ab81a
import
sys
import
sys
import
marshal
import
marshal
import
contextlib
import
contextlib
import
dis
from
distutils.version
import
StrictVersion
from
distutils.version
import
StrictVersion
from
.py33compat
import
Bytecode
from
._imp
import
find_module
,
PY_COMPILED
,
PY_FROZEN
,
PY_SOURCE
from
.
import
_imp
from
.py27compat
import
find_module
,
PY_COMPILED
,
PY_FROZEN
,
PY_SOURCE
from
.
import
py27compat
__all__
=
[
__all__
=
[
...
@@ -111,12 +110,12 @@ def get_module_constant(module, symbol, default=-1, paths=None):
...
@@ -111,12 +110,12 @@ def get_module_constant(module, symbol, default=-1, paths=None):
f
.
read
(
8
)
# skip magic & date
f
.
read
(
8
)
# skip magic & date
code
=
marshal
.
load
(
f
)
code
=
marshal
.
load
(
f
)
elif
kind
==
PY_FROZEN
:
elif
kind
==
PY_FROZEN
:
code
=
py27compat
.
get_frozen_object
(
module
,
paths
)
code
=
_imp
.
get_frozen_object
(
module
,
paths
)
elif
kind
==
PY_SOURCE
:
elif
kind
==
PY_SOURCE
:
code
=
compile
(
f
.
read
(),
path
,
'exec'
)
code
=
compile
(
f
.
read
(),
path
,
'exec'
)
else
:
else
:
# Not something we can parse; we'll have to import it. :(
# Not something we can parse; we'll have to import it. :(
imported
=
py27compat
.
get_module
(
module
,
paths
,
info
)
imported
=
_imp
.
get_module
(
module
,
paths
,
info
)
return
getattr
(
imported
,
symbol
,
None
)
return
getattr
(
imported
,
symbol
,
None
)
return
extract_constant
(
code
,
symbol
,
default
)
return
extract_constant
(
code
,
symbol
,
default
)
...
@@ -146,7 +145,7 @@ def extract_constant(code, symbol, default=-1):
...
@@ -146,7 +145,7 @@ def extract_constant(code, symbol, default=-1):
const
=
default
const
=
default
for
byte_code
in
Bytecode
(
code
):
for
byte_code
in
dis
.
Bytecode
(
code
):
op
=
byte_code
.
opcode
op
=
byte_code
.
opcode
arg
=
byte_code
.
arg
arg
=
byte_code
.
arg
...
...
setuptools/dist.py
View file @
fb7ab81a
...
@@ -23,10 +23,8 @@ from distutils.errors import DistutilsOptionError, DistutilsSetupError
...
@@ -23,10 +23,8 @@ from distutils.errors import DistutilsOptionError, DistutilsSetupError
from
distutils.util
import
rfc822_escape
from
distutils.util
import
rfc822_escape
from
distutils.version
import
StrictVersion
from
distutils.version
import
StrictVersion
from
setuptools.extern
import
six
from
setuptools.extern
import
packaging
from
setuptools.extern
import
packaging
from
setuptools.extern
import
ordered_set
from
setuptools.extern
import
ordered_set
from
setuptools.extern.six.moves
import
map
,
filter
,
filterfalse
from
.
import
SetuptoolsDeprecationWarning
from
.
import
SetuptoolsDeprecationWarning
...
@@ -126,10 +124,6 @@ def write_pkg_file(self, file):
...
@@ -126,10 +124,6 @@ def write_pkg_file(self, file):
"""
"""
version
=
self
.
get_metadata_version
()
version
=
self
.
get_metadata_version
()
if
six
.
PY2
:
def
write_field
(
key
,
value
):
file
.
write
(
"%s: %s
\
n
"
%
(
key
,
self
.
_encode_field
(
value
)))
else
:
def
write_field
(
key
,
value
):
def
write_field
(
key
,
value
):
file
.
write
(
"%s: %s
\
n
"
%
(
key
,
value
))
file
.
write
(
"%s: %s
\
n
"
%
(
key
,
value
))
...
@@ -308,7 +302,7 @@ def check_entry_points(dist, attr, value):
...
@@ -308,7 +302,7 @@ def check_entry_points(dist, attr, value):
def
check_test_suite
(
dist
,
attr
,
value
):
def
check_test_suite
(
dist
,
attr
,
value
):
if
not
isinstance
(
value
,
s
ix
.
string_types
):
if
not
isinstance
(
value
,
s
tr
):
raise
DistutilsSetupError
(
"test_suite must be a string"
)
raise
DistutilsSetupError
(
"test_suite must be a string"
)
...
@@ -319,7 +313,7 @@ def check_package_data(dist, attr, value):
...
@@ -319,7 +313,7 @@ def check_package_data(dist, attr, value):
"{!r} must be a dictionary mapping package names to lists of "
"{!r} must be a dictionary mapping package names to lists of "
"string wildcard patterns"
.
format
(
attr
))
"string wildcard patterns"
.
format
(
attr
))
for
k
,
v
in
value
.
items
():
for
k
,
v
in
value
.
items
():
if
not
isinstance
(
k
,
s
ix
.
string_types
):
if
not
isinstance
(
k
,
s
tr
):
raise
DistutilsSetupError
(
raise
DistutilsSetupError
(
"keys of {!r} dict must be strings (got {!r})"
"keys of {!r} dict must be strings (got {!r})"
.
format
(
attr
,
k
)
.
format
(
attr
,
k
)
...
@@ -537,7 +531,7 @@ class Distribution(_Distribution):
...
@@ -537,7 +531,7 @@ class Distribution(_Distribution):
spec_inst_reqs
=
getattr
(
self
,
'install_requires'
,
None
)
or
()
spec_inst_reqs
=
getattr
(
self
,
'install_requires'
,
None
)
or
()
inst_reqs
=
list
(
pkg_resources
.
parse_requirements
(
spec_inst_reqs
))
inst_reqs
=
list
(
pkg_resources
.
parse_requirements
(
spec_inst_reqs
))
simple_reqs
=
filter
(
is_simple_req
,
inst_reqs
)
simple_reqs
=
filter
(
is_simple_req
,
inst_reqs
)
complex_reqs
=
filterfalse
(
is_simple_req
,
inst_reqs
)
complex_reqs
=
itertools
.
filterfalse
(
is_simple_req
,
inst_reqs
)
self
.
install_requires
=
list
(
map
(
str
,
simple_reqs
))
self
.
install_requires
=
list
(
map
(
str
,
simple_reqs
))
for
r
in
complex_reqs
:
for
r
in
complex_reqs
:
...
@@ -560,10 +554,10 @@ class Distribution(_Distribution):
...
@@ -560,10 +554,10 @@ class Distribution(_Distribution):
this method provides the same functionality in subtly-improved
this method provides the same functionality in subtly-improved
ways.
ways.
"""
"""
from
setuptools.extern.six.moves.
configparser
import
ConfigParser
from
configparser
import
ConfigParser
# Ignore install directory options if we have a venv
# Ignore install directory options if we have a venv
if
not
six
.
PY2
and
sys
.
prefix
!=
sys
.
base_prefix
:
if
sys
.
prefix
!=
sys
.
base_prefix
:
ignore_options
=
[
ignore_options
=
[
'install-base'
,
'install-platbase'
,
'install-lib'
,
'install-base'
,
'install-platbase'
,
'install-lib'
,
'install-platlib'
,
'install-purelib'
,
'install-headers'
,
'install-platlib'
,
'install-purelib'
,
'install-headers'
,
...
@@ -585,14 +579,14 @@ class Distribution(_Distribution):
...
@@ -585,14 +579,14 @@ class Distribution(_Distribution):
with
io
.
open
(
filename
,
encoding
=
'utf-8'
)
as
reader
:
with
io
.
open
(
filename
,
encoding
=
'utf-8'
)
as
reader
:
if
DEBUG
:
if
DEBUG
:
self
.
announce
(
" reading {filename}"
.
format
(
**
locals
()))
self
.
announce
(
" reading {filename}"
.
format
(
**
locals
()))
(
parser
.
readfp
if
six
.
PY2
else
parser
.
read_file
)
(
reader
)
parser
.
read_file
(
reader
)
for
section
in
parser
.
sections
():
for
section
in
parser
.
sections
():
options
=
parser
.
options
(
section
)
options
=
parser
.
options
(
section
)
opt_dict
=
self
.
get_option_dict
(
section
)
opt_dict
=
self
.
get_option_dict
(
section
)
for
opt
in
options
:
for
opt
in
options
:
if
opt
!=
'__name__'
and
opt
not
in
ignore_options
:
if
opt
!=
'__name__'
and
opt
not
in
ignore_options
:
val
=
self
.
_try_str
(
parser
.
get
(
section
,
opt
)
)
val
=
parser
.
get
(
section
,
opt
)
opt
=
opt
.
replace
(
'-'
,
'_'
)
opt
=
opt
.
replace
(
'-'
,
'_'
)
opt_dict
[
opt
]
=
(
filename
,
val
)
opt_dict
[
opt
]
=
(
filename
,
val
)
...
@@ -616,26 +610,6 @@ class Distribution(_Distribution):
...
@@ -616,26 +610,6 @@ class Distribution(_Distribution):
except
ValueError
as
e
:
except
ValueError
as
e
:
raise
DistutilsOptionError
(
e
)
from
e
raise
DistutilsOptionError
(
e
)
from
e
@
staticmethod
def
_try_str
(
val
):
"""
On Python 2, much of distutils relies on string values being of
type 'str' (bytes) and not unicode text. If the value can be safely
encoded to bytes using the default encoding, prefer that.
Why the default encoding? Because that value can be implicitly
decoded back to text if needed.
Ref #1653
"""
if
not
six
.
PY2
:
return
val
try
:
return
val
.
encode
()
except
UnicodeEncodeError
:
pass
return
val
def
_set_command_options
(
self
,
command_obj
,
option_dict
=
None
):
def
_set_command_options
(
self
,
command_obj
,
option_dict
=
None
):
"""
"""
Set the options for 'command_obj' from 'option_dict'. Basically
Set the options for 'command_obj' from 'option_dict'. Basically
...
@@ -669,7 +643,7 @@ class Distribution(_Distribution):
...
@@ -669,7 +643,7 @@ class Distribution(_Distribution):
neg_opt
=
{}
neg_opt
=
{}
try
:
try
:
is_string
=
isinstance
(
value
,
s
ix
.
string_types
)
is_string
=
isinstance
(
value
,
s
tr
)
if
option
in
neg_opt
and
is_string
:
if
option
in
neg_opt
and
is_string
:
setattr
(
command_obj
,
neg_opt
[
option
],
not
strtobool
(
value
))
setattr
(
command_obj
,
neg_opt
[
option
],
not
strtobool
(
value
))
elif
option
in
bool_opts
and
is_string
:
elif
option
in
bool_opts
and
is_string
:
...
@@ -1003,7 +977,7 @@ class Distribution(_Distribution):
...
@@ -1003,7 +977,7 @@ class Distribution(_Distribution):
"""
"""
import
sys
import
sys
if
s
ix
.
PY2
or
s
elf
.
help_commands
:
if
self
.
help_commands
:
return
_Distribution
.
handle_display_options
(
self
,
option_order
)
return
_Distribution
.
handle_display_options
(
self
,
option_order
)
# Stdout may be StringIO (e.g. in tests)
# Stdout may be StringIO (e.g. in tests)
...
...
setuptools/extension.py
View file @
fb7ab81a
...
@@ -4,8 +4,6 @@ import distutils.core
...
@@ -4,8 +4,6 @@ import distutils.core
import
distutils.errors
import
distutils.errors
import
distutils.extension
import
distutils.extension
from
setuptools.extern.six.moves
import
map
from
.monkey
import
get_unpatched
from
.monkey
import
get_unpatched
...
...
setuptools/installer.py
View file @
fb7ab81a
...
@@ -2,20 +2,18 @@ import glob
...
@@ -2,20 +2,18 @@ import glob
import
os
import
os
import
subprocess
import
subprocess
import
sys
import
sys
import
tempfile
from
distutils
import
log
from
distutils
import
log
from
distutils.errors
import
DistutilsError
from
distutils.errors
import
DistutilsError
import
pkg_resources
import
pkg_resources
from
setuptools.command.easy_install
import
easy_install
from
setuptools.command.easy_install
import
easy_install
from
setuptools.extern
import
six
from
setuptools.wheel
import
Wheel
from
setuptools.wheel
import
Wheel
from
.py31compat
import
TemporaryDirectory
def
_fixup_find_links
(
find_links
):
def
_fixup_find_links
(
find_links
):
"""Ensure find-links option end-up being a list of strings."""
"""Ensure find-links option end-up being a list of strings."""
if
isinstance
(
find_links
,
s
ix
.
string_types
):
if
isinstance
(
find_links
,
s
tr
):
return
find_links
.
split
()
return
find_links
.
split
()
assert
isinstance
(
find_links
,
(
tuple
,
list
))
assert
isinstance
(
find_links
,
(
tuple
,
list
))
return
find_links
return
find_links
...
@@ -103,7 +101,7 @@ def fetch_build_egg(dist, req):
...
@@ -103,7 +101,7 @@ def fetch_build_egg(dist, req):
for
egg_dist
in
pkg_resources
.
find_distributions
(
eggs_dir
):
for
egg_dist
in
pkg_resources
.
find_distributions
(
eggs_dir
):
if
egg_dist
in
req
and
environment
.
can_add
(
egg_dist
):
if
egg_dist
in
req
and
environment
.
can_add
(
egg_dist
):
return
egg_dist
return
egg_dist
with
TemporaryDirectory
()
as
tmpdir
:
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
cmd
=
[
cmd
=
[
sys
.
executable
,
'-m'
,
'pip'
,
sys
.
executable
,
'-m'
,
'pip'
,
'--disable-pip-version-check'
,
'--disable-pip-version-check'
,
...
...
setuptools/lib2to3_ex.py
View file @
fb7ab81a
...
@@ -2,9 +2,6 @@
...
@@ -2,9 +2,6 @@
Customized Mixin2to3 support:
Customized Mixin2to3 support:
- adds support for converting doctests
- adds support for converting doctests
This module raises an ImportError on Python 2.
"""
"""
import
warnings
import
warnings
...
...
setuptools/monkey.py
View file @
fb7ab81a
...
@@ -10,8 +10,6 @@ import functools
...
@@ -10,8 +10,6 @@ import functools
from
importlib
import
import_module
from
importlib
import
import_module
import
inspect
import
inspect
from
setuptools.extern
import
six
import
setuptools
import
setuptools
__all__
=
[]
__all__
=
[]
...
@@ -37,7 +35,7 @@ def _get_mro(cls):
...
@@ -37,7 +35,7 @@ def _get_mro(cls):
def
get_unpatched
(
item
):
def
get_unpatched
(
item
):
lookup
=
(
lookup
=
(
get_unpatched_class
if
isinstance
(
item
,
six
.
class_types
)
else
get_unpatched_class
if
isinstance
(
item
,
type
)
else
get_unpatched_function
if
isinstance
(
item
,
types
.
FunctionType
)
else
get_unpatched_function
if
isinstance
(
item
,
types
.
FunctionType
)
else
lambda
item
:
None
lambda
item
:
None
)
)
...
...
setuptools/msvc.py
View file @
fb7ab81a
...
@@ -30,12 +30,10 @@ import subprocess
...
@@ -30,12 +30,10 @@ import subprocess
import
distutils.errors
import
distutils.errors
from
setuptools.extern.packaging.version
import
LegacyVersion
from
setuptools.extern.packaging.version
import
LegacyVersion
from
setuptools.extern.six.moves
import
filterfalse
from
.monkey
import
get_unpatched
from
.monkey
import
get_unpatched
if
platform
.
system
()
==
'Windows'
:
if
platform
.
system
()
==
'Windows'
:
from
setuptools.extern.six.moves
import
winreg
import
winreg
from
os
import
environ
from
os
import
environ
else
:
else
:
# Mock winreg and environ so the module can be imported on this platform.
# Mock winreg and environ so the module can be imported on this platform.
...
@@ -1820,7 +1818,7 @@ class EnvironmentInfo:
...
@@ -1820,7 +1818,7 @@ class EnvironmentInfo:
seen = set()
seen = set()
seen_add = seen.add
seen_add = seen.add
if key is None:
if key is None:
for element in filterfalse(seen.__contains__, iterable):
for element in
itertools.
filterfalse(seen.__contains__, iterable):
seen_add(element)
seen_add(element)
yield element
yield element
else:
else:
...
...
setuptools/namespaces.py
View file @
fb7ab81a
...
@@ -2,8 +2,6 @@ import os
...
@@ -2,8 +2,6 @@ import os
from
distutils
import
log
from
distutils
import
log
import
itertools
import
itertools
from
setuptools.extern.six.moves
import
map
flatten
=
itertools
.
chain
.
from_iterable
flatten
=
itertools
.
chain
.
from_iterable
...
@@ -72,8 +70,6 @@ class Installer:
...
@@ -72,8 +70,6 @@ class Installer:
return
"sys._getframe(1).f_locals['sitedir']"
return
"sys._getframe(1).f_locals['sitedir']"
def
_gen_nspkg_line
(
self
,
pkg
):
def
_gen_nspkg_line
(
self
,
pkg
):
# ensure pkg is not a unicode string under Python 2.7
pkg
=
str
(
pkg
)
pth
=
tuple
(
pkg
.
split
(
'.'
))
pth
=
tuple
(
pkg
.
split
(
'.'
))
root
=
self
.
_get_root
()
root
=
self
.
_get_root
()
tmpl_lines
=
self
.
_nspkg_tmpl
tmpl_lines
=
self
.
_nspkg_tmpl
...
...
setuptools/package_index.py
View file @
fb7ab81a
...
@@ -2,17 +2,21 @@
...
@@ -2,17 +2,21 @@
import
sys
import
sys
import
os
import
os
import
re
import
re
import
io
import
shutil
import
shutil
import
socket
import
socket
import
base64
import
base64
import
hashlib
import
hashlib
import
itertools
import
itertools
import
warnings
import
warnings
import
configparser
import
html
import
http.client
import
urllib.parse
import
urllib.request
import
urllib.error
from
functools
import
wraps
from
functools
import
wraps
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
urllib
,
http_client
,
configparser
,
map
import
setuptools
import
setuptools
from
pkg_resources
import
(
from
pkg_resources
import
(
CHECKOUT_DIST
,
Distribution
,
BINARY_DIST
,
normalize_path
,
SOURCE_DIST
,
CHECKOUT_DIST
,
Distribution
,
BINARY_DIST
,
normalize_path
,
SOURCE_DIST
,
...
@@ -23,12 +27,8 @@ from setuptools import ssl_support
...
@@ -23,12 +27,8 @@ from setuptools import ssl_support
from
distutils
import
log
from
distutils
import
log
from
distutils.errors
import
DistutilsError
from
distutils.errors
import
DistutilsError
from
fnmatch
import
translate
from
fnmatch
import
translate
from
setuptools.py27compat
import
get_all_headers
from
setuptools.py33compat
import
unescape
from
setuptools.wheel
import
Wheel
from
setuptools.wheel
import
Wheel
__metaclass__
=
type
EGG_FRAGMENT
=
re
.
compile
(
r'^egg=([-A-Za-z0-9_.+!]+)$'
)
EGG_FRAGMENT
=
re
.
compile
(
r'^egg=([-A-Za-z0-9_.+!]+)$'
)
HREF
=
re
.
compile
(
r"""href\
s*=
\s*['"]?([^'"> ]+)"""
,
re
.
I
)
HREF
=
re
.
compile
(
r"""href\
s*=
\s*['"]?([^'"> ]+)"""
,
re
.
I
)
PYPI_MD5
=
re
.
compile
(
PYPI_MD5
=
re
.
compile
(
...
@@ -191,7 +191,7 @@ def unique_everseen(iterable, key=None):
...
@@ -191,7 +191,7 @@ def unique_everseen(iterable, key=None):
seen = set()
seen = set()
seen_add = seen.add
seen_add = seen.add
if key is None:
if key is None:
for element in
six.move
s.filterfalse(seen.__contains__, iterable):
for element in
itertool
s.filterfalse(seen.__contains__, iterable):
seen_add(element)
seen_add(element)
yield element
yield element
else:
else:
...
@@ -740,7 +740,7 @@ class PackageIndex(Environment):
...
@@ -740,7 +740,7 @@ class PackageIndex(Environment):
size = -1
size = -1
if "content-length" in headers:
if "content-length" in headers:
# Some servers return multiple Content-Length headers :(
# Some servers return multiple Content-Length headers :(
sizes =
get_all_headers(headers,
'Content-Length')
sizes =
headers.get_all(
'Content-Length')
size = max(map(int, sizes))
size = max(map(int, sizes))
self.reporthook(url, filename, blocknum, bs, size)
self.reporthook(url, filename, blocknum, bs, size)
with open(filename, 'wb') as tfp:
with open(filename, 'wb') as tfp:
...
@@ -767,7 +767,7 @@ class PackageIndex(Environment):
...
@@ -767,7 +767,7 @@ class PackageIndex(Environment):
return local_open(url)
return local_open(url)
try:
try:
return open_with_auth(url, self.opener)
return open_with_auth(url, self.opener)
except (ValueError, http
_
client.InvalidURL) as v:
except (ValueError, http
.
client.InvalidURL) as v:
msg = ' '.join([str(arg) for arg in v.args])
msg = ' '.join([str(arg) for arg in v.args])
if warning:
if warning:
self.warn(warning, msg)
self.warn(warning, msg)
...
@@ -781,7 +781,7 @@ class PackageIndex(Environment):
...
@@ -781,7 +781,7 @@ class PackageIndex(Environment):
else:
else:
raise DistutilsError("Download error for %s: %s"
raise DistutilsError("Download error for %s: %s"
% (url, v.reason)) from v
% (url, v.reason)) from v
except http
_
client.BadStatusLine as v:
except http
.
client.BadStatusLine as v:
if warning:
if warning:
self.warn(warning, v.line)
self.warn(warning, v.line)
else:
else:
...
@@ -790,7 +790,7 @@ class PackageIndex(Environment):
...
@@ -790,7 +790,7 @@ class PackageIndex(Environment):
'down, %s' %
'down, %s' %
(url, v.line)
(url, v.line)
) from v
) from v
except (http
_
client.HTTPException, socket.error) as v:
except (http
.
client.HTTPException, socket.error) as v:
if warning:
if warning:
self.warn(warning, v)
self.warn(warning, v)
else:
else:
...
@@ -940,7 +940,7 @@ entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub
...
@@ -940,7 +940,7 @@ entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub
def decode_entity(match):
def decode_entity(match):
what = match.group(0)
what = match.group(0)
return unescape(what)
return
html.
unescape(what)
def htmldecode(text):
def htmldecode(text):
...
@@ -972,8 +972,7 @@ def socket_timeout(timeout=15):
...
@@ -972,8 +972,7 @@ def socket_timeout(timeout=15):
def _encode_auth(auth):
def _encode_auth(auth):
"""
"""
A
function
compatible
with
Python
2.3
-
3.3
that
will
encode
Encode
auth
from
a
URL
suitable
for
an
HTTP
header
.
auth
from
a
URL
suitable
for
an
HTTP
header
.
>>>
str
(
_encode_auth
(
'username%3Apassword'
))
>>>
str
(
_encode_auth
(
'username%3Apassword'
))
'dXNlcm5hbWU6cGFzc3dvcmQ='
'dXNlcm5hbWU6cGFzc3dvcmQ='
...
@@ -1056,7 +1055,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
...
@@ -1056,7 +1055,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
# Double scheme does not raise on macOS as revealed by a
# Double scheme does not raise on macOS as revealed by a
# failing test. We would expect "nonnumeric port". Refs #20.
# failing test. We would expect "nonnumeric port". Refs #20.
if netloc.endswith(':'):
if netloc.endswith(':'):
raise http
_
client.InvalidURL("nonnumeric port: ''")
raise http
.
client.InvalidURL("nonnumeric port: ''")
if scheme in ('http', 'https'):
if scheme in ('http', 'https'):
auth, address = _splituser(netloc)
auth, address = _splituser(netloc)
...
@@ -1136,5 +1135,5 @@ def local_open(url):
...
@@ -1136,5 +1135,5 @@ def local_open(url):
status, message, body = 404, "Path not found", "Not found"
status, message, body = 404, "Path not found", "Not found"
headers = {'content-type': 'text/html'}
headers = {'content-type': 'text/html'}
body_stream =
six
.StringIO(body)
body_stream =
io
.StringIO(body)
return urllib.error.HTTPError(url, status, message, headers, body_stream)
return urllib.error.HTTPError(url, status, message, headers, body_stream)
setuptools/py27compat.py
deleted
100644 → 0
View file @
4eb5b32f
"""
Compatibility Support for Python 2.7 and earlier
"""
import
sys
import
platform
from
setuptools.extern
import
six
def
get_all_headers
(
message
,
key
):
"""
Given an HTTPMessage, return all headers matching a given key.
"""
return
message
.
get_all
(
key
)
if
six
.
PY2
:
def
get_all_headers
(
message
,
key
):
# noqa
return
message
.
getheaders
(
key
)
linux_py2_ascii
=
(
platform
.
system
()
==
'Linux'
and
six
.
PY2
)
rmtree_safe
=
str
if
linux_py2_ascii
else
lambda
x
:
x
"""Workaround for http://bugs.python.org/issue24672"""
try
:
from
._imp
import
find_module
,
PY_COMPILED
,
PY_FROZEN
,
PY_SOURCE
from
._imp
import
get_frozen_object
,
get_module
except
ImportError
:
import
imp
from
imp
import
PY_COMPILED
,
PY_FROZEN
,
PY_SOURCE
# noqa
def
find_module
(
module
,
paths
=
None
):
"""Just like 'imp.find_module()', but with package support"""
parts
=
module
.
split
(
'.'
)
while
parts
:
part
=
parts
.
pop
(
0
)
f
,
path
,
(
suffix
,
mode
,
kind
)
=
info
=
imp
.
find_module
(
part
,
paths
)
if
kind
==
imp
.
PKG_DIRECTORY
:
parts
=
parts
or
[
'__init__'
]
paths
=
[
path
]
elif
parts
:
raise
ImportError
(
"Can't find %r in %s"
%
(
parts
,
module
))
return
info
def
get_frozen_object
(
module
,
paths
):
return
imp
.
get_frozen_object
(
module
)
def
get_module
(
module
,
paths
,
info
):
imp
.
load_module
(
module
,
*
info
)
return
sys
.
modules
[
module
]
setuptools/py31compat.py
deleted
100644 → 0
View file @
4eb5b32f
__all__
=
[]
__metaclass__
=
type
try
:
# Python >=3.2
from
tempfile
import
TemporaryDirectory
except
ImportError
:
import
shutil
import
tempfile
class
TemporaryDirectory
:
"""
Very simple temporary directory context manager.
Will try to delete afterward, but will also ignore OS and similar
errors on deletion.
"""
def
__init__
(
self
,
**
kwargs
):
self
.
name
=
None
# Handle mkdtemp raising an exception
self
.
name
=
tempfile
.
mkdtemp
(
**
kwargs
)
def
__enter__
(
self
):
return
self
.
name
def
__exit__
(
self
,
exctype
,
excvalue
,
exctrace
):
try
:
shutil
.
rmtree
(
self
.
name
,
True
)
except
OSError
:
# removal errors are not the only possible
pass
self
.
name
=
None
setuptools/py33compat.py
deleted
100644 → 0
View file @
4eb5b32f
import
dis
import
array
import
collections
try
:
import
html
except
ImportError
:
html
=
None
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
html_parser
__metaclass__
=
type
OpArg
=
collections
.
namedtuple
(
'OpArg'
,
'opcode arg'
)
class
Bytecode_compat
:
def
__init__
(
self
,
code
):
self
.
code
=
code
def
__iter__
(
self
):
"""Yield '(op,arg)' pair for each operation in code object 'code'"""
bytes
=
array
.
array
(
'b'
,
self
.
code
.
co_code
)
eof
=
len
(
self
.
code
.
co_code
)
ptr
=
0
extended_arg
=
0
while
ptr
<
eof
:
op
=
bytes
[
ptr
]
if
op
>=
dis
.
HAVE_ARGUMENT
:
arg
=
bytes
[
ptr
+
1
]
+
bytes
[
ptr
+
2
]
*
256
+
extended_arg
ptr
+=
3
if
op
==
dis
.
EXTENDED_ARG
:
long_type
=
six
.
integer_types
[
-
1
]
extended_arg
=
arg
*
long_type
(
65536
)
continue
else
:
arg
=
None
ptr
+=
1
yield
OpArg
(
op
,
arg
)
Bytecode
=
getattr
(
dis
,
'Bytecode'
,
Bytecode_compat
)
unescape
=
getattr
(
html
,
'unescape'
,
None
)
if
unescape
is
None
:
# HTMLParser.unescape is deprecated since Python 3.4, and will be removed
# from 3.9.
unescape
=
html_parser
.
HTMLParser
().
unescape
setuptools/sandbox.py
View file @
fb7ab81a
...
@@ -8,9 +8,7 @@ import re
...
@@ -8,9 +8,7 @@ import re
import
contextlib
import
contextlib
import
pickle
import
pickle
import
textwrap
import
textwrap
import
builtins
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
builtins
,
map
import
pkg_resources
import
pkg_resources
from
distutils.errors
import
DistutilsError
from
distutils.errors
import
DistutilsError
...
@@ -138,7 +136,7 @@ class ExceptionSaver:
...
@@ -138,7 +136,7 @@ class ExceptionSaver:
return
return
type
,
exc
=
map
(
pickle
.
loads
,
self
.
_saved
)
type
,
exc
=
map
(
pickle
.
loads
,
self
.
_saved
)
six
.
reraise
(
type
,
exc
,
self
.
_tb
)
raise
exc
.
with_traceback
(
self
.
_tb
)
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
...
@@ -251,15 +249,8 @@ def run_setup(setup_script, args):
...
@@ -251,15 +249,8 @@ def run_setup(setup_script, args):
working_set
.
__init__
()
working_set
.
__init__
()
working_set
.
callbacks
.
append
(
lambda
dist
:
dist
.
activate
())
working_set
.
callbacks
.
append
(
lambda
dist
:
dist
.
activate
())
# __file__ should be a byte string on Python 2 (#712)
dunder_file
=
(
setup_script
if
isinstance
(
setup_script
,
str
)
else
setup_script
.
encode
(
sys
.
getfilesystemencoding
())
)
with
DirectorySandbox
(
setup_dir
):
with
DirectorySandbox
(
setup_dir
):
ns
=
dict
(
__file__
=
dunder_file
,
__name__
=
'__main__'
)
ns
=
dict
(
__file__
=
setup_script
,
__name__
=
'__main__'
)
_execfile
(
setup_script
,
ns
)
_execfile
(
setup_script
,
ns
)
except
SystemExit
as
v
:
except
SystemExit
as
v
:
if
v
.
args
and
v
.
args
[
0
]:
if
v
.
args
and
v
.
args
[
0
]:
...
...
setuptools/ssl_support.py
View file @
fb7ab81a
...
@@ -3,8 +3,9 @@ import socket
...
@@ -3,8 +3,9 @@ import socket
import
atexit
import
atexit
import
re
import
re
import
functools
import
functools
import
urllib.request
import
http.client
from
setuptools.extern.six.moves
import
urllib
,
http_client
,
map
,
filter
from
pkg_resources
import
ResolutionError
,
ExtractionError
from
pkg_resources
import
ResolutionError
,
ExtractionError
...
@@ -31,7 +32,7 @@ cert_paths = """
...
@@ -31,7 +32,7 @@ cert_paths = """
try
:
try
:
HTTPSHandler
=
urllib
.
request
.
HTTPSHandler
HTTPSHandler
=
urllib
.
request
.
HTTPSHandler
HTTPSConnection
=
http
_
client
.
HTTPSConnection
HTTPSConnection
=
http
.
client
.
HTTPSConnection
except
AttributeError
:
except
AttributeError
:
HTTPSHandler
=
HTTPSConnection
=
object
HTTPSHandler
=
HTTPSConnection
=
object
...
...
setuptools/tests/__init__.py
View file @
fb7ab81a
...
@@ -2,19 +2,12 @@ import locale
...
@@ -2,19 +2,12 @@ import locale
import
pytest
import
pytest
from
setuptools.extern.six
import
PY2
,
PY3
__all__
=
[
'fail_on_ascii'
,
'ack_2to3'
]
__all__
=
[
'fail_on_ascii'
,
'py2_only'
,
'py3_only'
,
'ack_2to3'
]
is_ascii
=
locale
.
getpreferredencoding
()
==
'ANSI_X3.4-1968'
is_ascii
=
locale
.
getpreferredencoding
()
==
'ANSI_X3.4-1968'
fail_on_ascii
=
pytest
.
mark
.
xfail
(
is_ascii
,
reason
=
"Test fails in this locale"
)
fail_on_ascii
=
pytest
.
mark
.
xfail
(
is_ascii
,
reason
=
"Test fails in this locale"
)
py2_only
=
pytest
.
mark
.
skipif
(
not
PY2
,
reason
=
"Test runs on Python 2 only"
)
py3_only
=
pytest
.
mark
.
skipif
(
not
PY3
,
reason
=
"Test runs on Python 3 only"
)
ack_2to3
=
pytest
.
mark
.
filterwarnings
(
'ignore:2to3 support is deprecated'
)
ack_2to3
=
pytest
.
mark
.
filterwarnings
(
'ignore:2to3 support is deprecated'
)
setuptools/tests/contexts.py
View file @
fb7ab81a
...
@@ -4,8 +4,8 @@ import shutil
...
@@ -4,8 +4,8 @@ import shutil
import
sys
import
sys
import
contextlib
import
contextlib
import
site
import
site
import
io
from
setuptools.extern
import
six
import
pkg_resources
import
pkg_resources
...
@@ -58,8 +58,8 @@ def quiet():
...
@@ -58,8 +58,8 @@ def quiet():
old_stdout
=
sys
.
stdout
old_stdout
=
sys
.
stdout
old_stderr
=
sys
.
stderr
old_stderr
=
sys
.
stderr
new_stdout
=
sys
.
stdout
=
six
.
StringIO
()
new_stdout
=
sys
.
stdout
=
io
.
StringIO
()
new_stderr
=
sys
.
stderr
=
six
.
StringIO
()
new_stderr
=
sys
.
stderr
=
io
.
StringIO
()
try
:
try
:
yield
new_stdout
,
new_stderr
yield
new_stdout
,
new_stderr
finally
:
finally
:
...
...
setuptools/tests/namespaces.py
View file @
fb7ab81a
from
__future__
import
absolute_import
,
unicode_literals
import
textwrap
import
textwrap
...
...
setuptools/tests/server.py
View file @
fb7ab81a
...
@@ -4,13 +4,12 @@
...
@@ -4,13 +4,12 @@
import
os
import
os
import
time
import
time
import
threading
import
threading
import
http.server
import
urllib.parse
import
urllib.request
from
setuptools.extern.six.moves
import
BaseHTTPServer
,
SimpleHTTPServer
from
setuptools.extern.six.moves.urllib_parse
import
urljoin
from
setuptools.extern.six.moves.urllib.request
import
pathname2url
class
IndexServer
(
http
.
server
.
HTTPServer
):
class
IndexServer
(
BaseHTTPServer
.
HTTPServer
):
"""Basic single-threaded http server simulating a package index
"""Basic single-threaded http server simulating a package index
You can use this server in unittest like this::
You can use this server in unittest like this::
...
@@ -24,8 +23,8 @@ class IndexServer(BaseHTTPServer.HTTPServer):
...
@@ -24,8 +23,8 @@ class IndexServer(BaseHTTPServer.HTTPServer):
def
__init__
(
def
__init__
(
self
,
server_address
=
(
''
,
0
),
self
,
server_address
=
(
''
,
0
),
RequestHandlerClass
=
SimpleHTTPS
erver
.
SimpleHTTPRequestHandler
):
RequestHandlerClass
=
http
.
s
erver
.
SimpleHTTPRequestHandler
):
BaseHTTPS
erver
.
HTTPServer
.
__init__
(
http
.
s
erver
.
HTTPServer
.
__init__
(
self
,
server_address
,
RequestHandlerClass
)
self
,
server_address
,
RequestHandlerClass
)
self
.
_run
=
True
self
.
_run
=
True
...
@@ -48,14 +47,14 @@ class IndexServer(BaseHTTPServer.HTTPServer):
...
@@ -48,14 +47,14 @@ class IndexServer(BaseHTTPServer.HTTPServer):
return
'http://127.0.0.1:%s/setuptools/tests/indexes/'
%
port
return
'http://127.0.0.1:%s/setuptools/tests/indexes/'
%
port
class
RequestRecorder
(
BaseHTTPS
erver
.
BaseHTTPRequestHandler
):
class
RequestRecorder
(
http
.
s
erver
.
BaseHTTPRequestHandler
):
def
do_GET
(
self
):
def
do_GET
(
self
):
requests
=
vars
(
self
.
server
).
setdefault
(
'requests'
,
[])
requests
=
vars
(
self
.
server
).
setdefault
(
'requests'
,
[])
requests
.
append
(
self
)
requests
.
append
(
self
)
self
.
send_response
(
200
,
'OK'
)
self
.
send_response
(
200
,
'OK'
)
class
MockServer
(
BaseHTTPS
erver
.
HTTPServer
,
threading
.
Thread
):
class
MockServer
(
http
.
s
erver
.
HTTPServer
,
threading
.
Thread
):
"""
"""
A simple HTTP Server that records the requests made to it.
A simple HTTP Server that records the requests made to it.
"""
"""
...
@@ -63,7 +62,7 @@ class MockServer(BaseHTTPServer.HTTPServer, threading.Thread):
...
@@ -63,7 +62,7 @@ class MockServer(BaseHTTPServer.HTTPServer, threading.Thread):
def
__init__
(
def
__init__
(
self
,
server_address
=
(
''
,
0
),
self
,
server_address
=
(
''
,
0
),
RequestHandlerClass
=
RequestRecorder
):
RequestHandlerClass
=
RequestRecorder
):
BaseHTTPS
erver
.
HTTPServer
.
__init__
(
http
.
s
erver
.
HTTPServer
.
__init__
(
self
,
server_address
,
RequestHandlerClass
)
self
,
server_address
,
RequestHandlerClass
)
threading
.
Thread
.
__init__
(
self
)
threading
.
Thread
.
__init__
(
self
)
self
.
setDaemon
(
True
)
self
.
setDaemon
(
True
)
...
@@ -87,5 +86,5 @@ def path_to_url(path, authority=None):
...
@@ -87,5 +86,5 @@ def path_to_url(path, authority=None):
base
=
'file:'
base
=
'file:'
if
authority
is
not
None
:
if
authority
is
not
None
:
base
+=
'//'
+
authority
base
+=
'//'
+
authority
url
=
url
join
(
base
,
pathname2url
(
path
))
url
=
url
lib
.
parse
.
urljoin
(
base
,
urllib
.
request
.
pathname2url
(
path
))
return
url
return
url
setuptools/tests/test_archive_util.py
View file @
fb7ab81a
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
import
tarfile
import
tarfile
import
io
import
io
from
setuptools.extern
import
six
import
pytest
import
pytest
from
setuptools
import
archive_util
from
setuptools
import
archive_util
...
@@ -22,8 +20,6 @@ def tarfile_with_unicode(tmpdir):
...
@@ -22,8 +20,6 @@ def tarfile_with_unicode(tmpdir):
data
=
b""
data
=
b""
filename
=
"testimäge.png"
filename
=
"testimäge.png"
if
six
.
PY2
:
filename
=
filename
.
decode
(
'utf-8'
)
t
=
tarfile
.
TarInfo
(
filename
)
t
=
tarfile
.
TarInfo
(
filename
)
t
.
size
=
len
(
data
)
t
.
size
=
len
(
data
)
...
@@ -39,4 +35,4 @@ def tarfile_with_unicode(tmpdir):
...
@@ -39,4 +35,4 @@ def tarfile_with_unicode(tmpdir):
@
pytest
.
mark
.
xfail
(
reason
=
"#710 and #712"
)
@
pytest
.
mark
.
xfail
(
reason
=
"#710 and #712"
)
def
test_unicode_files
(
tarfile_with_unicode
,
tmpdir
):
def
test_unicode_files
(
tarfile_with_unicode
,
tmpdir
):
target
=
tmpdir
/
'out'
target
=
tmpdir
/
'out'
archive_util
.
unpack_archive
(
tarfile_with_unicode
,
s
ix
.
text_type
(
target
))
archive_util
.
unpack_archive
(
tarfile_with_unicode
,
s
tr
(
target
))
setuptools/tests/test_build_ext.py
View file @
fb7ab81a
...
@@ -2,8 +2,6 @@ import sys
...
@@ -2,8 +2,6 @@ import sys
import
distutils.command.build_ext
as
orig
import
distutils.command.build_ext
as
orig
from
distutils.sysconfig
import
get_config_var
from
distutils.sysconfig
import
get_config_var
from
setuptools.extern
import
six
from
setuptools.command.build_ext
import
build_ext
,
get_abi3_suffix
from
setuptools.command.build_ext
import
build_ext
,
get_abi3_suffix
from
setuptools.dist
import
Distribution
from
setuptools.dist
import
Distribution
from
setuptools.extension
import
Extension
from
setuptools.extension
import
Extension
...
@@ -41,7 +39,7 @@ class TestBuildExt:
...
@@ -41,7 +39,7 @@ class TestBuildExt:
assert
'spam.eggs'
in
cmd
.
ext_map
assert
'spam.eggs'
in
cmd
.
ext_map
res
=
cmd
.
get_ext_filename
(
'spam.eggs'
)
res
=
cmd
.
get_ext_filename
(
'spam.eggs'
)
if
six
.
PY2
or
not
get_abi3_suffix
():
if
not
get_abi3_suffix
():
assert
res
.
endswith
(
get_config_var
(
'EXT_SUFFIX'
))
assert
res
.
endswith
(
get_config_var
(
'EXT_SUFFIX'
))
elif
sys
.
platform
==
'win32'
:
elif
sys
.
platform
==
'win32'
:
assert
res
.
endswith
(
'eggs.pyd'
)
assert
res
.
endswith
(
'eggs.pyd'
)
...
...
setuptools/tests/test_build_meta.py
View file @
fb7ab81a
from
__future__
import
unicode_literals
import
os
import
os
import
shutil
import
shutil
import
tarfile
import
tarfile
import
importlib
from
concurrent
import
futures
import
pytest
import
pytest
from
.files
import
build_files
from
.files
import
build_files
from
.textwrap
import
DALS
from
.textwrap
import
DALS
from
.
import
py2_only
__metaclass__
=
type
# Backports on Python 2.7
import
importlib
from
concurrent
import
futures
class
BuildBackendBase
:
class
BuildBackendBase
:
...
@@ -220,15 +213,6 @@ class TestBuildMetaBackend:
...
@@ -220,15 +213,6 @@ class TestBuildMetaBackend:
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
dist_dir
,
dist_info
,
'METADATA'
))
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
dist_dir
,
dist_info
,
'METADATA'
))
@
py2_only
def
test_prepare_metadata_for_build_wheel_with_str
(
self
,
build_backend
):
dist_dir
=
os
.
path
.
abspath
(
str
(
'pip-dist-info'
))
os
.
makedirs
(
dist_dir
)
dist_info
=
build_backend
.
prepare_metadata_for_build_wheel
(
dist_dir
)
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
dist_dir
,
dist_info
,
'METADATA'
))
def
test_build_sdist_explicit_dist
(
self
,
build_backend
):
def
test_build_sdist_explicit_dist
(
self
,
build_backend
):
# explicitly specifying the dist folder should work
# explicitly specifying the dist folder should work
# the folder sdist_directory and the ``--dist-dir`` can be the same
# the folder sdist_directory and the ``--dist-dir`` can be the same
...
...
setuptools/tests/test_config.py
View file @
fb7ab81a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
contextlib
import
contextlib
import
configparser
import
pytest
import
pytest
...
@@ -9,9 +7,6 @@ from distutils.errors import DistutilsOptionError, DistutilsFileError
...
@@ -9,9 +7,6 @@ from distutils.errors import DistutilsOptionError, DistutilsFileError
from
mock
import
patch
from
mock
import
patch
from
setuptools.dist
import
Distribution
,
_Distribution
from
setuptools.dist
import
Distribution
,
_Distribution
from
setuptools.config
import
ConfigHandler
,
read_configuration
from
setuptools.config
import
ConfigHandler
,
read_configuration
from
setuptools.extern.six.moves
import
configparser
from
setuptools.extern
import
six
from
.
import
py2_only
,
py3_only
from
.textwrap
import
DALS
from
.textwrap
import
DALS
...
@@ -311,10 +306,6 @@ class TestMetadata:
...
@@ -311,10 +306,6 @@ class TestMetadata:
with
get_dist
(
tmpdir
)
as
dist
:
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
metadata
.
version
==
'2016.11.26'
assert
dist
.
metadata
.
version
==
'2016.11.26'
if
six
.
PY2
:
# static version loading is unsupported on Python 2
return
config
.
write
(
config
.
write
(
'[metadata]
\
n
'
'[metadata]
\
n
'
'version = attr: fake_package.subpkg_b.mod.VERSION
\
n
'
'version = attr: fake_package.subpkg_b.mod.VERSION
\
n
'
...
@@ -719,19 +710,6 @@ class TestOptions:
...
@@ -719,19 +710,6 @@ class TestOptions:
assert
set
(
dist
.
packages
)
==
set
(
assert
set
(
dist
.
packages
)
==
set
(
[
'fake_package'
,
'fake_package.sub_two'
])
[
'fake_package'
,
'fake_package.sub_two'
])
@
py2_only
def
test_find_namespace_directive_fails_on_py2
(
self
,
tmpdir
):
dir_package
,
config
=
fake_env
(
tmpdir
,
'[options]
\
n
'
'packages = find_namespace:
\
n
'
)
with
pytest
.
raises
(
DistutilsOptionError
):
with
get_dist
(
tmpdir
)
as
dist
:
dist
.
parse_config_files
()
@
py3_only
def
test_find_namespace_directive
(
self
,
tmpdir
):
def
test_find_namespace_directive
(
self
,
tmpdir
):
dir_package
,
config
=
fake_env
(
dir_package
,
config
=
fake_env
(
tmpdir
,
tmpdir
,
...
...
setuptools/tests/test_develop.py
View file @
fb7ab81a
"""develop tests
"""develop tests
"""
"""
from
__future__
import
absolute_import
,
unicode_literals
import
os
import
os
import
site
import
site
import
sys
import
sys
...
@@ -10,7 +8,6 @@ import io
...
@@ -10,7 +8,6 @@ import io
import
subprocess
import
subprocess
import
platform
import
platform
from
setuptools.extern
import
six
from
setuptools.command
import
test
from
setuptools.command
import
test
import
pytest
import
pytest
...
@@ -97,7 +94,7 @@ class TestDevelop:
...
@@ -97,7 +94,7 @@ class TestDevelop:
with
io
.
open
(
fn
)
as
init_file
:
with
io
.
open
(
fn
)
as
init_file
:
init
=
init_file
.
read
().
strip
()
init
=
init_file
.
read
().
strip
()
expected
=
'print
"foo"'
if
six
.
PY2
else
'print
("foo")'
expected
=
'print("foo")'
assert
init
==
expected
assert
init
==
expected
def
test_console_scripts
(
self
,
tmpdir
):
def
test_console_scripts
(
self
,
tmpdir
):
...
@@ -163,7 +160,7 @@ class TestNamespaces:
...
@@ -163,7 +160,7 @@ class TestNamespaces:
reason
=
"https://github.com/pypa/setuptools/issues/851"
,
reason
=
"https://github.com/pypa/setuptools/issues/851"
,
)
)
@
pytest
.
mark
.
skipif
(
@
pytest
.
mark
.
skipif
(
platform
.
python_implementation
()
==
'PyPy'
and
not
six
.
PY2
,
platform
.
python_implementation
()
==
'PyPy'
,
reason
=
"https://github.com/pypa/setuptools/issues/1202"
,
reason
=
"https://github.com/pypa/setuptools/issues/1202"
,
)
)
def
test_namespace_package_importable
(
self
,
tmpdir
):
def
test_namespace_package_importable
(
self
,
tmpdir
):
...
...
setuptools/tests/test_dist.py
View file @
fb7ab81a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
io
import
io
import
collections
import
collections
import
re
import
re
import
functools
import
functools
import
urllib.request
import
urllib.parse
from
distutils.errors
import
DistutilsSetupError
from
distutils.errors
import
DistutilsSetupError
from
setuptools.dist
import
(
from
setuptools.dist
import
(
_get_unpatched
,
_get_unpatched
,
...
@@ -14,9 +12,6 @@ from setuptools.dist import (
...
@@ -14,9 +12,6 @@ from setuptools.dist import (
)
)
from
setuptools
import
sic
from
setuptools
import
sic
from
setuptools
import
Distribution
from
setuptools
import
Distribution
from
setuptools.extern.six.moves.urllib.request
import
pathname2url
from
setuptools.extern.six.moves.urllib_parse
import
urljoin
from
setuptools.extern
import
six
from
.textwrap
import
DALS
from
.textwrap
import
DALS
from
.test_easy_install
import
make_nspkg_sdist
from
.test_easy_install
import
make_nspkg_sdist
...
@@ -29,7 +24,8 @@ def test_dist_fetch_build_egg(tmpdir):
...
@@ -29,7 +24,8 @@ def test_dist_fetch_build_egg(tmpdir):
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
"""
"""
index
=
tmpdir
.
mkdir
(
'index'
)
index
=
tmpdir
.
mkdir
(
'index'
)
index_url
=
urljoin
(
'file://'
,
pathname2url
(
str
(
index
)))
index_url
=
urllib
.
parse
.
urljoin
(
'file://'
,
urllib
.
request
.
pathname2url
(
str
(
index
)))
def
sdist_with_index
(
distname
,
version
):
def
sdist_with_index
(
distname
,
version
):
dist_dir
=
index
.
mkdir
(
distname
)
dist_dir
=
index
.
mkdir
(
distname
)
...
@@ -63,8 +59,7 @@ def test_dist_fetch_build_egg(tmpdir):
...
@@ -63,8 +59,7 @@ def test_dist_fetch_build_egg(tmpdir):
dist
.
fetch_build_egg
(
r
)
dist
.
fetch_build_egg
(
r
)
for
r
in
reqs
for
r
in
reqs
]
]
# noqa below because on Python 2 it causes flakes
assert
[
dist
.
key
for
dist
in
resolved_dists
if
dist
]
==
reqs
assert
[
dist
.
key
for
dist
in
resolved_dists
if
dist
]
==
reqs
# noqa
def
test_dist__get_unpatched_deprecated
():
def
test_dist__get_unpatched_deprecated
():
...
@@ -150,9 +145,6 @@ def test_read_metadata(name, attrs):
...
@@ -150,9 +145,6 @@ def test_read_metadata(name, attrs):
dist_class
=
metadata_out
.
__class__
dist_class
=
metadata_out
.
__class__
# Write to PKG_INFO and then load into a new metadata object
# Write to PKG_INFO and then load into a new metadata object
if
six
.
PY2
:
PKG_INFO
=
io
.
BytesIO
()
else
:
PKG_INFO
=
io
.
StringIO
()
PKG_INFO
=
io
.
StringIO
()
metadata_out
.
write_pkg_file
(
PKG_INFO
)
metadata_out
.
write_pkg_file
(
PKG_INFO
)
...
...
setuptools/tests/test_dist_info.py
View file @
fb7ab81a
"""Test .dist-info style distributions.
"""Test .dist-info style distributions.
"""
"""
from
__future__
import
unicode_literals
from
setuptools.extern.six.moves
import
map
import
pytest
import
pytest
import
pkg_resources
import
pkg_resources
...
...
setuptools/tests/test_easy_install.py
View file @
fb7ab81a
# -*- coding: utf-8 -*-
"""Easy install Tests
"""Easy install Tests
"""
"""
from
__future__
import
absolute_import
,
unicode_literals
import
sys
import
sys
import
os
import
os
...
@@ -18,8 +16,6 @@ import mock
...
@@ -18,8 +16,6 @@ import mock
import
time
import
time
import
re
import
re
from
setuptools.extern
import
six
import
pytest
import
pytest
from
setuptools
import
sandbox
from
setuptools
import
sandbox
...
@@ -41,8 +37,6 @@ from . import contexts
...
@@ -41,8 +37,6 @@ from . import contexts
from
.files
import
build_files
from
.files
import
build_files
from
.textwrap
import
DALS
from
.textwrap
import
DALS
__metaclass__
=
type
class
FakeDist
:
class
FakeDist
:
def
get_entry_map
(
self
,
group
):
def
get_entry_map
(
self
,
group
):
...
@@ -984,8 +978,6 @@ def create_setup_requires_package(path, distname='foobar', version='0.1',
...
@@ -984,8 +978,6 @@ def create_setup_requires_package(path, distname='foobar', version='0.1',
)
)
class
TestScriptHeader
:
class
TestScriptHeader
:
non_ascii_exe
=
'/Users/José/bin/python'
non_ascii_exe
=
'/Users/José/bin/python'
if
six
.
PY2
:
non_ascii_exe
=
non_ascii_exe
.
encode
(
'utf-8'
)
exe_with_spaces
=
r'C:\
P
rogram Files\
Py
thon36\
py
thon.exe'
exe_with_spaces
=
r'C:\
P
rogram Files\
Py
thon36\
py
thon.exe'
def
test_get_script_header
(
self
):
def
test_get_script_header
(
self
):
...
...
setuptools/tests/test_egg_info.py
View file @
fb7ab81a
...
@@ -10,7 +10,6 @@ from setuptools.command.egg_info import (
...
@@ -10,7 +10,6 @@ from setuptools.command.egg_info import (
egg_info
,
manifest_maker
,
EggInfoDeprecationWarning
,
get_pkg_info_revision
,
egg_info
,
manifest_maker
,
EggInfoDeprecationWarning
,
get_pkg_info_revision
,
)
)
from
setuptools.dist
import
Distribution
from
setuptools.dist
import
Distribution
from
setuptools.extern.six.moves
import
map
import
pytest
import
pytest
...
@@ -19,8 +18,6 @@ from .files import build_files
...
@@ -19,8 +18,6 @@ from .files import build_files
from
.textwrap
import
DALS
from
.textwrap
import
DALS
from
.
import
contexts
from
.
import
contexts
__metaclass__
=
type
class
Environment
(
str
):
class
Environment
(
str
):
pass
pass
...
@@ -73,8 +70,7 @@ class TestEggInfo:
...
@@ -73,8 +70,7 @@ class TestEggInfo:
"""
"""
When the egg_info section is empty or not present, running
When the egg_info section is empty or not present, running
save_version_info should add the settings to the setup.cfg
save_version_info should add the settings to the setup.cfg
in a deterministic order, consistent with the ordering found
in a deterministic order.
on Python 2.7 with PYTHONHASHSEED=0.
"""
"""
setup_cfg
=
os
.
path
.
join
(
env
.
paths
[
'home'
],
'setup.cfg'
)
setup_cfg
=
os
.
path
.
join
(
env
.
paths
[
'home'
],
'setup.cfg'
)
dist
=
Distribution
()
dist
=
Distribution
()
...
@@ -906,49 +902,3 @@ class TestEggInfo:
...
@@ -906,49 +902,3 @@ class TestEggInfo:
def
test_get_pkg_info_revision_deprecated
(
self
):
def
test_get_pkg_info_revision_deprecated
(
self
):
pytest
.
warns
(
EggInfoDeprecationWarning
,
get_pkg_info_revision
)
pytest
.
warns
(
EggInfoDeprecationWarning
,
get_pkg_info_revision
)
EGG_INFO_TESTS
=
(
# Check for issue #1136: invalid string type when
# reading declarative `setup.cfg` under Python 2.
{
'setup.py'
:
DALS
(
"""
from setuptools import setup
setup(
name="foo",
)
"""
),
'setup.cfg'
:
DALS
(
"""
[options]
package_dir =
= src
"""
),
'src'
:
{},
},
# Check Unicode can be used in `setup.py` under Python 2.
{
'setup.py'
:
DALS
(
"""
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from setuptools import setup, find_packages
setup(
name="foo",
package_dir={'': 'src'},
)
"""
),
'src'
:
{},
}
)
@
pytest
.
mark
.
parametrize
(
'package_files'
,
EGG_INFO_TESTS
)
def
test_egg_info
(
self
,
tmpdir_cwd
,
env
,
package_files
):
"""
"""
build_files
(
package_files
)
code
,
data
=
environment
.
run_setup_py
(
cmd
=
[
'egg_info'
],
data_stream
=
1
,
)
assert
not
code
,
data
setuptools/tests/test_extern.py
View file @
fb7ab81a
...
@@ -3,7 +3,6 @@ import pickle
...
@@ -3,7 +3,6 @@ import pickle
from
setuptools
import
Distribution
from
setuptools
import
Distribution
from
setuptools.extern
import
ordered_set
from
setuptools.extern
import
ordered_set
from
setuptools.tests
import
py3_only
def
test_reimport_extern
():
def
test_reimport_extern
():
...
@@ -17,6 +16,5 @@ def test_orderedset_pickle_roundtrip():
...
@@ -17,6 +16,5 @@ def test_orderedset_pickle_roundtrip():
assert
o1
==
o2
assert
o1
==
o2
@
py3_only
def
test_distribution_picklable
():
def
test_distribution_picklable
():
pickle
.
loads
(
pickle
.
dumps
(
Distribution
()))
pickle
.
loads
(
pickle
.
dumps
(
Distribution
()))
setuptools/tests/test_find_packages.py
View file @
fb7ab81a
...
@@ -7,12 +7,8 @@ import platform
...
@@ -7,12 +7,8 @@ import platform
import
pytest
import
pytest
from
.
import
py3_only
from
setuptools.extern.six
import
PY3
from
setuptools
import
find_packages
from
setuptools
import
find_packages
if
PY3
:
from
setuptools
import
find_namespace_packages
from
setuptools
import
find_namespace_packages
# modeled after CPython's test.support.can_symlink
# modeled after CPython's test.support.can_symlink
...
@@ -154,34 +150,29 @@ class TestFindPackages:
...
@@ -154,34 +150,29 @@ class TestFindPackages:
def
_assert_packages
(
self
,
actual
,
expected
):
def
_assert_packages
(
self
,
actual
,
expected
):
assert
set
(
actual
)
==
set
(
expected
)
assert
set
(
actual
)
==
set
(
expected
)
@
py3_only
def
test_pep420_ns_package
(
self
):
def
test_pep420_ns_package
(
self
):
packages
=
find_namespace_packages
(
packages
=
find_namespace_packages
(
self
.
dist_dir
,
include
=
[
'pkg*'
],
exclude
=
[
'pkg.subpkg.assets'
])
self
.
dist_dir
,
include
=
[
'pkg*'
],
exclude
=
[
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
py3_only
def
test_pep420_ns_package_no_includes
(
self
):
def
test_pep420_ns_package_no_includes
(
self
):
packages
=
find_namespace_packages
(
packages
=
find_namespace_packages
(
self
.
dist_dir
,
exclude
=
[
'pkg.subpkg.assets'
])
self
.
dist_dir
,
exclude
=
[
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
self
.
_assert_packages
(
packages
,
[
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
packages
,
[
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
py3_only
def
test_pep420_ns_package_no_includes_or_excludes
(
self
):
def
test_pep420_ns_package_no_includes_or_excludes
(
self
):
packages
=
find_namespace_packages
(
self
.
dist_dir
)
packages
=
find_namespace_packages
(
self
.
dist_dir
)
expected
=
[
expected
=
[
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
,
'pkg.subpkg.assets'
]
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
,
'pkg.subpkg.assets'
]
self
.
_assert_packages
(
packages
,
expected
)
self
.
_assert_packages
(
packages
,
expected
)
@
py3_only
def
test_regular_package_with_nested_pep420_ns_packages
(
self
):
def
test_regular_package_with_nested_pep420_ns_packages
(
self
):
self
.
_touch
(
'__init__.py'
,
self
.
pkg_dir
)
self
.
_touch
(
'__init__.py'
,
self
.
pkg_dir
)
packages
=
find_namespace_packages
(
packages
=
find_namespace_packages
(
self
.
dist_dir
,
exclude
=
[
'docs'
,
'pkg.subpkg.assets'
])
self
.
dist_dir
,
exclude
=
[
'docs'
,
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
py3_only
def
test_pep420_ns_package_no_non_package_dirs
(
self
):
def
test_pep420_ns_package_no_non_package_dirs
(
self
):
shutil
.
rmtree
(
self
.
docs_dir
)
shutil
.
rmtree
(
self
.
docs_dir
)
shutil
.
rmtree
(
os
.
path
.
join
(
self
.
dist_dir
,
'pkg/subpkg/assets'
))
shutil
.
rmtree
(
os
.
path
.
join
(
self
.
dist_dir
,
'pkg/subpkg/assets'
))
...
...
setuptools/tests/test_integration.py
View file @
fb7ab81a
...
@@ -11,8 +11,8 @@ import subprocess
...
@@ -11,8 +11,8 @@ import subprocess
import
functools
import
functools
import
tarfile
import
tarfile
import
zipfile
import
zipfile
import
urllib.request
from
setuptools.extern.six.moves
import
urllib
import
pytest
import
pytest
from
setuptools.command.easy_install
import
easy_install
from
setuptools.command.easy_install
import
easy_install
...
...
setuptools/tests/test_manifest.py
View file @
fb7ab81a
...
@@ -7,18 +7,16 @@ import shutil
...
@@ -7,18 +7,16 @@ import shutil
import
sys
import
sys
import
tempfile
import
tempfile
import
itertools
import
itertools
import
io
from
distutils
import
log
from
distutils
import
log
from
distutils.errors
import
DistutilsTemplateError
from
distutils.errors
import
DistutilsTemplateError
from
setuptools.command.egg_info
import
FileList
,
egg_info
,
translate_pattern
from
setuptools.command.egg_info
import
FileList
,
egg_info
,
translate_pattern
from
setuptools.dist
import
Distribution
from
setuptools.dist
import
Distribution
from
setuptools.extern
import
six
from
setuptools.tests.textwrap
import
DALS
from
setuptools.tests.textwrap
import
DALS
import
pytest
import
pytest
__metaclass__
=
type
def
make_local_path
(
s
):
def
make_local_path
(
s
):
"""Converts '/' in a string to os.sep"""
"""Converts '/' in a string to os.sep"""
...
@@ -41,7 +39,7 @@ setup(**%r)
...
@@ -41,7 +39,7 @@ setup(**%r)
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
def
quiet
():
def
quiet
():
old_stdout
,
old_stderr
=
sys
.
stdout
,
sys
.
stderr
old_stdout
,
old_stderr
=
sys
.
stdout
,
sys
.
stderr
sys
.
stdout
,
sys
.
stderr
=
six
.
StringIO
(),
six
.
StringIO
()
sys
.
stdout
,
sys
.
stderr
=
io
.
StringIO
(),
io
.
StringIO
()
try
:
try
:
yield
yield
finally
:
finally
:
...
...
setuptools/tests/test_msvc14.py
View file @
fb7ab81a
...
@@ -31,8 +31,6 @@ class TestMSVC14:
...
@@ -31,8 +31,6 @@ class TestMSVC14:
finally
:
finally
:
_msvccompiler
.
_msvc14_find_vcvarsall
=
old_find_vcvarsall
_msvccompiler
.
_msvc14_find_vcvarsall
=
old_find_vcvarsall
@
pytest
.
mark
.
skipif
(
sys
.
version_info
[
0
]
<
3
,
reason
=
"Unicode requires encode/decode on Python 2"
)
def
test_get_vc_env_unicode
(
self
):
def
test_get_vc_env_unicode
(
self
):
import
setuptools.msvc
as
_msvccompiler
import
setuptools.msvc
as
_msvccompiler
...
...
setuptools/tests/test_namespaces.py
View file @
fb7ab81a
from
__future__
import
absolute_import
,
unicode_literals
import
sys
import
sys
import
subprocess
import
subprocess
...
...
setuptools/tests/test_packageindex.py
View file @
fb7ab81a
from
__future__
import
absolute_import
import
sys
import
sys
import
os
import
os
import
distutils.errors
import
distutils.errors
import
platform
import
platform
import
urllib.request
import
urllib.error
import
http.client
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
urllib
,
http_client
import
mock
import
mock
import
pytest
import
pytest
...
@@ -60,7 +59,7 @@ class TestPackageIndex:
...
@@ -60,7 +59,7 @@ class TestPackageIndex:
)
)
def
_urlopen
(
*
args
):
def
_urlopen
(
*
args
):
raise
http
_
client
.
BadStatusLine
(
'line'
)
raise
http
.
client
.
BadStatusLine
(
'line'
)
index
.
opener
=
_urlopen
index
.
opener
=
_urlopen
url
=
'http://example.com'
url
=
'http://example.com'
...
@@ -84,7 +83,7 @@ class TestPackageIndex:
...
@@ -84,7 +83,7 @@ class TestPackageIndex:
try
:
try
:
index
.
open_url
(
url
)
index
.
open_url
(
url
)
except
distutils
.
errors
.
DistutilsError
as
error
:
except
distutils
.
errors
.
DistutilsError
as
error
:
msg
=
s
ix
.
text_type
(
error
)
msg
=
s
tr
(
error
)
assert
(
assert
(
'nonnumeric port'
in
msg
'nonnumeric port'
in
msg
or
'getaddrinfo failed'
in
msg
or
'getaddrinfo failed'
in
msg
...
...
setuptools/tests/test_sdist.py
View file @
fb7ab81a
# -*- coding: utf-8 -*-
"""sdist tests"""
"""sdist tests"""
from
__future__
import
print_function
,
unicode_literals
import
os
import
os
import
sys
import
sys
import
tempfile
import
tempfile
...
@@ -10,9 +7,6 @@ import unicodedata
...
@@ -10,9 +7,6 @@ import unicodedata
import
contextlib
import
contextlib
import
io
import
io
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
import
pytest
import
pytest
import
pkg_resources
import
pkg_resources
...
@@ -21,7 +15,6 @@ from setuptools.command.egg_info import manifest_maker
...
@@ -21,7 +15,6 @@ from setuptools.command.egg_info import manifest_maker
from
setuptools.dist
import
Distribution
from
setuptools.dist
import
Distribution
from
setuptools.tests
import
fail_on_ascii
from
setuptools.tests
import
fail_on_ascii
from
.text
import
Filenames
from
.text
import
Filenames
from
.
import
py3_only
SETUP_ATTRS
=
{
SETUP_ATTRS
=
{
...
@@ -42,7 +35,7 @@ setup(**%r)
...
@@ -42,7 +35,7 @@ setup(**%r)
@
contextlib
.
contextmanager
@
contextlib
.
contextmanager
def
quiet
():
def
quiet
():
old_stdout
,
old_stderr
=
sys
.
stdout
,
sys
.
stderr
old_stdout
,
old_stderr
=
sys
.
stdout
,
sys
.
stderr
sys
.
stdout
,
sys
.
stderr
=
six
.
StringIO
(),
six
.
StringIO
()
sys
.
stdout
,
sys
.
stderr
=
io
.
StringIO
(),
io
.
StringIO
()
try
:
try
:
yield
yield
finally
:
finally
:
...
@@ -51,7 +44,7 @@ def quiet():
...
@@ -51,7 +44,7 @@ def quiet():
# Convert to POSIX path
# Convert to POSIX path
def
posix
(
path
):
def
posix
(
path
):
if
not
six
.
PY2
and
not
isinstance
(
path
,
str
):
if
not
isinstance
(
path
,
str
):
return
path
.
replace
(
os
.
sep
.
encode
(
'ascii'
),
b'/'
)
return
path
.
replace
(
os
.
sep
.
encode
(
'ascii'
),
b'/'
)
else
:
else
:
return
path
.
replace
(
os
.
sep
,
'/'
)
return
path
.
replace
(
os
.
sep
,
'/'
)
...
@@ -59,7 +52,7 @@ def posix(path):
...
@@ -59,7 +52,7 @@ def posix(path):
# HFS Plus uses decomposed UTF-8
# HFS Plus uses decomposed UTF-8
def
decompose
(
path
):
def
decompose
(
path
):
if
isinstance
(
path
,
s
ix
.
text_type
):
if
isinstance
(
path
,
s
tr
):
return
unicodedata
.
normalize
(
'NFD'
,
path
)
return
unicodedata
.
normalize
(
'NFD'
,
path
)
try
:
try
:
path
=
path
.
decode
(
'utf-8'
)
path
=
path
.
decode
(
'utf-8'
)
...
@@ -231,7 +224,6 @@ class TestSdistTest:
...
@@ -231,7 +224,6 @@ class TestSdistTest:
# The manifest should contain the UTF-8 filename
# The manifest should contain the UTF-8 filename
assert
posix
(
filename
)
in
u_contents
assert
posix
(
filename
)
in
u_contents
@
py3_only
@
fail_on_ascii
@
fail_on_ascii
def
test_write_manifest_allows_utf8_filenames
(
self
):
def
test_write_manifest_allows_utf8_filenames
(
self
):
# Test for #303.
# Test for #303.
...
@@ -265,7 +257,6 @@ class TestSdistTest:
...
@@ -265,7 +257,6 @@ class TestSdistTest:
# The filelist should have been updated as well
# The filelist should have been updated as well
assert
u_filename
in
mm
.
filelist
.
files
assert
u_filename
in
mm
.
filelist
.
files
@
py3_only
def
test_write_manifest_skips_non_utf8_filenames
(
self
):
def
test_write_manifest_skips_non_utf8_filenames
(
self
):
"""
"""
Files that cannot be encoded to UTF-8 (specifically, those that
Files that cannot be encoded to UTF-8 (specifically, those that
...
@@ -329,11 +320,9 @@ class TestSdistTest:
...
@@ -329,11 +320,9 @@ class TestSdistTest:
cmd
.
read_manifest
()
cmd
.
read_manifest
()
# The filelist should contain the UTF-8 filename
# The filelist should contain the UTF-8 filename
if
not
six
.
PY2
:
filename
=
filename
.
decode
(
'utf-8'
)
filename
=
filename
.
decode
(
'utf-8'
)
assert
filename
in
cmd
.
filelist
.
files
assert
filename
in
cmd
.
filelist
.
files
@
py3_only
@
fail_on_latin1_encoded_filenames
@
fail_on_latin1_encoded_filenames
def
test_read_manifest_skips_non_utf8_filenames
(
self
):
def
test_read_manifest_skips_non_utf8_filenames
(
self
):
# Test for #303.
# Test for #303.
...
@@ -383,12 +372,11 @@ class TestSdistTest:
...
@@ -383,12 +372,11 @@ class TestSdistTest:
if
sys
.
platform
==
'darwin'
:
if
sys
.
platform
==
'darwin'
:
filename
=
decompose
(
filename
)
filename
=
decompose
(
filename
)
if
not
six
.
PY2
:
fs_enc
=
sys
.
getfilesystemencoding
()
fs_enc
=
sys
.
getfilesystemencoding
()
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
if
fs_enc
==
'cp1252'
:
if
fs_enc
==
'cp1252'
:
# Python 3
mangles the UTF-8 filename
# Python
mangles the UTF-8 filename
filename
=
filename
.
decode
(
'cp1252'
)
filename
=
filename
.
decode
(
'cp1252'
)
assert
filename
in
cmd
.
filelist
.
files
assert
filename
in
cmd
.
filelist
.
files
else
:
else
:
...
@@ -397,8 +385,6 @@ class TestSdistTest:
...
@@ -397,8 +385,6 @@ class TestSdistTest:
else
:
else
:
filename
=
filename
.
decode
(
'utf-8'
)
filename
=
filename
.
decode
(
'utf-8'
)
assert
filename
in
cmd
.
filelist
.
files
assert
filename
in
cmd
.
filelist
.
files
else
:
assert
filename
in
cmd
.
filelist
.
files
@
classmethod
@
classmethod
def
make_strings
(
cls
,
item
):
def
make_strings
(
cls
,
item
):
...
@@ -425,19 +411,6 @@ class TestSdistTest:
...
@@ -425,19 +411,6 @@ class TestSdistTest:
with
quiet
():
with
quiet
():
cmd
.
run
()
cmd
.
run
()
if
six
.
PY2
:
# Under Python 2 there seems to be no decoded string in the
# filelist. However, due to decode and encoding of the
# file name to get utf-8 Manifest the latin1 maybe excluded
try
:
# fs_enc should match how one is expect the decoding to
# be proformed for the manifest output.
fs_enc
=
sys
.
getfilesystemencoding
()
filename
.
decode
(
fs_enc
)
assert
filename
in
cmd
.
filelist
.
files
except
UnicodeDecodeError
:
filename
not
in
cmd
.
filelist
.
files
else
:
# not all windows systems have a default FS encoding of cp1252
# not all windows systems have a default FS encoding of cp1252
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
# Latin-1 is similar to Windows-1252 however
# Latin-1 is similar to Windows-1252 however
...
...
setuptools/tests/test_setopt.py
View file @
fb7ab81a
# coding: utf-8
from
__future__
import
unicode_literals
import
io
import
io
import
configparser
import
six
from
setuptools.command
import
setopt
from
setuptools.command
import
setopt
from
setuptools.extern.six.moves
import
configparser
class
TestEdit
:
class
TestEdit
:
...
@@ -15,7 +9,7 @@ class TestEdit:
...
@@ -15,7 +9,7 @@ class TestEdit:
def
parse_config
(
filename
):
def
parse_config
(
filename
):
parser
=
configparser
.
ConfigParser
()
parser
=
configparser
.
ConfigParser
()
with
io
.
open
(
filename
,
encoding
=
'utf-8'
)
as
reader
:
with
io
.
open
(
filename
,
encoding
=
'utf-8'
)
as
reader
:
(
parser
.
readfp
if
six
.
PY2
else
parser
.
read_file
)
(
reader
)
parser
.
read_file
(
reader
)
return
parser
return
parser
@
staticmethod
@
staticmethod
...
...
setuptools/tests/test_setuptools.py
View file @
fb7ab81a
...
@@ -15,7 +15,6 @@ import setuptools
...
@@ -15,7 +15,6 @@ import setuptools
import
setuptools.dist
import
setuptools.dist
import
setuptools.depends
as
dep
import
setuptools.depends
as
dep
from
setuptools.depends
import
Require
from
setuptools.depends
import
Require
from
setuptools.extern
import
six
def
makeSetup
(
**
args
):
def
makeSetup
(
**
args
):
...
@@ -49,7 +48,7 @@ class TestDepends:
...
@@ -49,7 +48,7 @@ class TestDepends:
x
=
"test"
x
=
"test"
y
=
z
y
=
z
fc
=
six
.
get_function_code
(
f1
)
fc
=
f1
.
__code__
# unrecognized name
# unrecognized name
assert
dep
.
extract_constant
(
fc
,
'q'
,
-
1
)
is
None
assert
dep
.
extract_constant
(
fc
,
'q'
,
-
1
)
is
None
...
...
setuptools/tests/test_test.py
View file @
fb7ab81a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
mock
import
mock
from
distutils
import
log
from
distutils
import
log
import
os
import
os
...
@@ -110,7 +106,6 @@ def test_tests_are_run_once(capfd):
...
@@ -110,7 +106,6 @@ def test_tests_are_run_once(capfd):
with
open
(
'dummy/test_dummy.py'
,
'wt'
)
as
f
:
with
open
(
'dummy/test_dummy.py'
,
'wt'
)
as
f
:
f
.
write
(
DALS
(
f
.
write
(
DALS
(
"""
"""
from __future__ import print_function
import unittest
import unittest
class TestTest(unittest.TestCase):
class TestTest(unittest.TestCase):
def test_test(self):
def test_test(self):
...
...
setuptools/tests/test_virtualenv.py
View file @
fb7ab81a
...
@@ -12,17 +12,6 @@ from .textwrap import DALS
...
@@ -12,17 +12,6 @@ from .textwrap import DALS
from
.test_easy_install
import
make_nspkg_sdist
from
.test_easy_install
import
make_nspkg_sdist
@
pytest
.
fixture
(
autouse
=
True
)
def
disable_requires_python
(
monkeypatch
):
"""
Disable Requires-Python on Python 2.7
"""
if
sys
.
version_info
>
(
3
,):
return
monkeypatch
.
setenv
(
'PIP_IGNORE_REQUIRES_PYTHON'
,
'true'
)
@
pytest
.
fixture
(
autouse
=
True
)
@
pytest
.
fixture
(
autouse
=
True
)
def
pytest_virtualenv_works
(
virtualenv
):
def
pytest_virtualenv_works
(
virtualenv
):
"""
"""
...
...
setuptools/tests/test_wheel.py
View file @
fb7ab81a
...
@@ -25,8 +25,6 @@ from .contexts import tempdir
...
@@ -25,8 +25,6 @@ from .contexts import tempdir
from
.files
import
build_files
from
.files
import
build_files
from
.textwrap
import
DALS
from
.textwrap
import
DALS
__metaclass__
=
type
WHEEL_INFO_TESTS
=
(
WHEEL_INFO_TESTS
=
(
(
'invalid.whl'
,
ValueError
),
(
'invalid.whl'
,
ValueError
),
...
...
setuptools/tests/test_windows_wrappers.py
View file @
fb7ab81a
...
@@ -12,8 +12,6 @@ the script they are to wrap and with the same name as the script they
...
@@ -12,8 +12,6 @@ the script they are to wrap and with the same name as the script they
are to wrap.
are to wrap.
"""
"""
from
__future__
import
absolute_import
import
sys
import
sys
import
textwrap
import
textwrap
import
subprocess
import
subprocess
...
...
setuptools/tests/text.py
View file @
fb7ab81a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
class
Filenames
:
class
Filenames
:
unicode
=
'smörbröd.py'
unicode
=
'smörbröd.py'
latin_1
=
unicode
.
encode
(
'latin-1'
)
latin_1
=
unicode
.
encode
(
'latin-1'
)
...
...
setuptools/tests/textwrap.py
View file @
fb7ab81a
from
__future__
import
absolute_import
import
textwrap
import
textwrap
...
...
setuptools/unicode_utils.py
View file @
fb7ab81a
import
unicodedata
import
unicodedata
import
sys
import
sys
from
setuptools.extern
import
six
# HFS Plus uses decomposed UTF-8
# HFS Plus uses decomposed UTF-8
def
decompose
(
path
):
def
decompose
(
path
):
if
isinstance
(
path
,
s
ix
.
text_type
):
if
isinstance
(
path
,
s
tr
):
return
unicodedata
.
normalize
(
'NFD'
,
path
)
return
unicodedata
.
normalize
(
'NFD'
,
path
)
try
:
try
:
path
=
path
.
decode
(
'utf-8'
)
path
=
path
.
decode
(
'utf-8'
)
...
@@ -23,7 +21,7 @@ def filesys_decode(path):
...
@@ -23,7 +21,7 @@ def filesys_decode(path):
NONE when no expected encoding works
NONE when no expected encoding works
"""
"""
if
isinstance
(
path
,
s
ix
.
text_type
):
if
isinstance
(
path
,
s
tr
):
return
path
return
path
fs_enc
=
sys
.
getfilesystemencoding
()
or
'utf-8'
fs_enc
=
sys
.
getfilesystemencoding
()
or
'utf-8'
...
...
setuptools/wheel.py
View file @
fb7ab81a
...
@@ -14,13 +14,9 @@ import setuptools
...
@@ -14,13 +14,9 @@ import setuptools
from
pkg_resources
import
parse_version
from
pkg_resources
import
parse_version
from
setuptools.extern.packaging.tags
import
sys_tags
from
setuptools.extern.packaging.tags
import
sys_tags
from
setuptools.extern.packaging.utils
import
canonicalize_name
from
setuptools.extern.packaging.utils
import
canonicalize_name
from
setuptools.extern.six
import
PY3
from
setuptools.command.egg_info
import
write_requirements
from
setuptools.command.egg_info
import
write_requirements
__metaclass__
=
type
WHEEL_NAME
=
re
.
compile
(
WHEEL_NAME
=
re
.
compile
(
r"""^(?P<project_name>.+?)-(?P<version>\
d.*?)
r"""^(?P<project_name>.+?)-(?P<version>\
d.*?)
((-(?P<build>\
d.*?))?-(?P<py_
version>.+?)-(?P<abi>.+?)-(?P<platform>.+?)
((-(?P<build>\
d.*?))?-(?P<py_
version>.+?)-(?P<abi>.+?)-(?P<platform>.+?)
...
@@ -112,7 +108,7 @@ class Wheel:
...
@@ -112,7 +108,7 @@ class Wheel:
def _convert_metadata(zf, destination_eggdir, dist_info, egg_info):
def _convert_metadata(zf, destination_eggdir, dist_info, egg_info):
def get_metadata(name):
def get_metadata(name):
with zf.open(posixpath.join(dist_info, name)) as fp:
with zf.open(posixpath.join(dist_info, name)) as fp:
value = fp.read().decode('utf-8')
if PY3 else fp.read()
value = fp.read().decode('utf-8')
return email.parser.Parser().parsestr(value)
return email.parser.Parser().parsestr(value)
wheel_metadata = get_metadata('WHEEL')
wheel_metadata = get_metadata('WHEEL')
...
...
tools/tox_pip.py
View file @
fb7ab81a
...
@@ -56,24 +56,12 @@ def test_dependencies():
...
@@ -56,24 +56,12 @@ def test_dependencies():
return
filter
(
None
,
map
(
clean
,
raw
))
return
filter
(
None
,
map
(
clean
,
raw
))
def
disable_python_requires
():
"""
On Python 2, install the dependencies that are selective
on Python version while honoring REQUIRES_PYTHON, then
disable REQUIRES_PYTHON so that pip can install this
checkout of setuptools.
"""
pip
(
'install'
,
*
test_dependencies
())
os
.
environ
[
'PIP_IGNORE_REQUIRES_PYTHON'
]
=
'true'
def
run
(
args
):
def
run
(
args
):
os
.
environ
[
'PIP_USE_PEP517'
]
=
'true'
os
.
environ
[
'PIP_USE_PEP517'
]
=
'true'
if
is_install_self
(
args
):
if
is_install_self
(
args
):
remove_setuptools
()
remove_setuptools
()
bootstrap
()
bootstrap
()
sys
.
version_info
>
(
3
,)
or
disable_python_requires
()
pip
(
*
args
)
pip
(
*
args
)
...
...
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