Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1d7deafe
Commit
1d7deafe
authored
Sep 12, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Plain Diff
Branch merge
parents
b77c6c65
647ef8cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
56 deletions
+72
-56
Lib/distutils/dist.py
Lib/distutils/dist.py
+2
-1
Lib/distutils/tests/test_dist.py
Lib/distutils/tests/test_dist.py
+61
-51
Lib/pydoc.py
Lib/pydoc.py
+5
-4
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/distutils/dist.py
View file @
1d7deafe
...
@@ -1018,7 +1018,8 @@ class DistributionMetadata:
...
@@ -1018,7 +1018,8 @@ class DistributionMetadata:
"""Write the PKG-INFO format data to a file object.
"""Write the PKG-INFO format data to a file object.
"""
"""
version
=
'1.0'
version
=
'1.0'
if
self
.
provides
or
self
.
requires
or
self
.
obsoletes
:
if
(
self
.
provides
or
self
.
requires
or
self
.
obsoletes
or
self
.
classifiers
or
self
.
download_url
):
version
=
'1.1'
version
=
'1.1'
file
.
write
(
'Metadata-Version: %s
\
n
'
%
version
)
file
.
write
(
'Metadata-Version: %s
\
n
'
%
version
)
...
...
Lib/distutils/tests/test_dist.py
View file @
1d7deafe
...
@@ -74,7 +74,7 @@ class DistributionTestCase(support.LoggingSilencer,
...
@@ -74,7 +74,7 @@ class DistributionTestCase(support.LoggingSilencer,
self
.
assertEqual
(
d
.
get_command_packages
(),
self
.
assertEqual
(
d
.
get_command_packages
(),
[
"distutils.command"
,
"foo.bar"
,
"distutils.tests"
])
[
"distutils.command"
,
"foo.bar"
,
"distutils.tests"
])
cmd
=
d
.
get_command_obj
(
"test_dist"
)
cmd
=
d
.
get_command_obj
(
"test_dist"
)
self
.
assert
True
(
isinstance
(
cmd
,
test_dist
)
)
self
.
assert
IsInstance
(
cmd
,
test_dist
)
self
.
assertEqual
(
cmd
.
sample_option
,
"sometext"
)
self
.
assertEqual
(
cmd
.
sample_option
,
"sometext"
)
def
test_command_packages_configfile
(
self
):
def
test_command_packages_configfile
(
self
):
...
@@ -106,28 +106,23 @@ class DistributionTestCase(support.LoggingSilencer,
...
@@ -106,28 +106,23 @@ class DistributionTestCase(support.LoggingSilencer,
def
test_empty_options
(
self
):
def
test_empty_options
(
self
):
# an empty options dictionary should not stay in the
# an empty options dictionary should not stay in the
# list of attributes
# list of attributes
klass
=
Distribution
# catching warnings
# catching warnings
warns
=
[]
warns
=
[]
def
_warn
(
msg
):
def
_warn
(
msg
):
warns
.
append
(
msg
)
warns
.
append
(
msg
)
old_warn
=
warnings
.
warn
self
.
addCleanup
(
setattr
,
warnings
,
'warn'
,
warnings
.
warn
)
warnings
.
warn
=
_warn
warnings
.
warn
=
_warn
try
:
dist
=
Distribution
(
attrs
=
{
'author'
:
'xxx'
,
'name'
:
'xxx'
,
dist
=
klass
(
attrs
=
{
'author'
:
'xxx'
,
'version'
:
'xxx'
,
'url'
:
'xxxx'
,
'name'
:
'xxx'
,
'options'
:
{}})
'version'
:
'xxx'
,
'url'
:
'xxxx'
,
'options'
:
{}})
finally
:
warnings
.
warn
=
old_warn
self
.
assertEqual
(
len
(
warns
),
0
)
self
.
assertEqual
(
len
(
warns
),
0
)
self
.
assertNotIn
(
'options'
,
dir
(
dist
))
def
test_finalize_options
(
self
):
def
test_finalize_options
(
self
):
attrs
=
{
'keywords'
:
'one,two'
,
attrs
=
{
'keywords'
:
'one,two'
,
'platforms'
:
'one,two'
}
'platforms'
:
'one,two'
}
...
@@ -150,7 +145,6 @@ class DistributionTestCase(support.LoggingSilencer,
...
@@ -150,7 +145,6 @@ class DistributionTestCase(support.LoggingSilencer,
cmds
=
dist
.
get_command_packages
()
cmds
=
dist
.
get_command_packages
()
self
.
assertEqual
(
cmds
,
[
'distutils.command'
,
'one'
,
'two'
])
self
.
assertEqual
(
cmds
,
[
'distutils.command'
,
'one'
,
'two'
])
def
test_announce
(
self
):
def
test_announce
(
self
):
# make sure the level is known
# make sure the level is known
dist
=
Distribution
()
dist
=
Distribution
()
...
@@ -158,6 +152,7 @@ class DistributionTestCase(support.LoggingSilencer,
...
@@ -158,6 +152,7 @@ class DistributionTestCase(support.LoggingSilencer,
kwargs
=
{
'level'
:
'ok2'
}
kwargs
=
{
'level'
:
'ok2'
}
self
.
assertRaises
(
ValueError
,
dist
.
announce
,
args
,
kwargs
)
self
.
assertRaises
(
ValueError
,
dist
.
announce
,
args
,
kwargs
)
class
MetadataTestCase
(
support
.
TempdirManager
,
support
.
EnvironGuard
,
class
MetadataTestCase
(
support
.
TempdirManager
,
support
.
EnvironGuard
,
unittest
.
TestCase
):
unittest
.
TestCase
):
...
@@ -170,15 +165,20 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -170,15 +165,20 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
sys
.
argv
[:]
=
self
.
argv
[
1
]
sys
.
argv
[:]
=
self
.
argv
[
1
]
super
(
MetadataTestCase
,
self
).
tearDown
()
super
(
MetadataTestCase
,
self
).
tearDown
()
def
format_metadata
(
self
,
dist
):
sio
=
io
.
StringIO
()
dist
.
metadata
.
write_pkg_file
(
sio
)
return
sio
.
getvalue
()
def
test_simple_metadata
(
self
):
def
test_simple_metadata
(
self
):
attrs
=
{
"name"
:
"package"
,
attrs
=
{
"name"
:
"package"
,
"version"
:
"1.0"
}
"version"
:
"1.0"
}
dist
=
Distribution
(
attrs
)
dist
=
Distribution
(
attrs
)
meta
=
self
.
format_metadata
(
dist
)
meta
=
self
.
format_metadata
(
dist
)
self
.
assert
True
(
"Metadata-Version: 1.0"
in
meta
)
self
.
assert
In
(
"Metadata-Version: 1.0"
,
meta
)
self
.
assert
True
(
"provides:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"provides:"
,
meta
.
lower
())
self
.
assert
True
(
"requires:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"requires:"
,
meta
.
lower
())
self
.
assert
True
(
"obsoletes:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"obsoletes:"
,
meta
.
lower
())
def
test_provides
(
self
):
def
test_provides
(
self
):
attrs
=
{
"name"
:
"package"
,
attrs
=
{
"name"
:
"package"
,
...
@@ -190,9 +190,9 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -190,9 +190,9 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
self
.
assertEqual
(
dist
.
get_provides
(),
self
.
assertEqual
(
dist
.
get_provides
(),
[
"package"
,
"package.sub"
])
[
"package"
,
"package.sub"
])
meta
=
self
.
format_metadata
(
dist
)
meta
=
self
.
format_metadata
(
dist
)
self
.
assert
True
(
"Metadata-Version: 1.1"
in
meta
)
self
.
assert
In
(
"Metadata-Version: 1.1"
,
meta
)
self
.
assert
True
(
"requires:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"requires:"
,
meta
.
lower
())
self
.
assert
True
(
"obsoletes:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"obsoletes:"
,
meta
.
lower
())
def
test_provides_illegal
(
self
):
def
test_provides_illegal
(
self
):
self
.
assertRaises
(
ValueError
,
Distribution
,
self
.
assertRaises
(
ValueError
,
Distribution
,
...
@@ -210,11 +210,11 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -210,11 +210,11 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
self
.
assertEqual
(
dist
.
get_requires
(),
self
.
assertEqual
(
dist
.
get_requires
(),
[
"other"
,
"another (==1.0)"
])
[
"other"
,
"another (==1.0)"
])
meta
=
self
.
format_metadata
(
dist
)
meta
=
self
.
format_metadata
(
dist
)
self
.
assert
True
(
"Metadata-Version: 1.1"
in
meta
)
self
.
assert
In
(
"Metadata-Version: 1.1"
,
meta
)
self
.
assert
True
(
"provides:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"provides:"
,
meta
.
lower
())
self
.
assert
True
(
"Requires: other"
in
meta
)
self
.
assert
In
(
"Requires: other"
,
meta
)
self
.
assert
True
(
"Requires: another (==1.0)"
in
meta
)
self
.
assert
In
(
"Requires: another (==1.0)"
,
meta
)
self
.
assert
True
(
"obsoletes:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"obsoletes:"
,
meta
.
lower
())
def
test_requires_illegal
(
self
):
def
test_requires_illegal
(
self
):
self
.
assertRaises
(
ValueError
,
Distribution
,
self
.
assertRaises
(
ValueError
,
Distribution
,
...
@@ -232,11 +232,11 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -232,11 +232,11 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
self
.
assertEqual
(
dist
.
get_obsoletes
(),
self
.
assertEqual
(
dist
.
get_obsoletes
(),
[
"other"
,
"another (<1.0)"
])
[
"other"
,
"another (<1.0)"
])
meta
=
self
.
format_metadata
(
dist
)
meta
=
self
.
format_metadata
(
dist
)
self
.
assert
True
(
"Metadata-Version: 1.1"
in
meta
)
self
.
assert
In
(
"Metadata-Version: 1.1"
,
meta
)
self
.
assert
True
(
"provides:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"provides:"
,
meta
.
lower
())
self
.
assert
True
(
"requires:"
not
in
meta
.
lower
())
self
.
assert
NotIn
(
"requires:"
,
meta
.
lower
())
self
.
assert
True
(
"Obsoletes: other"
in
meta
)
self
.
assert
In
(
"Obsoletes: other"
,
meta
)
self
.
assert
True
(
"Obsoletes: another (<1.0)"
in
meta
)
self
.
assert
In
(
"Obsoletes: another (<1.0)"
,
meta
)
def
test_obsoletes_illegal
(
self
):
def
test_obsoletes_illegal
(
self
):
self
.
assertRaises
(
ValueError
,
Distribution
,
self
.
assertRaises
(
ValueError
,
Distribution
,
...
@@ -244,10 +244,34 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -244,10 +244,34 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
"version"
:
"1.0"
,
"version"
:
"1.0"
,
"obsoletes"
:
[
"my.pkg (splat)"
]})
"obsoletes"
:
[
"my.pkg (splat)"
]})
def
format_metadata
(
self
,
dist
):
def
test_classifier
(
self
):
sio
=
io
.
StringIO
()
attrs
=
{
'name'
:
'Boa'
,
'version'
:
'3.0'
,
dist
.
metadata
.
write_pkg_file
(
sio
)
'classifiers'
:
[
'Programming Language :: Python :: 3'
]}
return
sio
.
getvalue
()
dist
=
Distribution
(
attrs
)
meta
=
self
.
format_metadata
(
dist
)
self
.
assertIn
(
'Metadata-Version: 1.1'
,
meta
)
def
test_download_url
(
self
):
attrs
=
{
'name'
:
'Boa'
,
'version'
:
'3.0'
,
'download_url'
:
'http://example.org/boa'
}
dist
=
Distribution
(
attrs
)
meta
=
self
.
format_metadata
(
dist
)
self
.
assertIn
(
'Metadata-Version: 1.1'
,
meta
)
def
test_long_description
(
self
):
long_desc
=
textwrap
.
dedent
(
"""
\
example::
We start here
and continue here
and end here."""
)
attrs
=
{
"name"
:
"package"
,
"version"
:
"1.0"
,
"long_description"
:
long_desc
}
dist
=
Distribution
(
attrs
)
meta
=
self
.
format_metadata
(
dist
)
meta
=
meta
.
replace
(
'
\
n
'
+
8
*
' '
,
'
\
n
'
)
self
.
assertIn
(
long_desc
,
meta
)
def
test_custom_pydistutils
(
self
):
def
test_custom_pydistutils
(
self
):
# fixes #2166
# fixes #2166
...
@@ -272,14 +296,14 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -272,14 +296,14 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
if
sys
.
platform
in
(
'linux'
,
'darwin'
):
if
sys
.
platform
in
(
'linux'
,
'darwin'
):
os
.
environ
[
'HOME'
]
=
temp_dir
os
.
environ
[
'HOME'
]
=
temp_dir
files
=
dist
.
find_config_files
()
files
=
dist
.
find_config_files
()
self
.
assert
True
(
user_filename
in
files
)
self
.
assert
In
(
user_filename
,
files
)
# win32-style
# win32-style
if
sys
.
platform
==
'win32'
:
if
sys
.
platform
==
'win32'
:
# home drive should be found
# home drive should be found
os
.
environ
[
'HOME'
]
=
temp_dir
os
.
environ
[
'HOME'
]
=
temp_dir
files
=
dist
.
find_config_files
()
files
=
dist
.
find_config_files
()
self
.
assert
True
(
user_filename
in
files
,
self
.
assert
In
(
user_filename
,
files
,
'%r not found in %r'
%
(
user_filename
,
files
))
'%r not found in %r'
%
(
user_filename
,
files
))
finally
:
finally
:
os
.
remove
(
user_filename
)
os
.
remove
(
user_filename
)
...
@@ -301,22 +325,8 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
...
@@ -301,22 +325,8 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
output
=
[
line
for
line
in
s
.
getvalue
().
split
(
'
\
n
'
)
output
=
[
line
for
line
in
s
.
getvalue
().
split
(
'
\
n
'
)
if
line
.
strip
()
!=
''
]
if
line
.
strip
()
!=
''
]
self
.
assertTrue
(
len
(
output
)
>
0
)
self
.
assertTrue
(
output
)
def
test_long_description
(
self
):
long_desc
=
textwrap
.
dedent
(
"""
\
example::
We start here
and continue here
and end here."""
)
attrs
=
{
"name"
:
"package"
,
"version"
:
"1.0"
,
"long_description"
:
long_desc
}
dist
=
Distribution
(
attrs
)
meta
=
self
.
format_metadata
(
dist
)
meta
=
meta
.
replace
(
'
\
n
'
+
8
*
' '
,
'
\
n
'
)
self
.
assertTrue
(
long_desc
in
meta
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
Lib/pydoc.py
View file @
1d7deafe
...
@@ -1044,10 +1044,11 @@ class TextDoc(Doc):
...
@@ -1044,10 +1044,11 @@ class TextDoc(Doc):
if
docloc
is
not
None
:
if
docloc
is
not
None
:
result
=
result
+
self
.
section
(
'MODULE REFERENCE'
,
docloc
+
"""
result
=
result
+
self
.
section
(
'MODULE REFERENCE'
,
docloc
+
"""
The following documentation is automatically generated from the Python source
The following documentation is automatically generated from the Python
files. It may be incomplete, incorrect or include features that are considered
source files. It may be incomplete, incorrect or include features that
implementation detail and may vary between Python implementations. When in
are considered implementation detail and may vary between Python
doubt, consult the module reference at the location listed above.
implementations. When in doubt, consult the module reference at the
location listed above.
"""
)
"""
)
if
desc
:
if
desc
:
...
...
Misc/NEWS
View file @
1d7deafe
...
@@ -25,6 +25,10 @@ Core and Builtins
...
@@ -25,6 +25,10 @@ Core and Builtins
Library
Library
-------
-------
- Issue #8933: distutils' PKG-INFO files will now correctly report
Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is
present.
- Issue #9561: distutils now reads and writes egg-info files using UTF-8,
- Issue #9561: distutils now reads and writes egg-info files using UTF-8,
instead of the locale encoding.
instead of the locale encoding.
...
...
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