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
3605030c
Commit
3605030c
authored
Jun 10, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix assorted bugs in packaging.util.cfg_to_args (#11595).
Original patch by Erik Bray.
parent
1c1d9a50
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
17 deletions
+67
-17
Lib/packaging/tests/test_util.py
Lib/packaging/tests/test_util.py
+41
-7
Lib/packaging/util.py
Lib/packaging/util.py
+21
-10
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/packaging/tests/test_util.py
View file @
3605030c
...
@@ -8,16 +8,18 @@ import subprocess
...
@@ -8,16 +8,18 @@ import subprocess
from
io
import
StringIO
from
io
import
StringIO
from
packaging.tests
import
support
,
unittest
from
packaging.tests
import
support
,
unittest
from
packaging.tests.test_config
import
SETUP_CFG
from
packaging.errors
import
(
from
packaging.errors
import
(
PackagingPlatformError
,
PackagingByteCompileError
,
PackagingFileError
,
PackagingPlatformError
,
PackagingByteCompileError
,
PackagingFileError
,
PackagingExecError
,
InstallationException
)
PackagingExecError
,
InstallationException
)
from
packaging
import
util
from
packaging
import
util
from
packaging.dist
import
Distribution
from
packaging.util
import
(
from
packaging.util
import
(
convert_path
,
change_root
,
split_quoted
,
strtobool
,
rfc822_escape
,
convert_path
,
change_root
,
split_quoted
,
strtobool
,
rfc822_escape
,
get_compiler_versions
,
_MAC_OS_X_LD_VERSION
,
byte_compile
,
find_packages
,
get_compiler_versions
,
_MAC_OS_X_LD_VERSION
,
byte_compile
,
find_packages
,
spawn
,
get_pypirc_path
,
generate_pypirc
,
read_pypirc
,
resolve_name
,
iglob
,
spawn
,
get_pypirc_path
,
generate_pypirc
,
read_pypirc
,
resolve_name
,
iglob
,
RICH_GLOB
,
egginfo_to_distinfo
,
is_setuptools
,
is_distutils
,
is_packaging
,
RICH_GLOB
,
egginfo_to_distinfo
,
is_setuptools
,
is_distutils
,
is_packaging
,
get_install_method
)
get_install_method
,
cfg_to_args
)
PYPIRC
=
"""
\
PYPIRC
=
"""
\
...
@@ -88,13 +90,15 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -88,13 +90,15 @@ class UtilTestCase(support.EnvironRestorer,
support
.
LoggingCatcher
,
support
.
LoggingCatcher
,
unittest
.
TestCase
):
unittest
.
TestCase
):
restore_environ
=
[
'HOME'
]
restore_environ
=
[
'HOME'
,
'PLAT'
]
def
setUp
(
self
):
def
setUp
(
self
):
super
(
UtilTestCase
,
self
).
setUp
()
super
(
UtilTestCase
,
self
).
setUp
()
self
.
tmp_dir
=
self
.
mkdtemp
()
self
.
addCleanup
(
os
.
chdir
,
os
.
getcwd
())
self
.
rc
=
os
.
path
.
join
(
self
.
tmp_dir
,
'.pypirc'
)
tempdir
=
self
.
mkdtemp
()
os
.
environ
[
'HOME'
]
=
self
.
tmp_dir
self
.
rc
=
os
.
path
.
join
(
tempdir
,
'.pypirc'
)
os
.
environ
[
'HOME'
]
=
tempdir
os
.
chdir
(
tempdir
)
# saving the environment
# saving the environment
self
.
name
=
os
.
name
self
.
name
=
os
.
name
self
.
platform
=
sys
.
platform
self
.
platform
=
sys
.
platform
...
@@ -103,7 +107,6 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -103,7 +107,6 @@ class UtilTestCase(support.EnvironRestorer,
self
.
join
=
os
.
path
.
join
self
.
join
=
os
.
path
.
join
self
.
isabs
=
os
.
path
.
isabs
self
.
isabs
=
os
.
path
.
isabs
self
.
splitdrive
=
os
.
path
.
splitdrive
self
.
splitdrive
=
os
.
path
.
splitdrive
#self._config_vars = copy(sysconfig._config_vars)
# patching os.uname
# patching os.uname
if
hasattr
(
os
,
'uname'
):
if
hasattr
(
os
,
'uname'
):
...
@@ -137,7 +140,6 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -137,7 +140,6 @@ class UtilTestCase(support.EnvironRestorer,
os
.
uname
=
self
.
uname
os
.
uname
=
self
.
uname
else
:
else
:
del
os
.
uname
del
os
.
uname
#sysconfig._config_vars = copy(self._config_vars)
util
.
find_executable
=
self
.
old_find_executable
util
.
find_executable
=
self
.
old_find_executable
subprocess
.
Popen
=
self
.
old_popen
subprocess
.
Popen
=
self
.
old_popen
sys
.
old_stdout
=
self
.
old_stdout
sys
.
old_stdout
=
self
.
old_stdout
...
@@ -491,6 +493,38 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -491,6 +493,38 @@ class UtilTestCase(support.EnvironRestorer,
content
=
f
.
read
()
content
=
f
.
read
()
self
.
assertEqual
(
content
,
WANTED
)
self
.
assertEqual
(
content
,
WANTED
)
def
test_cfg_to_args
(
self
):
opts
=
{
'description-file'
:
'README'
,
'extra-files'
:
''
,
'setup-hook'
:
'packaging.tests.test_config.hook'
}
self
.
write_file
(
'setup.cfg'
,
SETUP_CFG
%
opts
)
self
.
write_file
(
'README'
,
'loooong description'
)
args
=
cfg_to_args
()
# use Distribution to get the contents of the setup.cfg file
dist
=
Distribution
()
dist
.
parse_config_files
()
metadata
=
dist
.
metadata
self
.
assertEqual
(
args
[
'name'
],
metadata
[
'Name'
])
# + .dev1 because the test SETUP_CFG also tests a hook function in
# test_config.py for appending to the version string
self
.
assertEqual
(
args
[
'version'
]
+
'.dev1'
,
metadata
[
'Version'
])
self
.
assertEqual
(
args
[
'author'
],
metadata
[
'Author'
])
self
.
assertEqual
(
args
[
'author_email'
],
metadata
[
'Author-Email'
])
self
.
assertEqual
(
args
[
'maintainer'
],
metadata
[
'Maintainer'
])
self
.
assertEqual
(
args
[
'maintainer_email'
],
metadata
[
'Maintainer-Email'
])
self
.
assertEqual
(
args
[
'description'
],
metadata
[
'Summary'
])
self
.
assertEqual
(
args
[
'long_description'
],
metadata
[
'Description'
])
self
.
assertEqual
(
args
[
'classifiers'
],
metadata
[
'Classifier'
])
self
.
assertEqual
(
args
[
'requires'
],
metadata
[
'Requires-Dist'
])
self
.
assertEqual
(
args
[
'provides'
],
metadata
[
'Provides-Dist'
])
self
.
assertEqual
(
args
[
'package_dir'
].
get
(
''
),
dist
.
package_dir
)
self
.
assertEqual
(
args
[
'packages'
],
dist
.
packages
)
self
.
assertEqual
(
args
[
'scripts'
],
dist
.
scripts
)
self
.
assertEqual
(
args
[
'py_modules'
],
dist
.
py_modules
)
class
GlobTestCaseBase
(
support
.
TempdirManager
,
class
GlobTestCaseBase
(
support
.
TempdirManager
,
support
.
LoggingCatcher
,
support
.
LoggingCatcher
,
...
...
Lib/packaging/util.py
View file @
3605030c
...
@@ -1015,16 +1015,20 @@ def cfg_to_args(path='setup.cfg'):
...
@@ -1015,16 +1015,20 @@ def cfg_to_args(path='setup.cfg'):
"requires"
:
(
"metadata"
,
"requires_dist"
),
"requires"
:
(
"metadata"
,
"requires_dist"
),
"provides"
:
(
"metadata"
,
"provides_dist"
),
# **
"provides"
:
(
"metadata"
,
"provides_dist"
),
# **
"obsoletes"
:
(
"metadata"
,
"obsoletes_dist"
),
# **
"obsoletes"
:
(
"metadata"
,
"obsoletes_dist"
),
# **
"package_dir"
:
(
"files"
,
'packages_root'
),
"packages"
:
(
"files"
,),
"packages"
:
(
"files"
,),
"scripts"
:
(
"files"
,),
"scripts"
:
(
"files"
,),
"py_modules"
:
(
"files"
,
"modules"
),
# **
"py_modules"
:
(
"files"
,
"modules"
),
# **
}
}
MULTI_FIELDS
=
(
"classifiers"
,
MULTI_FIELDS
=
(
"classifiers"
,
"requires"
,
"platforms"
,
"platforms"
,
"requires"
,
"provides"
,
"obsoletes"
,
"packages"
,
"packages"
,
"scripts"
)
"scripts"
,
"py_modules"
)
def
has_get_option
(
config
,
section
,
option
):
def
has_get_option
(
config
,
section
,
option
):
if
config
.
has_option
(
section
,
option
):
if
config
.
has_option
(
section
,
option
):
...
@@ -1036,9 +1040,9 @@ def cfg_to_args(path='setup.cfg'):
...
@@ -1036,9 +1040,9 @@ def cfg_to_args(path='setup.cfg'):
# The real code starts here
# The real code starts here
config
=
RawConfigParser
()
config
=
RawConfigParser
()
if
not
os
.
path
.
exists
(
file
):
if
not
os
.
path
.
exists
(
path
):
raise
PackagingFileError
(
"file '%s' does not exist"
%
raise
PackagingFileError
(
"file '%s' does not exist"
%
os
.
path
.
abspath
(
file
))
os
.
path
.
abspath
(
path
))
config
.
read
(
path
)
config
.
read
(
path
)
kwargs
=
{}
kwargs
=
{}
...
@@ -1055,17 +1059,24 @@ def cfg_to_args(path='setup.cfg'):
...
@@ -1055,17 +1059,24 @@ def cfg_to_args(path='setup.cfg'):
in_cfg_value
=
has_get_option
(
config
,
section
,
option
)
in_cfg_value
=
has_get_option
(
config
,
section
,
option
)
if
not
in_cfg_value
:
if
not
in_cfg_value
:
# There is no such option in the setup.cfg
# There is no such option in the setup.cfg
if
arg
==
"long_description"
:
if
arg
==
'long_description'
:
filename
=
has_get_option
(
config
,
section
,
"description_file"
)
filenames
=
has_get_option
(
config
,
section
,
'description-file'
)
if
filename
:
if
filenames
:
filenames
=
split_multiline
(
filenames
)
in_cfg_value
=
[]
for
filename
in
filenames
:
with
open
(
filename
)
as
fp
:
with
open
(
filename
)
as
fp
:
in_cfg_value
=
fp
.
read
()
in_cfg_value
.
append
(
fp
.
read
())
in_cfg_value
=
'
\
n
\
n
'
.
join
(
in_cfg_value
)
else
:
else
:
continue
continue
if
arg
==
'package_dir'
and
in_cfg_value
:
in_cfg_value
=
{
''
:
in_cfg_value
}
if
arg
in
MULTI_FIELDS
:
if
arg
in
MULTI_FIELDS
:
# support multiline options
# support multiline options
in_cfg_value
=
in_cfg_value
.
strip
().
split
(
'
\
n
'
)
in_cfg_value
=
split_multiline
(
in_cfg_value
)
kwargs
[
arg
]
=
in_cfg_value
kwargs
[
arg
]
=
in_cfg_value
...
...
Misc/ACKS
View file @
3605030c
...
@@ -116,6 +116,7 @@ Monty Brandenberg
...
@@ -116,6 +116,7 @@ Monty Brandenberg
Georg Brandl
Georg Brandl
Christopher Brannon
Christopher Brannon
Terrence Brannon
Terrence Brannon
Erik Bray
Brian Brazil
Brian Brazil
Dave Brennan
Dave Brennan
Tom Bridgman
Tom Bridgman
...
...
Misc/NEWS
View file @
3605030c
...
@@ -187,6 +187,10 @@ Core and Builtins
...
@@ -187,6 +187,10 @@ Core and Builtins
Library
Library
-------
-------
- Issue #11595: Fix assorted bugs in packaging.util.cfg_to_args, a
compatibility helper for the distutils-packaging transition. Original patch
by Erik Bray.
- Issue #12246: Warn and fail when trying to install a third-party project from
- Issue #12246: Warn and fail when trying to install a third-party project from
an uninstalled Python (built in a source checkout). Original patch by
an uninstalled Python (built in a source checkout). Original patch by
Tshepang Lekhonkhobe.
Tshepang Lekhonkhobe.
...
...
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