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
f5c04b1b
Commit
f5c04b1b
authored
Dec 31, 2018
by
Paul Ganssle
Committed by
GitHub
Dec 31, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1559 from RajdeepRao/BUG-1551
Disallow files for license inputs
parents
0c9624fd
3db95bcc
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
6 deletions
+75
-6
changelog.d/1551.breaking.rst
changelog.d/1551.breaking.rst
+1
-0
docs/setuptools.txt
docs/setuptools.txt
+1
-1
setup.cfg
setup.cfg
+0
-1
setuptools/config.py
setuptools/config.py
+20
-2
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+20
-0
setuptools/tests/test_egg_info.py
setuptools/tests/test_egg_info.py
+33
-2
No files found.
changelog.d/1551.breaking.rst
0 → 100644
View file @
f5c04b1b
File inputs for the `license` field in `setup.cfg` files now explicitly raise an error.
docs/setuptools.txt
View file @
f5c04b1b
...
...
@@ -2370,7 +2370,7 @@ author_email author-email str
maintainer str
maintainer_email maintainer-email str
classifiers classifier file:, list-comma
license
file:,
str
license str
description summary file:, str
long_description long-description file:, str
long_description_content_type str 38.6.0
...
...
setup.cfg
View file @
f5c04b1b
...
...
@@ -26,4 +26,3 @@ universal = 1
license_file = LICENSE
[bumpversion:file:setup.py]
setuptools/config.py
View file @
f5c04b1b
...
...
@@ -246,6 +246,24 @@ class ConfigHandler:
value
=
value
.
lower
()
return
value
in
(
'1'
,
'true'
,
'yes'
)
@
classmethod
def
_exclude_files_parser
(
cls
,
key
):
"""Returns a parser function to make sure field inputs
are not files.
Parses a value after getting the key so error messages are
more informative.
:param key:
:rtype: callable
"""
def
parser
(
value
):
exclude_directive
=
'file:'
if
value
.
startswith
(
exclude_directive
):
raise
ValueError
(
'Only strings are accepted for the {0} field, files are not accepted'
.
format
(
key
))
return
value
return
parser
@
classmethod
def
_parse_file
(
cls
,
value
):
"""Represents value as a string, allowing including text
...
...
@@ -255,7 +273,6 @@ class ConfigHandler:
directory with setup.py.
Examples:
file: LICENSE
file: README.rst, CHANGELOG.md, src/file.txt
:param str value:
...
...
@@ -449,6 +466,7 @@ class ConfigMetadataHandler(ConfigHandler):
parse_list
=
self
.
_parse_list
parse_file
=
self
.
_parse_file
parse_dict
=
self
.
_parse_dict
exclude_files_parser
=
self
.
_exclude_files_parser
return
{
'platforms'
:
parse_list
,
...
...
@@ -460,7 +478,7 @@ class ConfigMetadataHandler(ConfigHandler):
DeprecationWarning
),
'obsoletes'
:
parse_list
,
'classifiers'
:
self
.
_get_parser_compound
(
parse_file
,
parse_list
),
'license'
:
parse_file
,
'license'
:
exclude_files_parser
(
'license'
)
,
'description'
:
parse_file
,
'long_description'
:
parse_file
,
'version'
:
self
.
_parse_version
,
...
...
setuptools/tests/test_config.py
View file @
f5c04b1b
import
contextlib
import
pytest
from
distutils.errors
import
DistutilsOptionError
,
DistutilsFileError
from
mock
import
patch
from
setuptools.dist
import
Distribution
,
_Distribution
from
setuptools.config
import
ConfigHandler
,
read_configuration
from
.
import
py2_only
,
py3_only
from
.textwrap
import
DALS
class
ErrConfigHandler
(
ConfigHandler
):
"""Erroneous handler. Fails to implement required methods."""
...
...
@@ -146,6 +148,24 @@ class TestMetadata:
assert
metadata
.
download_url
==
'http://test.test.com/test/'
assert
metadata
.
maintainer_email
==
'test@test.com'
def
test_license_cfg
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
DALS
(
"""
[metadata]
name=foo
version=0.0.1
license=Apache 2.0
"""
)
)
with
get_dist
(
tmpdir
)
as
dist
:
metadata
=
dist
.
metadata
assert
metadata
.
name
==
"foo"
assert
metadata
.
version
==
"0.0.1"
assert
metadata
.
license
==
"Apache 2.0"
def
test_file_mixed
(
self
,
tmpdir
):
fake_env
(
...
...
setuptools/tests/test_egg_info.py
View file @
f5c04b1b
...
...
@@ -148,6 +148,37 @@ class TestEggInfo:
]
assert
sorted
(
actual
)
==
expected
def
test_license_is_a_string
(
self
,
tmpdir_cwd
,
env
):
setup_config
=
DALS
(
"""
[metadata]
name=foo
version=0.0.1
license=file:MIT
"""
)
setup_script
=
DALS
(
"""
from setuptools import setup
setup()
"""
)
build_files
({
'setup.py'
:
setup_script
,
'setup.cfg'
:
setup_config
})
# This command should fail with a ValueError, but because it's
# currently configured to use a subprocess, the actual traceback
# object is lost and we need to parse it from stderr
with
pytest
.
raises
(
AssertionError
)
as
exc
:
self
.
_run_egg_info_command
(
tmpdir_cwd
,
env
)
# Hopefully this is not too fragile: the only argument to the
# assertion error should be a traceback, ending with:
# ValueError: ....
#
# assert not 1
tb
=
exc
.
value
.
args
[
0
].
split
(
'
\
n
'
)
assert
tb
[
-
3
].
lstrip
().
startswith
(
'ValueError'
)
def
test_rebuilt
(
self
,
tmpdir_cwd
,
env
):
"""Ensure timestamps are updated when the command is re-run."""
self
.
_create_project
()
...
...
@@ -597,8 +628,8 @@ class TestEggInfo:
data_stream
=
1
,
env
=
environ
,
)
if
code
:
raise
AssertionError
(
data
)
assert
not
code
,
data
if
output
:
assert
output
in
data
...
...
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