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
796abd8d
Commit
796abd8d
authored
Jan 08, 2020
by
Hugo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for Python 4: replace unsafe six.PY3 with PY2
parent
7e97def4
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
31 additions
and
31 deletions
+31
-31
setuptools/command/build_ext.py
setuptools/command/build_ext.py
+1
-1
setuptools/command/develop.py
setuptools/command/develop.py
+1
-1
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+1
-1
setuptools/command/egg_info.py
setuptools/command/egg_info.py
+1
-1
setuptools/command/sdist.py
setuptools/command/sdist.py
+1
-1
setuptools/command/test.py
setuptools/command/test.py
+2
-2
setuptools/command/upload_docs.py
setuptools/command/upload_docs.py
+2
-2
setuptools/dist.py
setuptools/dist.py
+3
-3
setuptools/tests/test_develop.py
setuptools/tests/test_develop.py
+2
-2
setuptools/tests/test_sdist.py
setuptools/tests/test_sdist.py
+16
-16
setuptools/tests/test_setopt.py
setuptools/tests/test_setopt.py
+1
-1
No files found.
setuptools/command/build_ext.py
View file @
796abd8d
...
@@ -113,7 +113,7 @@ class build_ext(_build_ext):
...
@@ -113,7 +113,7 @@ class build_ext(_build_ext):
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
=
(
six
.
PY3
not
six
.
PY2
and
getattr
(
ext
,
'py_limited_api'
)
and
getattr
(
ext
,
'py_limited_api'
)
and
get_abi3_suffix
()
and
get_abi3_suffix
()
)
)
...
...
setuptools/command/develop.py
View file @
796abd8d
...
@@ -108,7 +108,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
...
@@ -108,7 +108,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
six
.
PY3
and
getattr
(
self
.
distribution
,
'use_2to3'
,
False
):
if
not
six
.
PY2
and
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 @
796abd8d
...
@@ -1567,7 +1567,7 @@ def get_exe_prefixes(exe_filename):
...
@@ -1567,7 +1567,7 @@ def get_exe_prefixes(exe_filename):
continue
continue
if
parts
[
0
].
upper
()
in
(
'PURELIB'
,
'PLATLIB'
):
if
parts
[
0
].
upper
()
in
(
'PURELIB'
,
'PLATLIB'
):
contents
=
z
.
read
(
name
)
contents
=
z
.
read
(
name
)
if
six
.
PY3
:
if
not
six
.
PY2
:
contents
=
contents
.
decode
()
contents
=
contents
.
decode
()
for
pth
in
yield_lines
(
contents
):
for
pth
in
yield_lines
(
contents
):
pth
=
pth
.
strip
().
replace
(
'
\
\
'
,
'/'
)
pth
=
pth
.
strip
().
replace
(
'
\
\
'
,
'/'
)
...
...
setuptools/command/egg_info.py
View file @
796abd8d
...
@@ -266,7 +266,7 @@ class egg_info(InfoCommon, Command):
...
@@ -266,7 +266,7 @@ 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
six.PY3
:
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
')
...
...
setuptools/command/sdist.py
View file @
796abd8d
...
@@ -207,7 +207,7 @@ class sdist(sdist_add_defaults, orig.sdist):
...
@@ -207,7 +207,7 @@ 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
six
.
PY3
:
if
not
six
.
PY2
:
try
:
try
:
line
=
line
.
decode
(
'UTF-8'
)
line
=
line
.
decode
(
'UTF-8'
)
except
UnicodeDecodeError
:
except
UnicodeDecodeError
:
...
...
setuptools/command/test.py
View file @
796abd8d
...
@@ -129,7 +129,7 @@ class test(Command):
...
@@ -129,7 +129,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
=
six
.
PY3
and
getattr
(
self
.
distribution
,
'use_2to3'
,
False
)
with_2to3
=
not
six
.
PY2
and
getattr
(
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:
...
@@ -240,7 +240,7 @@ class test(Command):
...
@@ -240,7 +240,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
six
.
PY3
and
getattr
(
self
.
distribution
,
'use_2to3'
,
False
):
if
not
six
.
PY2
and
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 @
796abd8d
...
@@ -24,7 +24,7 @@ from .upload import upload
...
@@ -24,7 +24,7 @@ from .upload import upload
def
_encode
(
s
):
def
_encode
(
s
):
errors
=
's
urrogateescape'
if
six
.
PY3
else
'strict
'
errors
=
's
trict'
if
six
.
PY2
else
'surrogateescape
'
return
s
.
encode
(
'utf-8'
,
errors
)
return
s
.
encode
(
'utf-8'
,
errors
)
...
@@ -153,7 +153,7 @@ class upload_docs(upload):
...
@@ -153,7 +153,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
)
if
six
.
PY3
:
if
not
six
.
PY2
:
credentials
=
credentials
.
decode
(
'ascii'
)
credentials
=
credentials
.
decode
(
'ascii'
)
auth
=
"Basic "
+
credentials
auth
=
"Basic "
+
credentials
...
...
setuptools/dist.py
View file @
796abd8d
...
@@ -571,7 +571,7 @@ class Distribution(_Distribution):
...
@@ -571,7 +571,7 @@ class Distribution(_Distribution):
from
setuptools.extern.six.moves.configparser
import
ConfigParser
from
setuptools.extern.six.moves.configparser
import
ConfigParser
# Ignore install directory options if we have a venv
# Ignore install directory options if we have a venv
if
six
.
PY3
and
sys
.
prefix
!=
sys
.
base_prefix
:
if
not
six
.
PY2
and
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'
,
...
@@ -593,7 +593,7 @@ class Distribution(_Distribution):
...
@@ -593,7 +593,7 @@ 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
.
read
_file
if
six
.
PY3
else
parser
.
readfp
)(
reader
)
(
parser
.
read
fp
if
six
.
PY2
else
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
)
...
@@ -636,7 +636,7 @@ class Distribution(_Distribution):
...
@@ -636,7 +636,7 @@ class Distribution(_Distribution):
Ref #1653
Ref #1653
"""
"""
if
six
.
PY3
:
if
not
six
.
PY2
:
return
val
return
val
try
:
try
:
return
val
.
encode
()
return
val
.
encode
()
...
...
setuptools/tests/test_develop.py
View file @
796abd8d
...
@@ -95,7 +95,7 @@ class TestDevelop:
...
@@ -95,7 +95,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
.
PY3
else
'print "foo"
'
expected
=
'print
"foo"'
if
six
.
PY2
else
'print("foo")
'
assert
init
==
expected
assert
init
==
expected
def
test_console_scripts
(
self
,
tmpdir
):
def
test_console_scripts
(
self
,
tmpdir
):
...
@@ -161,7 +161,7 @@ class TestNamespaces:
...
@@ -161,7 +161,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
six
.
PY3
,
platform
.
python_implementation
()
==
'PyPy'
and
not
six
.
PY2
,
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_sdist.py
View file @
796abd8d
...
@@ -51,7 +51,7 @@ def quiet():
...
@@ -51,7 +51,7 @@ def quiet():
# Convert to POSIX path
# Convert to POSIX path
def
posix
(
path
):
def
posix
(
path
):
if
six
.
PY3
and
not
isinstance
(
path
,
str
):
if
not
six
.
PY2
and
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
,
'/'
)
...
@@ -329,7 +329,7 @@ class TestSdistTest:
...
@@ -329,7 +329,7 @@ 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
six
.
PY3
:
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
...
@@ -383,7 +383,7 @@ class TestSdistTest:
...
@@ -383,7 +383,7 @@ class TestSdistTest:
if
sys
.
platform
==
'darwin'
:
if
sys
.
platform
==
'darwin'
:
filename
=
decompose
(
filename
)
filename
=
decompose
(
filename
)
if
six
.
PY3
:
if
not
six
.
PY2
:
fs_enc
=
sys
.
getfilesystemencoding
()
fs_enc
=
sys
.
getfilesystemencoding
()
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
...
@@ -425,7 +425,19 @@ class TestSdistTest:
...
@@ -425,7 +425,19 @@ class TestSdistTest:
with
quiet
():
with
quiet
():
cmd
.
run
()
cmd
.
run
()
if
six
.
PY3
:
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
...
@@ -440,18 +452,6 @@ class TestSdistTest:
...
@@ -440,18 +452,6 @@ class TestSdistTest:
# The Latin-1 filename should have been skipped
# The Latin-1 filename should have been skipped
filename
=
filename
.
decode
(
'latin-1'
)
filename
=
filename
.
decode
(
'latin-1'
)
filename
not
in
cmd
.
filelist
.
files
filename
not
in
cmd
.
filelist
.
files
else
:
# 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
def
test_pyproject_toml_in_sdist
(
self
,
tmpdir
):
def
test_pyproject_toml_in_sdist
(
self
,
tmpdir
):
"""
"""
...
...
setuptools/tests/test_setopt.py
View file @
796abd8d
...
@@ -15,7 +15,7 @@ class TestEdit:
...
@@ -15,7 +15,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
.
read
_file
if
six
.
PY3
else
parser
.
readfp
)(
reader
)
(
parser
.
read
fp
if
six
.
PY2
else
parser
.
read_file
)(
reader
)
return
parser
return
parser
@
staticmethod
@
staticmethod
...
...
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