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
21333fe8
Commit
21333fe8
authored
Dec 04, 2016
by
idle sign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `metadata` section aliases.
parent
68c03bee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
setuptools/config.py
setuptools/config.py
+20
-2
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+25
-0
No files found.
setuptools/config.py
View file @
21333fe8
...
...
@@ -18,6 +18,12 @@ class ConfigHandler(object):
"""
aliases
=
{}
"""Options aliases.
For compatibility with various packages. E.g.: d2to1 and pbr.
"""
strict_mode
=
True
"""Flag. Whether unknown options in config should
raise DistutilsOptionError exception, or pass silently.
...
...
@@ -48,6 +54,9 @@ class ConfigHandler(object):
unknown
=
tuple
()
target_obj
=
self
.
target_obj
# Translate alias into real name.
option_name
=
self
.
aliases
.
get
(
option_name
,
option_name
)
current_value
=
getattr
(
target_obj
,
option_name
,
unknown
)
if
current_value
is
unknown
:
...
...
@@ -216,9 +225,18 @@ class ConfigHandler(object):
class
ConfigMetadataHandler
(
ConfigHandler
):
section_prefix
=
'metadata'
aliases
=
{
'author-email'
:
'author_email'
,
'home_page'
:
'url'
,
'summary'
:
'description'
,
'classifier'
:
'classifiers'
,
'platform'
:
'platforms'
,
}
strict_mode
=
False
"""We need to keep it loose, to be
compatible with `pbr` package
which also uses `metadata` section.
"""We need to keep it loose, to be
partially compatible with
`pbr` and `d2to1` packages
which also uses `metadata` section.
"""
...
...
setuptools/tests/test_config.py
View file @
21333fe8
...
...
@@ -86,6 +86,31 @@ class TestMetadata:
assert
metadata
.
name
==
'fake_name'
assert
metadata
.
keywords
==
[
'one'
,
'two'
]
def
test_aliases
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
'[metadata]
\
n
'
'author-email = test@test.com
\
n
'
'home_page = http://test.test.com/test/
\
n
'
'summary = Short summary
\
n
'
'platform = a, b
\
n
'
'classifier =
\
n
'
' Framework :: Django
\
n
'
' Programming Language :: Python :: 3.5
\
n
'
)
with
get_dist
(
tmpdir
)
as
dist
:
metadata
=
dist
.
metadata
assert
metadata
.
author_email
==
'test@test.com'
assert
metadata
.
url
==
'http://test.test.com/test/'
assert
metadata
.
description
==
'Short summary'
assert
metadata
.
platforms
==
[
'a'
,
'b'
]
assert
metadata
.
classifiers
==
[
'Framework :: Django'
,
'Programming Language :: Python :: 3.5'
,
]
def
test_multiline
(
self
,
tmpdir
):
fake_env
(
...
...
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