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
f991fbb3
Commit
f991fbb3
authored
Aug 16, 2020
by
mergify[bot]
Committed by
GitHub
Aug 16, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2332 from pypa/debt/cleanup-py2
Remove legacy Python 2 code
parents
4eb5b32f
45e0ea0f
Changes
75
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
75 changed files
with
193 additions
and
2547 deletions
+193
-2547
bootstrap.py
bootstrap.py
+0
-2
pavement.py
pavement.py
+6
-1
pkg_resources/__init__.py
pkg_resources/__init__.py
+5
-34
pkg_resources/_vendor/packaging/requirements.py
pkg_resources/_vendor/packaging/requirements.py
+1
-1
pkg_resources/_vendor/six.py
pkg_resources/_vendor/six.py
+0
-868
pkg_resources/_vendor/vendored.txt
pkg_resources/_vendor/vendored.txt
+0
-1
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/_vendor/packaging/requirements.py
setuptools/_vendor/packaging/requirements.py
+1
-1
setuptools/_vendor/six.py
setuptools/_vendor/six.py
+0
-868
setuptools/_vendor/vendored.txt
setuptools/_vendor/vendored.txt
+0
-1
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 @
f991fbb3
...
...
@@ -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.
"""
from
__future__
import
unicode_literals
import
os
import
sys
import
textwrap
...
...
pavement.py
View file @
f991fbb3
...
...
@@ -22,7 +22,11 @@ def rewrite_packaging(pkg_files, new_root):
"""
for
file
in
pkg_files
.
glob
(
'*.py'
):
text
=
file
.
text
()
text
=
re
.
sub
(
r' (pyparsing|six)'
,
rf'
{
new_root
}
.\1'
,
text
)
text
=
re
.
sub
(
r' (pyparsing)'
,
rf'
{
new_root
}
.\1'
,
text
)
text
=
text
.
replace
(
'from six.moves.urllib import parse'
,
'from urllib import parse'
,
)
file
.
write_text
(
text
)
...
...
@@ -50,6 +54,7 @@ def install(vendor):
subprocess
.
check_call
(
install_args
)
remove_all
(
vendor
.
glob
(
'*.dist-info'
))
remove_all
(
vendor
.
glob
(
'*.egg-info'
))
remove_all
(
vendor
.
glob
(
'six.py'
))
(
vendor
/
'__init__.py'
).
write_text
(
''
)
...
...
pkg_resources/__init__.py
View file @
f991fbb3
# coding: utf-8
"""
Package resource API
--------------------
...
...
@@ -15,8 +14,6 @@ The package resource API is designed to work with normal filesystem packages,
method.
"""
from
__future__
import
absolute_import
import
sys
import
os
import
io
...
...
@@ -54,9 +51,6 @@ try:
except
NameError
:
FileExistsError
=
OSError
from
pkg_resources.extern
import
six
from
pkg_resources.extern.six.moves
import
map
,
filter
# capture these to bypass sandboxing
from
os
import
utime
try
:
...
...
@@ -83,18 +77,9 @@ __import__('pkg_resources.extern.packaging.specifiers')
__import__
(
'pkg_resources.extern.packaging.requirements'
)
__import__
(
'pkg_resources.extern.packaging.markers'
)
__metaclass__
=
type
if
(
3
,
0
)
<
sys
.
version_info
<
(
3
,
5
):
if
sys
.
version_info
<
(
3
,
5
):
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
# satisfy the linters.
require
=
None
...
...
@@ -474,7 +459,7 @@ run_main = run_script
def get_distribution(dist):
"""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)
if isinstance(dist, Requirement):
dist = get_provider(dist)
...
...
@@ -1418,8 +1403,6 @@ class NullProvider:
return ""
path = self._get_metadata_path(name)
value = self._get(path)
if six.PY2:
return value
try:
return value.decode('utf-8')
except UnicodeDecodeError as exc:
...
...
@@ -1910,8 +1893,7 @@ class FileMetadata(EmptyProvider):
return metadata
def _warn_on_replacement(self, metadata):
# Python 2.7 compat for: replacement_char = '�'
replacement_char = b'
\
xef
\
xbf
\
xbd
'.decode('utf-8')
replacement_char = '�'
if replacement_char in metadata:
tmpl = "
{
self
.
path
}
could
not
be
properly
decoded
in
UTF
-
8
"
msg = tmpl.format(**locals())
...
...
@@ -2109,8 +2091,6 @@ class NoDists:
"""
def __bool__(self):
return False
if six.PY2:
__nonzero__ = __bool__
def __call__(self, fullpath):
return iter(())
...
...
@@ -2127,12 +2107,7 @@ def safe_listdir(path):
except OSError as e:
# Ignore the directory if does not exist, not a directory or
# permission denied
ignorable = (
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:
if e.errno not in (errno.ENOTDIR, errno.EACCES, errno.ENOENT):
raise
return ()
...
...
@@ -2406,7 +2381,7 @@ def _set_parent_ns(packageName):
def yield_lines(strs):
"""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():
s = s.strip()
# skip blank lines/comments
...
...
@@ -2844,10 +2819,6 @@ class Distribution:
)
)
if
not
hasattr
(
object
,
'__dir__'
):
# python 2.7 not supported
del
__dir__
@
classmethod
def
from_filename
(
cls
,
filename
,
metadata
=
None
,
**
kw
):
return
cls
.
from_location
(
...
...
pkg_resources/_vendor/packaging/requirements.py
View file @
f991fbb3
...
...
@@ -9,7 +9,7 @@ import re
from
pkg_resources.extern.pyparsing
import
stringStart
,
stringEnd
,
originalTextFor
,
ParseException
from
pkg_resources.extern.pyparsing
import
ZeroOrMore
,
Word
,
Optional
,
Regex
,
Combine
from
pkg_resources.extern.pyparsing
import
Literal
as
L
# noqa
from
pkg_resources.extern.six.moves.
urllib
import
parse
as
urlparse
from
urllib
import
parse
as
urlparse
from
._typing
import
TYPE_CHECKING
from
.markers
import
MARKER_EXPR
,
Marker
...
...
pkg_resources/_vendor/six.py
deleted
100644 → 0
View file @
4eb5b32f
This diff is collapsed.
Click to expand it.
pkg_resources/_vendor/vendored.txt
View file @
f991fbb3
packaging==20.4
pyparsing==2.2.1
six==1.10.0
appdirs==1.4.3
pkg_resources/tests/test_pkg_resources.py
View file @
f991fbb3
# coding: utf-8
from
__future__
import
unicode_literals
import
sys
import
tempfile
import
os
...
...
@@ -20,16 +17,11 @@ except ImportError:
from
pkg_resources
import
(
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
pkg_resources
__metaclass__
=
type
def
timestamp
(
dt
):
"""
...
...
@@ -42,7 +34,7 @@ def timestamp(dt):
return
time
.
mktime
(
dt
.
timetuple
())
class
EggRemover
(
text_type
):
class
EggRemover
(
str
):
def
__call__
(
self
):
if
self
in
sys
.
path
:
sys
.
path
.
remove
(
self
)
...
...
@@ -143,7 +135,7 @@ class TestResourceManager:
path
=
mgr
.
get_cache_path
(
'foo'
)
type_
=
str
(
type
(
path
))
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
):
# Patch to os.path.isdir to create a race condition
...
...
@@ -225,13 +217,6 @@ def test_get_metadata__bad_utf8(tmpdir):
metadata
=
'née'
.
encode
(
'iso-8859-1'
)
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
:
dist
.
get_metadata
(
filename
)
...
...
@@ -247,25 +232,18 @@ def test_get_metadata__bad_utf8(tmpdir):
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
):
"""
Create a distribution directory with no file containing the version.
"""
# Convert the LocalPath object to a string before joining.
dist_dir
=
os
.
path
.
join
(
str
(
tmpdir
),
basename
)
os
.
mkdir
(
dist_dir
)
dist_dir
=
tmpdir
/
basename
dist_dir
.
ensure_dir
()
# Make the directory non-empty so distributions_from_metadata()
# 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
))
assert
len
(
dists
)
==
1
...
...
pkg_resources/tests/test_resources.py
View file @
f991fbb3
from
__future__
import
unicode_literals
import
os
import
sys
import
string
import
platform
import
itertools
from
pkg_resources.extern.six.moves
import
map
import
pytest
from
pkg_resources.extern
import
packaging
...
...
pkg_resources/tests/test_working_set.py
View file @
f991fbb3
...
...
@@ -9,8 +9,6 @@ import pkg_resources
from
.test_resources
import
Metadata
__metaclass__
=
type
def
strip_comments
(
s
):
return
'
\
n
'
.
join
(
...
...
setup.cfg
View file @
f991fbb3
...
...
@@ -70,7 +70,6 @@ tests =
coverage>=4.5.1
pytest-cov>=2.5.1
paver; python_version>="3.6"
futures; python_version=="2.7"
pip>=19.1 # For proper file:// URLs support.
jaraco.envs
...
...
setuptools/__init__.py
View file @
f991fbb3
...
...
@@ -13,27 +13,19 @@ from distutils.util import convert_path
from
._deprecation_warning
import
SetuptoolsDeprecationWarning
from
setuptools.extern.six
import
PY3
,
string_types
from
setuptools.extern.six.moves
import
filter
,
map
import
setuptools.version
from
setuptools.extension
import
Extension
from
setuptools.dist
import
Distribution
from
setuptools.depends
import
Require
from
.
import
monkey
__metaclass__
=
type
__all__
=
[
'setup'
,
'Distribution'
,
'Command'
,
'Extension'
,
'Require'
,
'SetuptoolsDeprecationWarning'
,
'find_packages'
'find_packages'
,
'find_namespace_packages'
,
]
if
PY3
:
__all__
.
append
(
'find_namespace_packages'
)
__version__
=
setuptools
.
version
.
__version__
bootstrap_install_from
=
None
...
...
@@ -122,9 +114,7 @@ class PEP420PackageFinder(PackageFinder):
find_packages
=
PackageFinder
.
find
if
PY3
:
find_namespace_packages
=
PEP420PackageFinder
.
find
find_namespace_packages
=
PEP420PackageFinder
.
find
def
_install_setup_requires
(
attrs
):
...
...
@@ -187,7 +177,7 @@ class Command(_Command):
if
val
is
None
:
setattr
(
self
,
option
,
default
)
return
default
elif
not
isinstance
(
val
,
str
ing_types
):
elif
not
isinstance
(
val
,
str
):
raise
DistutilsOptionError
(
"'%s' must be a %s (got `%s`)"
%
(
option
,
what
,
val
))
return
val
...
...
@@ -201,11 +191,11 @@ class Command(_Command):
val
=
getattr
(
self
,
option
)
if
val
is
None
:
return
elif
isinstance
(
val
,
str
ing_types
):
elif
isinstance
(
val
,
str
):
setattr
(
self
,
option
,
re
.
split
(
r',\
s*|
\s+'
,
val
))
else
:
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
:
ok
=
False
if
not
ok
:
...
...
setuptools/_vendor/packaging/requirements.py
View file @
f991fbb3
...
...
@@ -9,7 +9,7 @@ import re
from
setuptools.extern.pyparsing
import
stringStart
,
stringEnd
,
originalTextFor
,
ParseException
from
setuptools.extern.pyparsing
import
ZeroOrMore
,
Word
,
Optional
,
Regex
,
Combine
from
setuptools.extern.pyparsing
import
Literal
as
L
# noqa
from
setuptools.extern.six.moves.
urllib
import
parse
as
urlparse
from
urllib
import
parse
as
urlparse
from
._typing
import
TYPE_CHECKING
from
.markers
import
MARKER_EXPR
,
Marker
...
...
setuptools/_vendor/six.py
deleted
100644 → 0
View file @
4eb5b32f
This diff is collapsed.
Click to expand it.
setuptools/_vendor/vendored.txt
View file @
f991fbb3
packaging==20.4
pyparsing==2.2.1
six==1.10.0
ordered-set==3.1.1
setuptools/build_meta.py
View file @
f991fbb3
...
...
@@ -32,10 +32,10 @@ import sys
import
tokenize
import
shutil
import
contextlib
import
tempfile
import
setuptools
import
distutils
from
setuptools.py31compat
import
TemporaryDirectory
from
pkg_resources
import
parse_requirements
...
...
@@ -91,19 +91,6 @@ def no_install_setup_requires():
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
):
return
[
name
for
name
in
os
.
listdir
(
a_dir
)
if
os
.
path
.
isdir
(
os
.
path
.
join
(
a_dir
,
name
))]
...
...
@@ -168,8 +155,8 @@ class _BuildMetaBackend(object):
def
prepare_metadata_for_build_wheel
(
self
,
metadata_directory
,
config_settings
=
None
):
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
'dist_info'
,
'--egg-base'
,
_to_str
(
metadata_directory
)
]
sys
.
argv
=
sys
.
argv
[:
1
]
+
[
'dist_info'
,
'--egg-base'
,
metadata_directory
]
with
no_install_setup_requires
():
self
.
run_setup
()
...
...
@@ -207,7 +194,7 @@ class _BuildMetaBackend(object):
# Build in a temporary directory, then copy to the target.
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
+
[
'--dist-dir'
,
tmp_dist_dir
]
+
config_settings
[
"--global-option"
])
...
...
setuptools/command/alias.py
View file @
f991fbb3
from
distutils.errors
import
DistutilsOptionError
from
setuptools.extern.six.moves
import
map
from
setuptools.command.setopt
import
edit_config
,
option_base
,
config_file
...
...
setuptools/command/bdist_egg.py
View file @
f991fbb3
...
...
@@ -13,24 +13,16 @@ import textwrap
import
marshal
import
warnings
from
setuptools.extern
import
six
from
pkg_resources
import
get_build_platform
,
Distribution
,
ensure_directory
from
pkg_resources
import
EntryPoint
from
setuptools.extension
import
Library
from
setuptools
import
Command
,
SetuptoolsDeprecationWarning
try
:
# Python 2.7 or >=3.2
from
sysconfig
import
get_path
,
get_python_version
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
():
return
get_python_lib
(
False
)
def
_get_purelib
():
return
get_path
(
"purelib"
)
def
strip_module
(
filename
):
...
...
@@ -420,9 +412,7 @@ def scan_module(egg_dir, base, name, stubs):
return True # Extension module
pkg = base[len(egg_dir) + 1:].replace(os.sep, '.')
module = pkg + (pkg and '.' or '') + os.path.splitext(name)[0]
if six.PY2:
skip = 8 # skip magic & date
elif sys.version_info < (3, 7):
if sys.version_info < (3, 7):
skip = 12 # skip magic & date & file size
else:
skip = 16 # skip magic & reserved? & date & file size
...
...
@@ -453,7 +443,7 @@ def iter_symbols(code):
for name in code.co_names:
yield name
for const in code.co_consts:
if isinstance(const, s
ix.string_types
):
if isinstance(const, s
tr
):
yield const
elif isinstance(const, CodeType):
for name in iter_symbols(const):
...
...
setuptools/command/build_ext.py
View file @
f991fbb3
import
os
import
sys
import
itertools
from
importlib.machinery
import
EXTENSION_SUFFIXES
from
distutils.command.build_ext
import
build_ext
as
_du_build_ext
from
distutils.file_util
import
copy_file
from
distutils.ccompiler
import
new_compiler
...
...
@@ -9,15 +10,6 @@ from distutils.errors import DistutilsError
from
distutils
import
log
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
:
# Attempt to use Cython for building extensions, if available
...
...
@@ -115,11 +107,7 @@ class build_ext(_build_ext):
filename
=
_build_ext
.
get_ext_filename
(
self
,
fullname
)
if
fullname
in
self
.
ext_map
:
ext
=
self
.
ext_map
[
fullname
]
use_abi3
=
(
not
six
.
PY2
and
getattr
(
ext
,
'py_limited_api'
)
and
get_abi3_suffix
()
)
use_abi3
=
getattr
(
ext
,
'py_limited_api'
)
and
get_abi3_suffix
()
if
use_abi3
:
so_ext
=
get_config_var
(
'EXT_SUFFIX'
)
filename
=
filename
[:
-
len
(
so_ext
)]
...
...
setuptools/command/build_py.py
View file @
f991fbb3
...
...
@@ -9,9 +9,6 @@ import distutils.errors
import
itertools
import
stat
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
,
filter
,
filterfalse
try
:
from
setuptools.lib2to3_ex
import
Mixin2to3
except
ImportError
:
...
...
@@ -73,9 +70,6 @@ class build_py(orig.build_py, Mixin2to3):
return
orig
.
build_py
.
__getattr__
(
self
,
attr
)
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
,
package
)
if
copied
:
...
...
@@ -249,7 +243,7 @@ def _unique_everseen(iterable, key=None):
seen
=
set
()
seen_add
=
seen
.
add
if
key
is
None
:
for
element
in
filterfalse
(
seen
.
__contains__
,
iterable
):
for
element
in
itertools
.
filterfalse
(
seen
.
__contains__
,
iterable
):
seen_add
(
element
)
yield
element
else
:
...
...
setuptools/command/develop.py
View file @
f991fbb3
...
...
@@ -5,15 +5,11 @@ import os
import
glob
import
io
from
setuptools.extern
import
six
import
pkg_resources
from
setuptools.command.easy_install
import
easy_install
from
setuptools
import
namespaces
import
setuptools
__metaclass__
=
type
class
develop
(
namespaces
.
DevelopInstaller
,
easy_install
):
"""Set up package for development"""
...
...
@@ -108,7 +104,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
return
path_to_setup
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:
# Ensure metadata is up-to-date
...
...
setuptools/command/easy_install.py
View file @
f991fbb3
...
...
@@ -38,18 +38,15 @@ import contextlib
import
subprocess
import
shlex
import
io
import
configparser
from
sysconfig
import
get_config_vars
,
get_path
from
setuptools
import
SetuptoolsDeprecationWarning
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
configparser
,
map
from
setuptools
import
Command
from
setuptools.sandbox
import
run_setup
from
setuptools.py27compat
import
rmtree_safe
from
setuptools.command
import
setopt
from
setuptools.archive_util
import
unpack_archive
from
setuptools.package_index
import
(
...
...
@@ -65,8 +62,6 @@ from pkg_resources import (
)
import
pkg_resources
__metaclass__
=
type
# Turn on PEP440Warnings
warnings
.
filterwarnings
(
"default"
,
category
=
pkg_resources
.
PEP440Warning
)
...
...
@@ -96,28 +91,16 @@ def samefile(p1, p2):
return
norm_p1
==
norm_p2
if
six
.
PY2
:
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'
)
def
_to_bytes
(
s
):
return
s
.
encode
(
'utf8'
)
def
isascii
(
s
):
try
:
s
.
encode
(
'ascii'
)
return
True
except
UnicodeError
:
return
False
def
isascii
(
s
):
try
:
s
.
encode
(
'ascii'
)
return
True
except
UnicodeError
:
return
False
def
_one_liner
(
text
):
...
...
@@ -341,7 +324,7 @@ class easy_install(Command):
self
.
local_index
=
Environment
(
self
.
shadow_path
+
sys
.
path
)
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
()
else
:
self
.
find_links
=
[]
...
...
@@ -650,7 +633,7 @@ class easy_install(Command):
# cast to str as workaround for #709 and #710 and #712
yield
str
(
tmpdir
)
finally
:
os
.
path
.
exists
(
tmpdir
)
and
rmtree
(
rmtree_safe
(
tmpdir
)
)
os
.
path
.
exists
(
tmpdir
)
and
rmtree
(
tmpdir
)
def
easy_install
(
self
,
spec
,
deps
=
False
):
with
self
.
_tmpdir
()
as
tmpdir
:
...
...
@@ -1318,7 +1301,7 @@ class easy_install(Command):
if
not
self
.
user
:
return
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
):
self
.
debug_print
(
"os.makedirs('%s', 0o700)"
%
path
)
os
.
makedirs
(
path
,
0o700
)
...
...
@@ -1499,7 +1482,7 @@ def extract_wininst_cfg(dist_filename):
# Now the config is in bytes, but for RawConfigParser, it should
# be text, so decode it.
config
=
config
.
decode
(
sys
.
getfilesystemencoding
())
cfg
.
readfp
(
six
.
StringIO
(
config
))
cfg
.
readfp
(
io
.
StringIO
(
config
))
except
configparser
.
Error
:
return
None
if
not
cfg
.
has_section
(
'metadata'
)
or
not
cfg
.
has_section
(
'Setup'
):
...
...
@@ -1534,9 +1517,7 @@ def get_exe_prefixes(exe_filename):
if
name
.
endswith
(
'-nspkg.pth'
):
continue
if
parts
[
0
].
upper
()
in
(
'PURELIB'
,
'PLATLIB'
):
contents
=
z
.
read
(
name
)
if
not
six
.
PY2
:
contents
=
contents
.
decode
()
contents
=
z
.
read
(
name
).
decode
()
for
pth
in
yield_lines
(
contents
):
pth
=
pth
.
strip
().
replace
(
'
\
\
'
,
'/'
)
if
not
pth
.
startswith
(
'import'
):
...
...
@@ -1700,7 +1681,8 @@ def auto_chmod(func, arg, exc):
chmod
(
arg
,
stat
.
S_IWRITE
)
return
func
(
arg
)
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
):
...
...
@@ -2263,10 +2245,7 @@ def get_win_launcher(type):
def
load_launcher_manifest
(
name
):
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
()
def
rmtree
(
path
,
ignore_errors
=
False
,
onerror
=
auto_chmod
):
...
...
setuptools/command/egg_info.py
View file @
f991fbb3
...
...
@@ -16,9 +16,6 @@ import warnings
import
time
import
collections
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
from
setuptools
import
Command
from
setuptools.command.sdist
import
sdist
from
setuptools.command.sdist
import
walk_revctrl
...
...
@@ -267,8 +264,7 @@ class egg_info(InfoCommon, Command):
to the file.
"""
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:
f = open(filename, '
wb
')
f.write(data)
...
...
@@ -647,7 +643,7 @@ def _write_requirements(stream, reqs):
def
write_requirements
(
cmd
,
basename
,
filename
):
dist
=
cmd
.
distribution
data
=
six
.
StringIO
()
data
=
io
.
StringIO
()
_write_requirements
(
data
,
dist
.
install_requires
)
extras_require
=
dist
.
extras_require
or
{}
for
extra
in
sorted
(
extras_require
):
...
...
@@ -687,12 +683,12 @@ def write_arg(cmd, basename, filename, force=False):
def
write_entries
(
cmd
,
basename
,
filename
):
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
elif
ep
is
not
None
:
data
=
[]
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
=
'
\
n
'
.
join
(
sorted
(
map
(
str
,
contents
.
values
())))
data
.
append
(
'[%s]
\
n
%s
\
n
\
n
'
%
(
section
,
contents
))
...
...
setuptools/command/py36compat.py
View file @
f991fbb3
...
...
@@ -3,8 +3,6 @@ from glob import glob
from
distutils.util
import
convert_path
from
distutils.command
import
sdist
from
setuptools.extern.six.moves
import
filter
class
sdist_add_defaults
:
"""
...
...
setuptools/command/rotate.py
View file @
f991fbb3
...
...
@@ -4,8 +4,6 @@ from distutils.errors import DistutilsOptionError
import
os
import
shutil
from
setuptools.extern
import
six
from
setuptools
import
Command
...
...
@@ -38,7 +36,7 @@ class rotate(Command):
self
.
keep
=
int
(
self
.
keep
)
except
ValueError
as
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
=
[
convert_path
(
p
.
strip
())
for
p
in
self
.
match
.
split
(
','
)
]
...
...
setuptools/command/sdist.py
View file @
f991fbb3
...
...
@@ -5,7 +5,7 @@ import sys
import
io
import
contextlib
from
setuptools.extern
import
six
,
ordered_set
from
setuptools.extern
import
ordered_set
from
.py36compat
import
sdist_add_defaults
...
...
@@ -98,34 +98,8 @@ class sdist(sdist_add_defaults, orig.sdist):
if
orig_val
is
not
NoValue
:
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
):
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'
):
self
.
filelist
.
append
(
'pyproject.toml'
)
...
...
@@ -158,10 +132,7 @@ class sdist(sdist_add_defaults, orig.sdist):
def
_add_defaults_data_files
(
self
):
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
:
log
.
warn
(
"data_files contains unexpected objects"
)
...
...
@@ -207,12 +178,11 @@ class sdist(sdist_add_defaults, orig.sdist):
manifest
=
open
(
self
.
manifest
,
'rb'
)
for
line
in
manifest
:
# The manifest must contain UTF-8. See #303.
if
not
six
.
PY2
:
try
:
line
=
line
.
decode
(
'UTF-8'
)
except
UnicodeDecodeError
:
log
.
warn
(
"%r not UTF-8 decodable -- skipping"
%
line
)
continue
try
:
line
=
line
.
decode
(
'UTF-8'
)
except
UnicodeDecodeError
:
log
.
warn
(
"%r not UTF-8 decodable -- skipping"
%
line
)
continue
# ignore comments and blank lines
line
=
line
.
strip
()
if
line
.
startswith
(
'#'
)
or
not
line
:
...
...
setuptools/command/setopt.py
View file @
f991fbb3
...
...
@@ -3,8 +3,7 @@ from distutils import log
from
distutils.errors
import
DistutilsOptionError
import
distutils
import
os
from
setuptools.extern.six.moves
import
configparser
import
configparser
from
setuptools
import
Command
...
...
setuptools/command/test.py
View file @
f991fbb3
...
...
@@ -8,17 +8,12 @@ from distutils.errors import DistutilsError, DistutilsOptionError
from
distutils
import
log
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
,
working_set
,
_namespace_packages
,
evaluate_marker
,
add_activation_listener
,
require
,
EntryPoint
)
from
setuptools
import
Command
from
.build_py
import
_unique_everseen
__metaclass__
=
type
class
ScanningLoader
(
TestLoader
):
...
...
@@ -129,8 +124,7 @@ class test(Command):
@
contextlib
.
contextmanager
def
project_on_sys_path
(
self
,
include_dists
=
[]):
with_2to3
=
not
six
.
PY2
and
getattr
(
self
.
distribution
,
'use_2to3'
,
False
)
with_2to3
=
getattr
(
self
.
distribution
,
'use_2to3'
,
False
)
if
with_2to3
:
# If we run 2to3 we can not do this inplace:
...
...
@@ -241,7 +235,7 @@ class test(Command):
# Purge modules under test from sys.modules. The test loader will
# re-import them from the build location. Required when 2to3 is used
# 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
]
if
module
in
_namespace_packages
:
del_modules
=
[]
...
...
setuptools/command/upload_docs.py
View file @
f991fbb3
...
...
@@ -15,17 +15,15 @@ import tempfile
import
shutil
import
itertools
import
functools
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
http_client
,
urllib
import
http.client
import
urllib.parse
from
pkg_resources
import
iter_entry_points
from
.upload
import
upload
def
_encode
(
s
):
errors
=
'strict'
if
six
.
PY2
else
'surrogateescape'
return
s
.
encode
(
'utf-8'
,
errors
)
return
s
.
encode
(
'utf-8'
,
'surrogateescape'
)
class
upload_docs
(
upload
):
...
...
@@ -152,9 +150,7 @@ class upload_docs(upload):
}
# set up the authentication
credentials
=
_encode
(
self
.
username
+
':'
+
self
.
password
)
credentials
=
standard_b64encode
(
credentials
)
if
not
six
.
PY2
:
credentials
=
credentials
.
decode
(
'ascii'
)
credentials
=
standard_b64encode
(
credentials
).
decode
(
'ascii'
)
auth
=
"Basic "
+
credentials
body
,
ct
=
self
.
_build_multipart
(
data
)
...
...
@@ -169,9 +165,9 @@ class upload_docs(upload):
urllib
.
parse
.
urlparse
(
self
.
repository
)
assert
not
params
and
not
query
and
not
fragments
if
schema
==
'http'
:
conn
=
http
_
client
.
HTTPConnection
(
netloc
)
conn
=
http
.
client
.
HTTPConnection
(
netloc
)
elif
schema
==
'https'
:
conn
=
http
_
client
.
HTTPSConnection
(
netloc
)
conn
=
http
.
client
.
HTTPSConnection
(
netloc
)
else
:
raise
AssertionError
(
"unsupported schema "
+
schema
)
...
...
setuptools/config.py
View file @
f991fbb3
from
__future__
import
absolute_import
,
unicode_literals
import
ast
import
io
import
os
...
...
@@ -15,10 +14,6 @@ import contextlib
from
distutils.errors
import
DistutilsOptionError
,
DistutilsFileError
from
setuptools.extern.packaging.version
import
LegacyVersion
,
parse
from
setuptools.extern.packaging.specifiers
import
SpecifierSet
from
setuptools.extern.six
import
string_types
,
PY3
__metaclass__
=
type
class
StaticModule
:
...
...
@@ -324,7 +319,7 @@ class ConfigHandler:
"""
include_directive
=
'file:'
if
not
isinstance
(
value
,
str
ing_types
):
if
not
isinstance
(
value
,
str
):
return
value
if
not
value
.
startswith
(
include_directive
):
...
...
@@ -559,7 +554,7 @@ class ConfigMetadataHandler(ConfigHandler):
if
callable
(
version
):
version
=
version
()
if
not
isinstance
(
version
,
str
ing_types
):
if
not
isinstance
(
version
,
str
):
if
hasattr
(
version
,
'__iter__'
):
version
=
'.'
.
join
(
map
(
str
,
version
))
else
:
...
...
@@ -614,9 +609,6 @@ class ConfigOptionsHandler(ConfigHandler):
return
self
.
_parse_list
(
value
)
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.
find_kwargs
=
self
.
parse_section_packages__find
(
...
...
setuptools/depends.py
View file @
f991fbb3
import
sys
import
marshal
import
contextlib
import
dis
from
distutils.version
import
StrictVersion
from
.py33compat
import
Bytecode
from
.py27compat
import
find_module
,
PY_COMPILED
,
PY_FROZEN
,
PY_SOURCE
from
.
import
py27compat
from
._imp
import
find_module
,
PY_COMPILED
,
PY_FROZEN
,
PY_SOURCE
from
.
import
_imp
__all__
=
[
...
...
@@ -111,12 +110,12 @@ def get_module_constant(module, symbol, default=-1, paths=None):
f
.
read
(
8
)
# skip magic & date
code
=
marshal
.
load
(
f
)
elif
kind
==
PY_FROZEN
:
code
=
py27compat
.
get_frozen_object
(
module
,
paths
)
code
=
_imp
.
get_frozen_object
(
module
,
paths
)
elif
kind
==
PY_SOURCE
:
code
=
compile
(
f
.
read
(),
path
,
'exec'
)
else
:
# Not something we can parse; we'll have to import it. :(
imported
=
py27compat
.
get_module
(
module
,
paths
,
info
)
imported
=
_imp
.
get_module
(
module
,
paths
,
info
)
return
getattr
(
imported
,
symbol
,
None
)
return
extract_constant
(
code
,
symbol
,
default
)
...
...
@@ -146,7 +145,7 @@ def extract_constant(code, symbol, default=-1):
const
=
default
for
byte_code
in
Bytecode
(
code
):
for
byte_code
in
dis
.
Bytecode
(
code
):
op
=
byte_code
.
opcode
arg
=
byte_code
.
arg
...
...
setuptools/dist.py
View file @
f991fbb3
...
...
@@ -23,10 +23,8 @@ from distutils.errors import DistutilsOptionError, DistutilsSetupError
from
distutils.util
import
rfc822_escape
from
distutils.version
import
StrictVersion
from
setuptools.extern
import
six
from
setuptools.extern
import
packaging
from
setuptools.extern
import
ordered_set
from
setuptools.extern.six.moves
import
map
,
filter
,
filterfalse
from
.
import
SetuptoolsDeprecationWarning
...
...
@@ -126,12 +124,8 @@ def write_pkg_file(self, file):
"""
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
):
file
.
write
(
"%s: %s
\
n
"
%
(
key
,
value
))
def
write_field
(
key
,
value
):
file
.
write
(
"%s: %s
\
n
"
%
(
key
,
value
))
write_field
(
'Metadata-Version'
,
str
(
version
))
write_field
(
'Name'
,
self
.
get_name
())
...
...
@@ -308,7 +302,7 @@ def check_entry_points(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"
)
...
...
@@ -319,7 +313,7 @@ def check_package_data(dist, attr, value):
"{!r} must be a dictionary mapping package names to lists of "
"string wildcard patterns"
.
format
(
attr
))
for
k
,
v
in
value
.
items
():
if
not
isinstance
(
k
,
s
ix
.
string_types
):
if
not
isinstance
(
k
,
s
tr
):
raise
DistutilsSetupError
(
"keys of {!r} dict must be strings (got {!r})"
.
format
(
attr
,
k
)
...
...
@@ -537,7 +531,7 @@ class Distribution(_Distribution):
spec_inst_reqs
=
getattr
(
self
,
'install_requires'
,
None
)
or
()
inst_reqs
=
list
(
pkg_resources
.
parse_requirements
(
spec_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
))
for
r
in
complex_reqs
:
...
...
@@ -560,10 +554,10 @@ class Distribution(_Distribution):
this method provides the same functionality in subtly-improved
ways.
"""
from
setuptools.extern.six.moves.
configparser
import
ConfigParser
from
configparser
import
ConfigParser
# 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
=
[
'install-base'
,
'install-platbase'
,
'install-lib'
,
'install-platlib'
,
'install-purelib'
,
'install-headers'
,
...
...
@@ -585,14 +579,14 @@ class Distribution(_Distribution):
with
io
.
open
(
filename
,
encoding
=
'utf-8'
)
as
reader
:
if
DEBUG
:
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
():
options
=
parser
.
options
(
section
)
opt_dict
=
self
.
get_option_dict
(
section
)
for
opt
in
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_dict
[
opt
]
=
(
filename
,
val
)
...
...
@@ -616,26 +610,6 @@ class Distribution(_Distribution):
except
ValueError
as
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
):
"""
Set the options for 'command_obj' from 'option_dict'. Basically
...
...
@@ -669,7 +643,7 @@ class Distribution(_Distribution):
neg_opt
=
{}
try
:
is_string
=
isinstance
(
value
,
s
ix
.
string_types
)
is_string
=
isinstance
(
value
,
s
tr
)
if
option
in
neg_opt
and
is_string
:
setattr
(
command_obj
,
neg_opt
[
option
],
not
strtobool
(
value
))
elif
option
in
bool_opts
and
is_string
:
...
...
@@ -1003,7 +977,7 @@ class Distribution(_Distribution):
"""
import
sys
if
s
ix
.
PY2
or
s
elf
.
help_commands
:
if
self
.
help_commands
:
return
_Distribution
.
handle_display_options
(
self
,
option_order
)
# Stdout may be StringIO (e.g. in tests)
...
...
setuptools/extension.py
View file @
f991fbb3
...
...
@@ -4,8 +4,6 @@ import distutils.core
import
distutils.errors
import
distutils.extension
from
setuptools.extern.six.moves
import
map
from
.monkey
import
get_unpatched
...
...
setuptools/installer.py
View file @
f991fbb3
...
...
@@ -2,20 +2,18 @@ import glob
import
os
import
subprocess
import
sys
import
tempfile
from
distutils
import
log
from
distutils.errors
import
DistutilsError
import
pkg_resources
from
setuptools.command.easy_install
import
easy_install
from
setuptools.extern
import
six
from
setuptools.wheel
import
Wheel
from
.py31compat
import
TemporaryDirectory
def
_fixup_find_links
(
find_links
):
"""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
()
assert
isinstance
(
find_links
,
(
tuple
,
list
))
return
find_links
...
...
@@ -103,7 +101,7 @@ def fetch_build_egg(dist, req):
for
egg_dist
in
pkg_resources
.
find_distributions
(
eggs_dir
):
if
egg_dist
in
req
and
environment
.
can_add
(
egg_dist
):
return
egg_dist
with
TemporaryDirectory
()
as
tmpdir
:
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
cmd
=
[
sys
.
executable
,
'-m'
,
'pip'
,
'--disable-pip-version-check'
,
...
...
setuptools/lib2to3_ex.py
View file @
f991fbb3
...
...
@@ -2,9 +2,6 @@
Customized Mixin2to3 support:
- adds support for converting doctests
This module raises an ImportError on Python 2.
"""
import
warnings
...
...
setuptools/monkey.py
View file @
f991fbb3
...
...
@@ -10,8 +10,6 @@ import functools
from
importlib
import
import_module
import
inspect
from
setuptools.extern
import
six
import
setuptools
__all__
=
[]
...
...
@@ -37,7 +35,7 @@ def _get_mro(cls):
def
get_unpatched
(
item
):
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
lambda
item
:
None
)
...
...
setuptools/msvc.py
View file @
f991fbb3
...
...
@@ -30,12 +30,10 @@ import subprocess
import
distutils.errors
from
setuptools.extern.packaging.version
import
LegacyVersion
from
setuptools.extern.six.moves
import
filterfalse
from
.monkey
import
get_unpatched
if
platform
.
system
()
==
'Windows'
:
from
setuptools.extern.six.moves
import
winreg
import
winreg
from
os
import
environ
else
:
# Mock winreg and environ so the module can be imported on this platform.
...
...
@@ -1820,7 +1818,7 @@ class EnvironmentInfo:
seen = set()
seen_add = seen.add
if key is None:
for element in filterfalse(seen.__contains__, iterable):
for element in
itertools.
filterfalse(seen.__contains__, iterable):
seen_add(element)
yield element
else:
...
...
setuptools/namespaces.py
View file @
f991fbb3
...
...
@@ -2,8 +2,6 @@ import os
from
distutils
import
log
import
itertools
from
setuptools.extern.six.moves
import
map
flatten
=
itertools
.
chain
.
from_iterable
...
...
@@ -72,8 +70,6 @@ class Installer:
return
"sys._getframe(1).f_locals['sitedir']"
def
_gen_nspkg_line
(
self
,
pkg
):
# ensure pkg is not a unicode string under Python 2.7
pkg
=
str
(
pkg
)
pth
=
tuple
(
pkg
.
split
(
'.'
))
root
=
self
.
_get_root
()
tmpl_lines
=
self
.
_nspkg_tmpl
...
...
setuptools/package_index.py
View file @
f991fbb3
...
...
@@ -2,17 +2,21 @@
import
sys
import
os
import
re
import
io
import
shutil
import
socket
import
base64
import
hashlib
import
itertools
import
warnings
import
configparser
import
html
import
http.client
import
urllib.parse
import
urllib.request
import
urllib.error
from
functools
import
wraps
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
urllib
,
http_client
,
configparser
,
map
import
setuptools
from
pkg_resources
import
(
CHECKOUT_DIST
,
Distribution
,
BINARY_DIST
,
normalize_path
,
SOURCE_DIST
,
...
...
@@ -23,12 +27,8 @@ from setuptools import ssl_support
from
distutils
import
log
from
distutils.errors
import
DistutilsError
from
fnmatch
import
translate
from
setuptools.py27compat
import
get_all_headers
from
setuptools.py33compat
import
unescape
from
setuptools.wheel
import
Wheel
__metaclass__
=
type
EGG_FRAGMENT
=
re
.
compile
(
r'^egg=([-A-Za-z0-9_.+!]+)$'
)
HREF
=
re
.
compile
(
r"""href\
s*=
\s*['"]?([^'"> ]+)"""
,
re
.
I
)
PYPI_MD5
=
re
.
compile
(
...
...
@@ -191,7 +191,7 @@ def unique_everseen(iterable, key=None):
seen = set()
seen_add = seen.add
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)
yield element
else:
...
...
@@ -740,7 +740,7 @@ class PackageIndex(Environment):
size = -1
if "content-length" in 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))
self.reporthook(url, filename, blocknum, bs, size)
with open(filename, 'wb') as tfp:
...
...
@@ -767,7 +767,7 @@ class PackageIndex(Environment):
return local_open(url)
try:
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])
if warning:
self.warn(warning, msg)
...
...
@@ -781,7 +781,7 @@ class PackageIndex(Environment):
else:
raise DistutilsError("Download error for %s: %s"
% (url, v.reason)) from v
except http
_
client.BadStatusLine as v:
except http
.
client.BadStatusLine as v:
if warning:
self.warn(warning, v.line)
else:
...
...
@@ -790,7 +790,7 @@ class PackageIndex(Environment):
'down, %s' %
(url, v.line)
) from v
except (http
_
client.HTTPException, socket.error) as v:
except (http
.
client.HTTPException, socket.error) as v:
if warning:
self.warn(warning, v)
else:
...
...
@@ -940,7 +940,7 @@ entity_sub = re.compile(r'&(#(\d+|x[\da-fA-F]+)|[\w.:-]+);?').sub
def decode_entity(match):
what = match.group(0)
return unescape(what)
return
html.
unescape(what)
def htmldecode(text):
...
...
@@ -972,8 +972,7 @@ def socket_timeout(timeout=15):
def _encode_auth(auth):
"""
A
function
compatible
with
Python
2.3
-
3.3
that
will
encode
auth
from
a
URL
suitable
for
an
HTTP
header
.
Encode
auth
from
a
URL
suitable
for
an
HTTP
header
.
>>>
str
(
_encode_auth
(
'username%3Apassword'
))
'dXNlcm5hbWU6cGFzc3dvcmQ='
...
...
@@ -1056,7 +1055,7 @@ def open_with_auth(url, opener=urllib.request.urlopen):
# Double scheme does not raise on macOS as revealed by a
# failing test. We would expect "nonnumeric port". Refs #20.
if netloc.endswith(':'):
raise http
_
client.InvalidURL("nonnumeric port: ''")
raise http
.
client.InvalidURL("nonnumeric port: ''")
if scheme in ('http', 'https'):
auth, address = _splituser(netloc)
...
...
@@ -1136,5 +1135,5 @@ def local_open(url):
status, message, body = 404, "Path not found", "Not found"
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)
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 @
f991fbb3
...
...
@@ -8,9 +8,7 @@ import re
import
contextlib
import
pickle
import
textwrap
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
builtins
,
map
import
builtins
import
pkg_resources
from
distutils.errors
import
DistutilsError
...
...
@@ -138,7 +136,7 @@ class ExceptionSaver:
return
type
,
exc
=
map
(
pickle
.
loads
,
self
.
_saved
)
six
.
reraise
(
type
,
exc
,
self
.
_tb
)
raise
exc
.
with_traceback
(
self
.
_tb
)
@
contextlib
.
contextmanager
...
...
@@ -251,15 +249,8 @@ def run_setup(setup_script, args):
working_set
.
__init__
()
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
):
ns
=
dict
(
__file__
=
dunder_file
,
__name__
=
'__main__'
)
ns
=
dict
(
__file__
=
setup_script
,
__name__
=
'__main__'
)
_execfile
(
setup_script
,
ns
)
except
SystemExit
as
v
:
if
v
.
args
and
v
.
args
[
0
]:
...
...
setuptools/ssl_support.py
View file @
f991fbb3
...
...
@@ -3,8 +3,9 @@ import socket
import
atexit
import
re
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
...
...
@@ -31,7 +32,7 @@ cert_paths = """
try
:
HTTPSHandler
=
urllib
.
request
.
HTTPSHandler
HTTPSConnection
=
http
_
client
.
HTTPSConnection
HTTPSConnection
=
http
.
client
.
HTTPSConnection
except
AttributeError
:
HTTPSHandler
=
HTTPSConnection
=
object
...
...
setuptools/tests/__init__.py
View file @
f991fbb3
...
...
@@ -2,19 +2,12 @@ import locale
import
pytest
from
setuptools.extern.six
import
PY2
,
PY3
__all__
=
[
'fail_on_ascii'
,
'py2_only'
,
'py3_only'
,
'ack_2to3'
]
__all__
=
[
'fail_on_ascii'
,
'ack_2to3'
]
is_ascii
=
locale
.
getpreferredencoding
()
==
'ANSI_X3.4-1968'
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'
)
setuptools/tests/contexts.py
View file @
f991fbb3
...
...
@@ -4,8 +4,8 @@ import shutil
import
sys
import
contextlib
import
site
import
io
from
setuptools.extern
import
six
import
pkg_resources
...
...
@@ -58,8 +58,8 @@ def quiet():
old_stdout
=
sys
.
stdout
old_stderr
=
sys
.
stderr
new_stdout
=
sys
.
stdout
=
six
.
StringIO
()
new_stderr
=
sys
.
stderr
=
six
.
StringIO
()
new_stdout
=
sys
.
stdout
=
io
.
StringIO
()
new_stderr
=
sys
.
stderr
=
io
.
StringIO
()
try
:
yield
new_stdout
,
new_stderr
finally
:
...
...
setuptools/tests/namespaces.py
View file @
f991fbb3
from
__future__
import
absolute_import
,
unicode_literals
import
textwrap
...
...
setuptools/tests/server.py
View file @
f991fbb3
...
...
@@ -4,13 +4,12 @@
import
os
import
time
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
(
BaseHTTPServer
.
HTTPServer
):
class
IndexServer
(
http
.
server
.
HTTPServer
):
"""Basic single-threaded http server simulating a package index
You can use this server in unittest like this::
...
...
@@ -24,8 +23,8 @@ class IndexServer(BaseHTTPServer.HTTPServer):
def
__init__
(
self
,
server_address
=
(
''
,
0
),
RequestHandlerClass
=
SimpleHTTPS
erver
.
SimpleHTTPRequestHandler
):
BaseHTTPS
erver
.
HTTPServer
.
__init__
(
RequestHandlerClass
=
http
.
s
erver
.
SimpleHTTPRequestHandler
):
http
.
s
erver
.
HTTPServer
.
__init__
(
self
,
server_address
,
RequestHandlerClass
)
self
.
_run
=
True
...
...
@@ -48,14 +47,14 @@ class IndexServer(BaseHTTPServer.HTTPServer):
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
):
requests
=
vars
(
self
.
server
).
setdefault
(
'requests'
,
[])
requests
.
append
(
self
)
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.
"""
...
...
@@ -63,7 +62,7 @@ class MockServer(BaseHTTPServer.HTTPServer, threading.Thread):
def
__init__
(
self
,
server_address
=
(
''
,
0
),
RequestHandlerClass
=
RequestRecorder
):
BaseHTTPS
erver
.
HTTPServer
.
__init__
(
http
.
s
erver
.
HTTPServer
.
__init__
(
self
,
server_address
,
RequestHandlerClass
)
threading
.
Thread
.
__init__
(
self
)
self
.
setDaemon
(
True
)
...
...
@@ -87,5 +86,5 @@ def path_to_url(path, authority=None):
base
=
'file:'
if
authority
is
not
None
:
base
+=
'//'
+
authority
url
=
url
join
(
base
,
pathname2url
(
path
))
url
=
url
lib
.
parse
.
urljoin
(
base
,
urllib
.
request
.
pathname2url
(
path
))
return
url
setuptools/tests/test_archive_util.py
View file @
f991fbb3
...
...
@@ -3,8 +3,6 @@
import
tarfile
import
io
from
setuptools.extern
import
six
import
pytest
from
setuptools
import
archive_util
...
...
@@ -22,8 +20,6 @@ def tarfile_with_unicode(tmpdir):
data
=
b""
filename
=
"testimäge.png"
if
six
.
PY2
:
filename
=
filename
.
decode
(
'utf-8'
)
t
=
tarfile
.
TarInfo
(
filename
)
t
.
size
=
len
(
data
)
...
...
@@ -39,4 +35,4 @@ def tarfile_with_unicode(tmpdir):
@
pytest
.
mark
.
xfail
(
reason
=
"#710 and #712"
)
def
test_unicode_files
(
tarfile_with_unicode
,
tmpdir
):
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 @
f991fbb3
...
...
@@ -2,8 +2,6 @@ import sys
import
distutils.command.build_ext
as
orig
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.dist
import
Distribution
from
setuptools.extension
import
Extension
...
...
@@ -41,7 +39,7 @@ class TestBuildExt:
assert
'spam.eggs'
in
cmd
.
ext_map
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'
))
elif
sys
.
platform
==
'win32'
:
assert
res
.
endswith
(
'eggs.pyd'
)
...
...
setuptools/tests/test_build_meta.py
View file @
f991fbb3
from
__future__
import
unicode_literals
import
os
import
shutil
import
tarfile
import
importlib
from
concurrent
import
futures
import
pytest
from
.files
import
build_files
from
.textwrap
import
DALS
from
.
import
py2_only
__metaclass__
=
type
# Backports on Python 2.7
import
importlib
from
concurrent
import
futures
class
BuildBackendBase
:
...
...
@@ -220,15 +213,6 @@ class TestBuildMetaBackend:
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
):
# explicitly specifying the dist folder should work
# the folder sdist_directory and the ``--dist-dir`` can be the same
...
...
setuptools/tests/test_config.py
View file @
f991fbb3
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
contextlib
import
configparser
import
pytest
...
...
@@ -9,9 +7,6 @@ from distutils.errors import DistutilsOptionError, DistutilsFileError
from
mock
import
patch
from
setuptools.dist
import
Distribution
,
_Distribution
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
...
...
@@ -311,10 +306,6 @@ class TestMetadata:
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
metadata
.
version
==
'2016.11.26'
if
six
.
PY2
:
# static version loading is unsupported on Python 2
return
config
.
write
(
'[metadata]
\
n
'
'version = attr: fake_package.subpkg_b.mod.VERSION
\
n
'
...
...
@@ -719,19 +710,6 @@ class TestOptions:
assert
set
(
dist
.
packages
)
==
set
(
[
'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
):
dir_package
,
config
=
fake_env
(
tmpdir
,
...
...
setuptools/tests/test_develop.py
View file @
f991fbb3
"""develop tests
"""
from
__future__
import
absolute_import
,
unicode_literals
import
os
import
site
import
sys
...
...
@@ -10,7 +8,6 @@ import io
import
subprocess
import
platform
from
setuptools.extern
import
six
from
setuptools.command
import
test
import
pytest
...
...
@@ -97,7 +94,7 @@ class TestDevelop:
with
io
.
open
(
fn
)
as
init_file
:
init
=
init_file
.
read
().
strip
()
expected
=
'print
"foo"'
if
six
.
PY2
else
'print
("foo")'
expected
=
'print("foo")'
assert
init
==
expected
def
test_console_scripts
(
self
,
tmpdir
):
...
...
@@ -163,7 +160,7 @@ class TestNamespaces:
reason
=
"https://github.com/pypa/setuptools/issues/851"
,
)
@
pytest
.
mark
.
skipif
(
platform
.
python_implementation
()
==
'PyPy'
and
not
six
.
PY2
,
platform
.
python_implementation
()
==
'PyPy'
,
reason
=
"https://github.com/pypa/setuptools/issues/1202"
,
)
def
test_namespace_package_importable
(
self
,
tmpdir
):
...
...
setuptools/tests/test_dist.py
View file @
f991fbb3
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
io
import
collections
import
re
import
functools
import
urllib.request
import
urllib.parse
from
distutils.errors
import
DistutilsSetupError
from
setuptools.dist
import
(
_get_unpatched
,
...
...
@@ -14,9 +12,6 @@ from setuptools.dist import (
)
from
setuptools
import
sic
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
.test_easy_install
import
make_nspkg_sdist
...
...
@@ -29,7 +24,8 @@ def test_dist_fetch_build_egg(tmpdir):
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
"""
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
):
dist_dir
=
index
.
mkdir
(
distname
)
...
...
@@ -63,8 +59,7 @@ def test_dist_fetch_build_egg(tmpdir):
dist
.
fetch_build_egg
(
r
)
for
r
in
reqs
]
# noqa below because on Python 2 it causes flakes
assert
[
dist
.
key
for
dist
in
resolved_dists
if
dist
]
==
reqs
# noqa
assert
[
dist
.
key
for
dist
in
resolved_dists
if
dist
]
==
reqs
def
test_dist__get_unpatched_deprecated
():
...
...
@@ -150,10 +145,7 @@ def test_read_metadata(name, attrs):
dist_class
=
metadata_out
.
__class__
# 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
)
...
...
setuptools/tests/test_dist_info.py
View file @
f991fbb3
"""Test .dist-info style distributions.
"""
from
__future__
import
unicode_literals
from
setuptools.extern.six.moves
import
map
import
pytest
import
pkg_resources
...
...
setuptools/tests/test_easy_install.py
View file @
f991fbb3
# -*- coding: utf-8 -*-
"""Easy install Tests
"""
from
__future__
import
absolute_import
,
unicode_literals
import
sys
import
os
...
...
@@ -18,8 +16,6 @@ import mock
import
time
import
re
from
setuptools.extern
import
six
import
pytest
from
setuptools
import
sandbox
...
...
@@ -41,8 +37,6 @@ from . import contexts
from
.files
import
build_files
from
.textwrap
import
DALS
__metaclass__
=
type
class
FakeDist
:
def
get_entry_map
(
self
,
group
):
...
...
@@ -984,8 +978,6 @@ def create_setup_requires_package(path, distname='foobar', version='0.1',
)
class
TestScriptHeader
:
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'
def
test_get_script_header
(
self
):
...
...
setuptools/tests/test_egg_info.py
View file @
f991fbb3
...
...
@@ -10,7 +10,6 @@ from setuptools.command.egg_info import (
egg_info
,
manifest_maker
,
EggInfoDeprecationWarning
,
get_pkg_info_revision
,
)
from
setuptools.dist
import
Distribution
from
setuptools.extern.six.moves
import
map
import
pytest
...
...
@@ -19,8 +18,6 @@ from .files import build_files
from
.textwrap
import
DALS
from
.
import
contexts
__metaclass__
=
type
class
Environment
(
str
):
pass
...
...
@@ -73,8 +70,7 @@ class TestEggInfo:
"""
When the egg_info section is empty or not present, running
save_version_info should add the settings to the setup.cfg
in a deterministic order, consistent with the ordering found
on Python 2.7 with PYTHONHASHSEED=0.
in a deterministic order.
"""
setup_cfg
=
os
.
path
.
join
(
env
.
paths
[
'home'
],
'setup.cfg'
)
dist
=
Distribution
()
...
...
@@ -906,49 +902,3 @@ class TestEggInfo:
def
test_get_pkg_info_revision_deprecated
(
self
):
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 @
f991fbb3
...
...
@@ -3,7 +3,6 @@ import pickle
from
setuptools
import
Distribution
from
setuptools.extern
import
ordered_set
from
setuptools.tests
import
py3_only
def
test_reimport_extern
():
...
...
@@ -17,6 +16,5 @@ def test_orderedset_pickle_roundtrip():
assert
o1
==
o2
@
py3_only
def
test_distribution_picklable
():
pickle
.
loads
(
pickle
.
dumps
(
Distribution
()))
setuptools/tests/test_find_packages.py
View file @
f991fbb3
...
...
@@ -7,12 +7,8 @@ import platform
import
pytest
from
.
import
py3_only
from
setuptools.extern.six
import
PY3
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
...
...
@@ -154,34 +150,29 @@ class TestFindPackages:
def
_assert_packages
(
self
,
actual
,
expected
):
assert
set
(
actual
)
==
set
(
expected
)
@
py3_only
def
test_pep420_ns_package
(
self
):
packages
=
find_namespace_packages
(
self
.
dist_dir
,
include
=
[
'pkg*'
],
exclude
=
[
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
py3_only
def
test_pep420_ns_package_no_includes
(
self
):
packages
=
find_namespace_packages
(
self
.
dist_dir
,
exclude
=
[
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
py3_only
def
test_pep420_ns_package_no_includes_or_excludes
(
self
):
packages
=
find_namespace_packages
(
self
.
dist_dir
)
expected
=
[
'docs'
,
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
,
'pkg.subpkg.assets'
]
self
.
_assert_packages
(
packages
,
expected
)
@
py3_only
def
test_regular_package_with_nested_pep420_ns_packages
(
self
):
self
.
_touch
(
'__init__.py'
,
self
.
pkg_dir
)
packages
=
find_namespace_packages
(
self
.
dist_dir
,
exclude
=
[
'docs'
,
'pkg.subpkg.assets'
])
self
.
_assert_packages
(
packages
,
[
'pkg'
,
'pkg.nspkg'
,
'pkg.subpkg'
])
@
py3_only
def
test_pep420_ns_package_no_non_package_dirs
(
self
):
shutil
.
rmtree
(
self
.
docs_dir
)
shutil
.
rmtree
(
os
.
path
.
join
(
self
.
dist_dir
,
'pkg/subpkg/assets'
))
...
...
setuptools/tests/test_integration.py
View file @
f991fbb3
...
...
@@ -11,8 +11,8 @@ import subprocess
import
functools
import
tarfile
import
zipfile
import
urllib.request
from
setuptools.extern.six.moves
import
urllib
import
pytest
from
setuptools.command.easy_install
import
easy_install
...
...
setuptools/tests/test_manifest.py
View file @
f991fbb3
...
...
@@ -7,18 +7,16 @@ import shutil
import
sys
import
tempfile
import
itertools
import
io
from
distutils
import
log
from
distutils.errors
import
DistutilsTemplateError
from
setuptools.command.egg_info
import
FileList
,
egg_info
,
translate_pattern
from
setuptools.dist
import
Distribution
from
setuptools.extern
import
six
from
setuptools.tests.textwrap
import
DALS
import
pytest
__metaclass__
=
type
def
make_local_path
(
s
):
"""Converts '/' in a string to os.sep"""
...
...
@@ -41,7 +39,7 @@ setup(**%r)
@
contextlib
.
contextmanager
def
quiet
():
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
:
yield
finally
:
...
...
setuptools/tests/test_msvc14.py
View file @
f991fbb3
...
...
@@ -31,8 +31,6 @@ class TestMSVC14:
finally
:
_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
):
import
setuptools.msvc
as
_msvccompiler
...
...
setuptools/tests/test_namespaces.py
View file @
f991fbb3
from
__future__
import
absolute_import
,
unicode_literals
import
sys
import
subprocess
...
...
setuptools/tests/test_packageindex.py
View file @
f991fbb3
from
__future__
import
absolute_import
import
sys
import
os
import
distutils.errors
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
pytest
...
...
@@ -60,7 +59,7 @@ class TestPackageIndex:
)
def
_urlopen
(
*
args
):
raise
http
_
client
.
BadStatusLine
(
'line'
)
raise
http
.
client
.
BadStatusLine
(
'line'
)
index
.
opener
=
_urlopen
url
=
'http://example.com'
...
...
@@ -84,7 +83,7 @@ class TestPackageIndex:
try
:
index
.
open_url
(
url
)
except
distutils
.
errors
.
DistutilsError
as
error
:
msg
=
s
ix
.
text_type
(
error
)
msg
=
s
tr
(
error
)
assert
(
'nonnumeric port'
in
msg
or
'getaddrinfo failed'
in
msg
...
...
setuptools/tests/test_sdist.py
View file @
f991fbb3
# -*- coding: utf-8 -*-
"""sdist tests"""
from
__future__
import
print_function
,
unicode_literals
import
os
import
sys
import
tempfile
...
...
@@ -10,9 +7,6 @@ import unicodedata
import
contextlib
import
io
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
import
pytest
import
pkg_resources
...
...
@@ -21,7 +15,6 @@ from setuptools.command.egg_info import manifest_maker
from
setuptools.dist
import
Distribution
from
setuptools.tests
import
fail_on_ascii
from
.text
import
Filenames
from
.
import
py3_only
SETUP_ATTRS
=
{
...
...
@@ -42,7 +35,7 @@ setup(**%r)
@
contextlib
.
contextmanager
def
quiet
():
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
:
yield
finally
:
...
...
@@ -51,7 +44,7 @@ def quiet():
# Convert to 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'/'
)
else
:
return
path
.
replace
(
os
.
sep
,
'/'
)
...
...
@@ -59,7 +52,7 @@ def posix(path):
# HFS Plus uses decomposed UTF-8
def
decompose
(
path
):
if
isinstance
(
path
,
s
ix
.
text_type
):
if
isinstance
(
path
,
s
tr
):
return
unicodedata
.
normalize
(
'NFD'
,
path
)
try
:
path
=
path
.
decode
(
'utf-8'
)
...
...
@@ -231,7 +224,6 @@ class TestSdistTest:
# The manifest should contain the UTF-8 filename
assert
posix
(
filename
)
in
u_contents
@
py3_only
@
fail_on_ascii
def
test_write_manifest_allows_utf8_filenames
(
self
):
# Test for #303.
...
...
@@ -265,7 +257,6 @@ class TestSdistTest:
# The filelist should have been updated as well
assert
u_filename
in
mm
.
filelist
.
files
@
py3_only
def
test_write_manifest_skips_non_utf8_filenames
(
self
):
"""
Files that cannot be encoded to UTF-8 (specifically, those that
...
...
@@ -329,11 +320,9 @@ class TestSdistTest:
cmd
.
read_manifest
()
# 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
@
py3_only
@
fail_on_latin1_encoded_filenames
def
test_read_manifest_skips_non_utf8_filenames
(
self
):
# Test for #303.
...
...
@@ -383,21 +372,18 @@ class TestSdistTest:
if
sys
.
platform
==
'darwin'
:
filename
=
decompose
(
filename
)
if
not
six
.
PY2
:
fs_enc
=
sys
.
getfilesystemencoding
()
fs_enc
=
sys
.
getfilesystemencoding
()
if
sys
.
platform
==
'win32'
:
if
fs_enc
==
'cp1252'
:
# Python 3 mangles the UTF-8 filename
filename
=
filename
.
decode
(
'cp1252'
)
assert
filename
in
cmd
.
filelist
.
files
else
:
filename
=
filename
.
decode
(
'mbcs'
)
assert
filename
in
cmd
.
filelist
.
files
if
sys
.
platform
==
'win32'
:
if
fs_enc
==
'cp1252'
:
# Python mangles the UTF-8 filename
filename
=
filename
.
decode
(
'cp1252'
)
assert
filename
in
cmd
.
filelist
.
files
else
:
filename
=
filename
.
decode
(
'
utf-8
'
)
filename
=
filename
.
decode
(
'
mbcs
'
)
assert
filename
in
cmd
.
filelist
.
files
else
:
filename
=
filename
.
decode
(
'utf-8'
)
assert
filename
in
cmd
.
filelist
.
files
@
classmethod
...
...
@@ -425,33 +411,20 @@ class TestSdistTest:
with
quiet
():
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
if
sys
.
platform
==
'win32'
:
# Latin-1 is similar to Windows-1252 however
# on mbcs filesys it is not in latin-1 encoding
fs_enc
=
sys
.
getfilesystemencoding
()
if
fs_enc
!=
'mbcs'
:
fs_enc
=
'latin-1'
filename
=
filename
.
decode
(
fs_enc
)
# not all windows systems have a default FS encoding of cp1252
if
sys
.
platform
==
'win32'
:
# Latin-1 is similar to Windows-1252 however
# on mbcs filesys it is not in latin-1 encoding
fs_enc
=
sys
.
getfilesystemencoding
()
if
fs_enc
!=
'mbcs'
:
fs_enc
=
'latin-1'
filename
=
filename
.
decode
(
fs_enc
)
assert
filename
in
cmd
.
filelist
.
files
else
:
# The Latin-1 filename should have been skipped
filename
=
filename
.
decode
(
'latin-1'
)
filename
not
in
cmd
.
filelist
.
files
assert
filename
in
cmd
.
filelist
.
files
else
:
# The Latin-1 filename should have been skipped
filename
=
filename
.
decode
(
'latin-1'
)
filename
not
in
cmd
.
filelist
.
files
def
test_pyproject_toml_in_sdist
(
self
,
tmpdir
):
"""
...
...
setuptools/tests/test_setopt.py
View file @
f991fbb3
# coding: utf-8
from
__future__
import
unicode_literals
import
io
import
six
import
configparser
from
setuptools.command
import
setopt
from
setuptools.extern.six.moves
import
configparser
class
TestEdit
:
...
...
@@ -15,7 +9,7 @@ class TestEdit:
def
parse_config
(
filename
):
parser
=
configparser
.
ConfigParser
()
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
@
staticmethod
...
...
setuptools/tests/test_setuptools.py
View file @
f991fbb3
...
...
@@ -15,7 +15,6 @@ import setuptools
import
setuptools.dist
import
setuptools.depends
as
dep
from
setuptools.depends
import
Require
from
setuptools.extern
import
six
def
makeSetup
(
**
args
):
...
...
@@ -49,7 +48,7 @@ class TestDepends:
x
=
"test"
y
=
z
fc
=
six
.
get_function_code
(
f1
)
fc
=
f1
.
__code__
# unrecognized name
assert
dep
.
extract_constant
(
fc
,
'q'
,
-
1
)
is
None
...
...
setuptools/tests/test_test.py
View file @
f991fbb3
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
mock
from
distutils
import
log
import
os
...
...
@@ -110,7 +106,6 @@ def test_tests_are_run_once(capfd):
with
open
(
'dummy/test_dummy.py'
,
'wt'
)
as
f
:
f
.
write
(
DALS
(
"""
from __future__ import print_function
import unittest
class TestTest(unittest.TestCase):
def test_test(self):
...
...
setuptools/tests/test_virtualenv.py
View file @
f991fbb3
...
...
@@ -12,17 +12,6 @@ from .textwrap import DALS
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
)
def
pytest_virtualenv_works
(
virtualenv
):
"""
...
...
setuptools/tests/test_wheel.py
View file @
f991fbb3
...
...
@@ -25,8 +25,6 @@ from .contexts import tempdir
from
.files
import
build_files
from
.textwrap
import
DALS
__metaclass__
=
type
WHEEL_INFO_TESTS
=
(
(
'invalid.whl'
,
ValueError
),
...
...
setuptools/tests/test_windows_wrappers.py
View file @
f991fbb3
...
...
@@ -12,8 +12,6 @@ the script they are to wrap and with the same name as the script they
are to wrap.
"""
from
__future__
import
absolute_import
import
sys
import
textwrap
import
subprocess
...
...
setuptools/tests/text.py
View file @
f991fbb3
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
class
Filenames
:
unicode
=
'smörbröd.py'
latin_1
=
unicode
.
encode
(
'latin-1'
)
...
...
setuptools/tests/textwrap.py
View file @
f991fbb3
from
__future__
import
absolute_import
import
textwrap
...
...
setuptools/unicode_utils.py
View file @
f991fbb3
import
unicodedata
import
sys
from
setuptools.extern
import
six
# HFS Plus uses decomposed UTF-8
def
decompose
(
path
):
if
isinstance
(
path
,
s
ix
.
text_type
):
if
isinstance
(
path
,
s
tr
):
return
unicodedata
.
normalize
(
'NFD'
,
path
)
try
:
path
=
path
.
decode
(
'utf-8'
)
...
...
@@ -23,7 +21,7 @@ def filesys_decode(path):
NONE when no expected encoding works
"""
if
isinstance
(
path
,
s
ix
.
text_type
):
if
isinstance
(
path
,
s
tr
):
return
path
fs_enc
=
sys
.
getfilesystemencoding
()
or
'utf-8'
...
...
setuptools/wheel.py
View file @
f991fbb3
...
...
@@ -14,13 +14,9 @@ import setuptools
from
pkg_resources
import
parse_version
from
setuptools.extern.packaging.tags
import
sys_tags
from
setuptools.extern.packaging.utils
import
canonicalize_name
from
setuptools.extern.six
import
PY3
from
setuptools.command.egg_info
import
write_requirements
__metaclass__
=
type
WHEEL_NAME
=
re
.
compile
(
r"""^(?P<project_name>.+?)-(?P<version>\
d.*?)
((-(?P<build>\
d.*?))?-(?P<py_
version>.+?)-(?P<abi>.+?)-(?P<platform>.+?)
...
...
@@ -112,7 +108,7 @@ class Wheel:
def _convert_metadata(zf, destination_eggdir, dist_info, egg_info):
def get_metadata(name):
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)
wheel_metadata = get_metadata('WHEEL')
...
...
tools/tox_pip.py
View file @
f991fbb3
...
...
@@ -56,24 +56,12 @@ def test_dependencies():
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
):
os
.
environ
[
'PIP_USE_PEP517'
]
=
'true'
if
is_install_self
(
args
):
remove_setuptools
()
bootstrap
()
sys
.
version_info
>
(
3
,)
or
disable_python_requires
()
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