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
87be56f3
Commit
87be56f3
authored
Mar 18, 2018
by
Jason R. Coombs
Committed by
GitHub
Mar 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1300 from pganssle/fix_unicode_maintainer
Fix unicode maintainer
parents
a6e5aa4e
eb6502d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
21 deletions
+48
-21
setuptools/dist.py
setuptools/dist.py
+11
-4
setuptools/tests/test_dist.py
setuptools/tests/test_dist.py
+37
-17
No files found.
setuptools/dist.py
View file @
87be56f3
# -*- coding: utf-8 -*-
__all__
=
[
'Distribution'
]
__all__
=
[
'Distribution'
]
import
re
import
re
...
@@ -35,10 +36,13 @@ def _get_unpatched(cls):
...
@@ -35,10 +36,13 @@ def _get_unpatched(cls):
warnings
.
warn
(
"Do not call this function"
,
DeprecationWarning
)
warnings
.
warn
(
"Do not call this function"
,
DeprecationWarning
)
return
get_unpatched
(
cls
)
return
get_unpatched
(
cls
)
def
get_metadata_version
(
dist_md
):
def
get_metadata_version
(
dist_md
):
if
dist_md
.
long_description_content_type
or
dist_md
.
provides_extras
:
if
dist_md
.
long_description_content_type
or
dist_md
.
provides_extras
:
return
StrictVersion
(
'2.1'
)
return
StrictVersion
(
'2.1'
)
elif
getattr
(
dist_md
,
'python_requires'
,
None
)
is
not
None
:
elif
(
dist_md
.
maintainer
is
not
None
or
dist_md
.
maintainer_email
is
not
None
or
getattr
(
dist_md
,
'python_requires'
,
None
)
is
not
None
):
return
StrictVersion
(
'1.2'
)
return
StrictVersion
(
'1.2'
)
elif
(
dist_md
.
provides
or
dist_md
.
requires
or
dist_md
.
obsoletes
or
elif
(
dist_md
.
provides
or
dist_md
.
requires
or
dist_md
.
obsoletes
or
dist_md
.
classifiers
or
dist_md
.
download_url
):
dist_md
.
classifiers
or
dist_md
.
download_url
):
...
@@ -59,7 +63,7 @@ def write_pkg_file(self, file):
...
@@ -59,7 +63,7 @@ def write_pkg_file(self, file):
file
.
write
(
'Summary: %s
\
n
'
%
self
.
get_description
())
file
.
write
(
'Summary: %s
\
n
'
%
self
.
get_description
())
file
.
write
(
'Home-page: %s
\
n
'
%
self
.
get_url
())
file
.
write
(
'Home-page: %s
\
n
'
%
self
.
get_url
())
if
version
==
'1.2'
:
if
version
<
StrictVersion
(
'1.2'
)
:
file
.
write
(
'Author: %s
\
n
'
%
self
.
get_contact
())
file
.
write
(
'Author: %s
\
n
'
%
self
.
get_contact
())
file
.
write
(
'Author-email: %s
\
n
'
%
self
.
get_contact_email
())
file
.
write
(
'Author-email: %s
\
n
'
%
self
.
get_contact_email
())
else
:
else
:
...
@@ -72,6 +76,9 @@ def write_pkg_file(self, file):
...
@@ -72,6 +76,9 @@ def write_pkg_file(self, file):
for
field
,
attr
in
optional_fields
:
for
field
,
attr
in
optional_fields
:
attr_val
=
getattr
(
self
,
attr
)
attr_val
=
getattr
(
self
,
attr
)
if
six
.
PY2
:
attr_val
=
self
.
_encode_field
(
attr_val
)
if
attr_val
is
not
None
:
if
attr_val
is
not
None
:
file
.
write
(
'%s: %s
\
n
'
%
(
field
,
attr_val
))
file
.
write
(
'%s: %s
\
n
'
%
(
field
,
attr_val
))
...
@@ -88,7 +95,7 @@ def write_pkg_file(self, file):
...
@@ -88,7 +95,7 @@ def write_pkg_file(self, file):
if
keywords
:
if
keywords
:
file
.
write
(
'Keywords: %s
\
n
'
%
keywords
)
file
.
write
(
'Keywords: %s
\
n
'
%
keywords
)
if
version
==
'1.2'
:
if
version
>=
StrictVersion
(
'1.2'
)
:
for
platform
in
self
.
get_platforms
():
for
platform
in
self
.
get_platforms
():
file
.
write
(
'Platform: %s
\
n
'
%
platform
)
file
.
write
(
'Platform: %s
\
n
'
%
platform
)
else
:
else
:
...
@@ -556,7 +563,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
...
@@ -556,7 +563,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
# don't use any other settings
# don't use any other settings
'find_links'
,
'site_dirs'
,
'index_url'
,
'find_links'
,
'site_dirs'
,
'index_url'
,
'optimize'
,
'site_dirs'
,
'allow_hosts'
,
'optimize'
,
'site_dirs'
,
'allow_hosts'
,
))
))
if
self
.
dependency_links
:
if
self
.
dependency_links
:
links
=
self
.
dependency_links
[:]
links
=
self
.
dependency_links
[:]
if
'find_links'
in
opts
:
if
'find_links'
in
opts
:
...
...
setuptools/tests/test_dist.py
View file @
87be56f3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
io
from
setuptools
import
Distribution
from
setuptools
import
Distribution
from
setuptools.extern.six.moves.urllib.request
import
pathname2url
from
setuptools.extern.six.moves.urllib.request
import
pathname2url
from
setuptools.extern.six.moves.urllib_parse
import
urljoin
from
setuptools.extern.six.moves.urllib_parse
import
urljoin
from
setuptools.extern.six
import
StringIO
from
.textwrap
import
DALS
from
.textwrap
import
DALS
from
.test_easy_install
import
make_nspkg_sdist
from
.test_easy_install
import
make_nspkg_sdist
import
pytest
import
pytest
def
test_dist_fetch_build_egg
(
tmpdir
):
def
test_dist_fetch_build_egg
(
tmpdir
):
"""
"""
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
"""
"""
index
=
tmpdir
.
mkdir
(
'index'
)
index
=
tmpdir
.
mkdir
(
'index'
)
index_url
=
urljoin
(
'file://'
,
pathname2url
(
str
(
index
)))
index_url
=
urljoin
(
'file://'
,
pathname2url
(
str
(
index
)))
def
sdist_with_index
(
distname
,
version
):
def
sdist_with_index
(
distname
,
version
):
dist_dir
=
index
.
mkdir
(
distname
)
dist_dir
=
index
.
mkdir
(
distname
)
dist_sdist
=
'%s-%s.tar.gz'
%
(
distname
,
version
)
dist_sdist
=
'%s-%s.tar.gz'
%
(
distname
,
version
)
...
@@ -63,37 +69,47 @@ def __maintainer_test_cases():
...
@@ -63,37 +69,47 @@ def __maintainer_test_cases():
test_cases
=
[
test_cases
=
[
(
'No author, no maintainer'
,
attrs
.
copy
()),
(
'No author, no maintainer'
,
attrs
.
copy
()),
(
'Author (no e-mail), no maintainer'
,
merge_dicts
(
attrs
,
(
'Author (no e-mail), no maintainer'
,
merge_dicts
(
attrs
,
{
'author'
:
'Author Name'
})),
{
'author'
:
'Author Name'
})),
(
'Author (e-mail), no maintainer'
,
merge_dicts
(
attrs
,
(
'Author (e-mail), no maintainer'
,
merge_dicts
(
attrs
,
{
'author'
:
'Author Name'
,
{
'author'
:
'Author Name'
,
'author_email'
:
'author@name.com'
})),
'author_email'
:
'author@name.com'
})),
(
'No author, maintainer (no e-mail)'
,
merge_dicts
(
attrs
,
(
'No author, maintainer (no e-mail)'
,
merge_dicts
(
attrs
,
{
'maintainer'
:
'Maintainer Name'
})),
{
'maintainer'
:
'Maintainer Name'
})),
(
'No author, maintainer (e-mail)'
,
merge_dicts
(
attrs
,
(
'No author, maintainer (e-mail)'
,
merge_dicts
(
attrs
,
{
'maintainer'
:
'Maintainer Name'
,
{
'maintainer'
:
'Maintainer Name'
,
'maintainer_email'
:
'maintainer@name.com'
})),
'maintainer_email'
:
'maintainer@name.com'
})),
(
'Author (no e-mail), Maintainer (no-email)'
,
merge_dicts
(
attrs
,
(
'Author (no e-mail), Maintainer (no-email)'
,
merge_dicts
(
attrs
,
{
'author'
:
'Author Name'
,
{
'author'
:
'Author Name'
,
'maintainer'
:
'Maintainer Name'
})),
'maintainer'
:
'Maintainer Name'
})),
(
'Author (e-mail), Maintainer (e-mail)'
,
merge_dicts
(
attrs
,
(
'Author (e-mail), Maintainer (e-mail)'
,
merge_dicts
(
attrs
,
{
'author'
:
'Author Name'
,
{
'author'
:
'Author Name'
,
'author_email'
:
'author@name.com'
,
'author_email'
:
'author@name.com'
,
'maintainer'
:
'Maintainer Name'
,
'maintainer'
:
'Maintainer Name'
,
'maintainer_email'
:
'maintainer@name.com'
})),
'maintainer_email'
:
'maintainer@name.com'
})),
(
'No author (e-mail), no maintainer (e-mail)'
,
merge_dicts
(
attrs
,
(
'No author (e-mail), no maintainer (e-mail)'
,
merge_dicts
(
attrs
,
{
'author_email'
:
'author@name.com'
,
{
'author_email'
:
'author@name.com'
,
'maintainer_email'
:
'maintainer@name.com'
})),
'maintainer_email'
:
'maintainer@name.com'
})),
(
'Author unicode'
,
merge_dicts
(
attrs
,
(
'Author unicode'
,
merge_dicts
(
attrs
,
{
'author'
:
'鉄沢寛'
})),
{
'author'
:
'鉄沢寛'
})),
(
'Maintainer unicode'
,
merge_dicts
(
attrs
,
(
'Maintainer unicode'
,
merge_dicts
(
attrs
,
{
'maintainer'
:
'Jan Łukasiewicz'
})),
{
'maintainer'
:
'Jan Łukasiewicz'
})),
]
]
return
test_cases
return
test_cases
@
pytest
.
mark
.
parametrize
(
'name,attrs'
,
__maintainer_test_cases
())
@
pytest
.
mark
.
parametrize
(
'name,attrs'
,
__maintainer_test_cases
())
def
test_maintainer_author
(
name
,
attrs
):
def
test_maintainer_author
(
name
,
attrs
,
tmpdir
):
tested_keys
=
{
tested_keys
=
{
'author'
:
'Author'
,
'author'
:
'Author'
,
'author_email'
:
'Author-email'
,
'author_email'
:
'Author-email'
,
...
@@ -103,12 +119,17 @@ def test_maintainer_author(name, attrs):
...
@@ -103,12 +119,17 @@ def test_maintainer_author(name, attrs):
# Generate a PKG-INFO file
# Generate a PKG-INFO file
dist
=
Distribution
(
attrs
)
dist
=
Distribution
(
attrs
)
PKG_INFO
=
StringIO
()
fn
=
tmpdir
.
mkdir
(
'pkg_info'
)
dist
.
metadata
.
write_pkg_file
(
PKG_INFO
)
fn_s
=
str
(
fn
)
PKG_INFO
.
seek
(
0
)
dist
.
metadata
.
write_pkg_info
(
fn_s
)
with
io
.
open
(
str
(
fn
.
join
(
'PKG-INFO'
)),
'r'
,
encoding
=
'utf-8'
)
as
f
:
raw_pkg_lines
=
f
.
readlines
()
# Drop blank lines
pkg_lines
=
list
(
filter
(
None
,
raw_pkg_lines
))
pkg_lines
=
PKG_INFO
.
readlines
()
pkg_lines
=
[
_
for
_
in
pkg_lines
if
_
]
# Drop blank lines
pkg_lines_set
=
set
(
pkg_lines
)
pkg_lines_set
=
set
(
pkg_lines
)
# Duplicate lines should not be generated
# Duplicate lines should not be generated
...
@@ -122,4 +143,3 @@ def test_maintainer_author(name, attrs):
...
@@ -122,4 +143,3 @@ def test_maintainer_author(name, attrs):
else
:
else
:
line
=
'%s: %s'
%
(
fkey
,
val
)
line
=
'%s: %s'
%
(
fkey
,
val
)
assert
line
in
pkg_lines_set
assert
line
in
pkg_lines_set
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