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
becf1c58
Commit
becf1c58
authored
Sep 19, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Plain Diff
Branch merge
parents
2496f331
28df8de6
Changes
44
Show whitespace changes
Inline
Side-by-side
Showing
44 changed files
with
215 additions
and
283 deletions
+215
-283
Lib/packaging/command/bdist_dumb.py
Lib/packaging/command/bdist_dumb.py
+2
-2
Lib/packaging/command/build_clib.py
Lib/packaging/command/build_clib.py
+1
-2
Lib/packaging/command/build_ext.py
Lib/packaging/command/build_ext.py
+6
-11
Lib/packaging/command/build_py.py
Lib/packaging/command/build_py.py
+1
-1
Lib/packaging/command/build_scripts.py
Lib/packaging/command/build_scripts.py
+2
-2
Lib/packaging/command/install_dist.py
Lib/packaging/command/install_dist.py
+21
-38
Lib/packaging/command/install_distinfo.py
Lib/packaging/command/install_distinfo.py
+4
-5
Lib/packaging/command/install_lib.py
Lib/packaging/command/install_lib.py
+1
-1
Lib/packaging/command/upload_docs.py
Lib/packaging/command/upload_docs.py
+1
-0
Lib/packaging/compat.py
Lib/packaging/compat.py
+1
-7
Lib/packaging/compiler/bcppcompiler.py
Lib/packaging/compiler/bcppcompiler.py
+0
-1
Lib/packaging/compiler/ccompiler.py
Lib/packaging/compiler/ccompiler.py
+0
-1
Lib/packaging/compiler/unixccompiler.py
Lib/packaging/compiler/unixccompiler.py
+1
-1
Lib/packaging/create.py
Lib/packaging/create.py
+5
-17
Lib/packaging/database.py
Lib/packaging/database.py
+4
-3
Lib/packaging/dist.py
Lib/packaging/dist.py
+2
-2
Lib/packaging/metadata.py
Lib/packaging/metadata.py
+4
-3
Lib/packaging/pypi/simple.py
Lib/packaging/pypi/simple.py
+3
-4
Lib/packaging/tests/__init__.py
Lib/packaging/tests/__init__.py
+5
-8
Lib/packaging/tests/__main__.py
Lib/packaging/tests/__main__.py
+2
-0
Lib/packaging/tests/pypi_server.py
Lib/packaging/tests/pypi_server.py
+4
-3
Lib/packaging/tests/test_command_bdist_dumb.py
Lib/packaging/tests/test_command_bdist_dumb.py
+1
-1
Lib/packaging/tests/test_command_build_ext.py
Lib/packaging/tests/test_command_build_ext.py
+6
-13
Lib/packaging/tests/test_command_build_py.py
Lib/packaging/tests/test_command_build_py.py
+0
-2
Lib/packaging/tests/test_command_install_dist.py
Lib/packaging/tests/test_command_install_dist.py
+5
-7
Lib/packaging/tests/test_command_install_lib.py
Lib/packaging/tests/test_command_install_lib.py
+1
-10
Lib/packaging/tests/test_command_register.py
Lib/packaging/tests/test_command_register.py
+1
-1
Lib/packaging/tests/test_command_upload.py
Lib/packaging/tests/test_command_upload.py
+10
-14
Lib/packaging/tests/test_command_upload_docs.py
Lib/packaging/tests/test_command_upload_docs.py
+29
-38
Lib/packaging/tests/test_create.py
Lib/packaging/tests/test_create.py
+8
-5
Lib/packaging/tests/test_database.py
Lib/packaging/tests/test_database.py
+3
-2
Lib/packaging/tests/test_depgraph.py
Lib/packaging/tests/test_depgraph.py
+17
-16
Lib/packaging/tests/test_dist.py
Lib/packaging/tests/test_dist.py
+9
-7
Lib/packaging/tests/test_install.py
Lib/packaging/tests/test_install.py
+1
-1
Lib/packaging/tests/test_metadata.py
Lib/packaging/tests/test_metadata.py
+2
-2
Lib/packaging/tests/test_mixin2to3.py
Lib/packaging/tests/test_mixin2to3.py
+0
-3
Lib/packaging/tests/test_pypi_server.py
Lib/packaging/tests/test_pypi_server.py
+8
-7
Lib/packaging/tests/test_run.py
Lib/packaging/tests/test_run.py
+1
-16
Lib/packaging/tests/test_util.py
Lib/packaging/tests/test_util.py
+2
-8
Lib/packaging/util.py
Lib/packaging/util.py
+4
-2
Lib/pkgutil.py
Lib/pkgutil.py
+2
-2
Lib/shutil.py
Lib/shutil.py
+4
-4
Lib/test/regrtest.py
Lib/test/regrtest.py
+24
-1
Lib/test/test_sysconfig.py
Lib/test/test_sysconfig.py
+7
-9
No files found.
Lib/packaging/command/bdist_dumb.py
View file @
becf1c58
...
@@ -5,9 +5,9 @@ sys.prefix or sys.exec_prefix.
...
@@ -5,9 +5,9 @@ sys.prefix or sys.exec_prefix.
"""
"""
import
os
import
os
from
shutil
import
rmtree
from
shutil
import
rmtree
from
sysconfig
import
get_python_version
from
sysconfig
import
get_python_version
from
packaging.util
import
get_platform
from
packaging.util
import
get_platform
from
packaging.command.cmd
import
Command
from
packaging.command.cmd
import
Command
from
packaging.errors
import
PackagingPlatformError
from
packaging.errors
import
PackagingPlatformError
...
@@ -24,7 +24,7 @@ class bdist_dumb(Command):
...
@@ -24,7 +24,7 @@ class bdist_dumb(Command):
"platform name to embed in generated filenames "
"platform name to embed in generated filenames "
"(default: %s)"
%
get_platform
()),
"(default: %s)"
%
get_platform
()),
(
'format='
,
'f'
,
(
'format='
,
'f'
,
"archive format to create (tar, gztar, zip)"
),
"archive format to create (tar, gztar,
bztar,
zip)"
),
(
'keep-temp'
,
'k'
,
(
'keep-temp'
,
'k'
,
"keep the pseudo-installation tree around after "
+
"keep the pseudo-installation tree around after "
+
"creating the distribution archive"
),
"creating the distribution archive"
),
...
...
Lib/packaging/command/build_clib.py
View file @
becf1c58
...
@@ -16,7 +16,7 @@ distribution and needed by extension modules.
...
@@ -16,7 +16,7 @@ distribution and needed by extension modules.
import
os
import
os
from
packaging.command.cmd
import
Command
from
packaging.command.cmd
import
Command
from
packaging.errors
import
PackagingSetupError
from
packaging.errors
import
PackagingSetupError
from
packaging.compiler
import
customize_compiler
from
packaging.compiler
import
customize_compiler
,
new_compiler
from
packaging
import
logger
from
packaging
import
logger
...
@@ -93,7 +93,6 @@ class build_clib(Command):
...
@@ -93,7 +93,6 @@ class build_clib(Command):
return
return
# Yech -- this is cut 'n pasted from build_ext.py!
# Yech -- this is cut 'n pasted from build_ext.py!
from
packaging.compiler
import
new_compiler
self
.
compiler
=
new_compiler
(
compiler
=
self
.
compiler
,
self
.
compiler
=
new_compiler
(
compiler
=
self
.
compiler
,
dry_run
=
self
.
dry_run
,
dry_run
=
self
.
dry_run
,
force
=
self
.
force
)
force
=
self
.
force
)
...
...
Lib/packaging/command/build_ext.py
View file @
becf1c58
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
os
import
os
import
re
import
re
import
sys
import
sys
import
site
import
logging
import
logging
import
sysconfig
import
sysconfig
...
@@ -15,9 +16,6 @@ from packaging.util import newer_group
...
@@ -15,9 +16,6 @@ from packaging.util import newer_group
from
packaging.compiler.extension
import
Extension
from
packaging.compiler.extension
import
Extension
from
packaging
import
logger
from
packaging
import
logger
import
site
HAS_USER_SITE
=
True
if
os
.
name
==
'nt'
:
if
os
.
name
==
'nt'
:
from
packaging.compiler.msvccompiler
import
get_build_version
from
packaging.compiler.msvccompiler
import
get_build_version
MSVC_VERSION
=
int
(
get_build_version
())
MSVC_VERSION
=
int
(
get_build_version
())
...
@@ -62,6 +60,8 @@ class build_ext(Command):
...
@@ -62,6 +60,8 @@ class build_ext(Command):
(
'inplace'
,
'i'
,
(
'inplace'
,
'i'
,
"ignore build-lib and put compiled extensions into the source "
+
"ignore build-lib and put compiled extensions into the source "
+
"directory alongside your pure Python modules"
),
"directory alongside your pure Python modules"
),
(
'user'
,
None
,
"add user include, library and rpath"
),
(
'include-dirs='
,
'I'
,
(
'include-dirs='
,
'I'
,
"list of directories to search for header files"
+
sep_by
),
"list of directories to search for header files"
+
sep_by
),
(
'define='
,
'D'
,
(
'define='
,
'D'
,
...
@@ -88,12 +88,8 @@ class build_ext(Command):
...
@@ -88,12 +88,8 @@ class build_ext(Command):
"path to the SWIG executable"
),
"path to the SWIG executable"
),
]
]
boolean_options
=
[
'inplace'
,
'debug'
,
'force'
]
boolean_options
=
[
'inplace'
,
'debug'
,
'force'
,
'user'
]
if
HAS_USER_SITE
:
user_options
.
append
((
'user'
,
None
,
"add user include, library and rpath"
))
boolean_options
.
append
(
'user'
)
help_options
=
[
help_options
=
[
(
'help-compiler'
,
None
,
(
'help-compiler'
,
None
,
...
@@ -120,7 +116,6 @@ class build_ext(Command):
...
@@ -120,7 +116,6 @@ class build_ext(Command):
self
.
compiler
=
None
self
.
compiler
=
None
self
.
swig
=
None
self
.
swig
=
None
self
.
swig_opts
=
None
self
.
swig_opts
=
None
if
HAS_USER_SITE
:
self
.
user
=
None
self
.
user
=
None
def
finalize_options
(
self
):
def
finalize_options
(
self
):
...
@@ -270,7 +265,7 @@ class build_ext(Command):
...
@@ -270,7 +265,7 @@ class build_ext(Command):
self
.
swig_opts
=
self
.
swig_opts
.
split
(
' '
)
self
.
swig_opts
=
self
.
swig_opts
.
split
(
' '
)
# Finally add the user include and library directories if requested
# Finally add the user include and library directories if requested
if
HAS_USER_SITE
and
self
.
user
:
if
self
.
user
:
user_include
=
os
.
path
.
join
(
site
.
USER_BASE
,
"include"
)
user_include
=
os
.
path
.
join
(
site
.
USER_BASE
,
"include"
)
user_lib
=
os
.
path
.
join
(
site
.
USER_BASE
,
"lib"
)
user_lib
=
os
.
path
.
join
(
site
.
USER_BASE
,
"lib"
)
if
os
.
path
.
isdir
(
user_include
):
if
os
.
path
.
isdir
(
user_include
):
...
...
Lib/packaging/command/build_py.py
View file @
becf1c58
...
@@ -388,7 +388,7 @@ class build_py(Command, Mixin2to3):
...
@@ -388,7 +388,7 @@ class build_py(Command, Mixin2to3):
self
.
build_module
(
module
,
module_file
,
package
)
self
.
build_module
(
module
,
module_file
,
package
)
def
byte_compile
(
self
,
files
):
def
byte_compile
(
self
,
files
):
if
hasattr
(
sys
,
'dont_write_bytecode'
)
and
sys
.
dont_write_bytecode
:
if
sys
.
dont_write_bytecode
:
logger
.
warning
(
'%s: byte-compiling is disabled, skipping.'
,
logger
.
warning
(
'%s: byte-compiling is disabled, skipping.'
,
self
.
get_command_name
())
self
.
get_command_name
())
return
return
...
...
Lib/packaging/command/build_scripts.py
View file @
becf1c58
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
os
import
os
import
re
import
re
import
sysconfig
import
sysconfig
import
tokenize
from
tokenize
import
detect_encoding
from
packaging.command.cmd
import
Command
from
packaging.command.cmd
import
Command
from
packaging.util
import
convert_path
,
newer
from
packaging.util
import
convert_path
,
newer
...
@@ -83,7 +83,7 @@ class build_scripts(Command, Mixin2to3):
...
@@ -83,7 +83,7 @@ class build_scripts(Command, Mixin2to3):
raise
raise
f
=
None
f
=
None
else
:
else
:
encoding
,
lines
=
tokenize
.
detect_encoding
(
f
.
readline
)
encoding
,
lines
=
detect_encoding
(
f
.
readline
)
f
.
seek
(
0
)
f
.
seek
(
0
)
first_line
=
f
.
readline
()
first_line
=
f
.
readline
()
if
not
first_line
:
if
not
first_line
:
...
...
Lib/packaging/command/install_dist.py
View file @
becf1c58
...
@@ -14,9 +14,6 @@ from packaging.util import convert_path, change_root, get_platform
...
@@ -14,9 +14,6 @@ from packaging.util import convert_path, change_root, get_platform
from
packaging.errors
import
PackagingOptionError
from
packaging.errors
import
PackagingOptionError
HAS_USER_SITE
=
True
class
install_dist
(
Command
):
class
install_dist
(
Command
):
description
=
"install everything from build directory"
description
=
"install everything from build directory"
...
@@ -27,6 +24,9 @@ class install_dist(Command):
...
@@ -27,6 +24,9 @@ class install_dist(Command):
"installation prefix"
),
"installation prefix"
),
(
'exec-prefix='
,
None
,
(
'exec-prefix='
,
None
,
"(Unix only) prefix for platform-specific files"
),
"(Unix only) prefix for platform-specific files"
),
(
'user'
,
None
,
"install in user site-packages directory [%s]"
%
get_path
(
'purelib'
,
'%s_user'
%
os
.
name
)),
(
'home='
,
None
,
(
'home='
,
None
,
"(Unix only) home directory to install under"
),
"(Unix only) home directory to install under"
),
...
@@ -97,15 +97,7 @@ class install_dist(Command):
...
@@ -97,15 +97,7 @@ class install_dist(Command):
]
]
boolean_options
=
[
'compile'
,
'force'
,
'skip-build'
,
'no-distinfo'
,
boolean_options
=
[
'compile'
,
'force'
,
'skip-build'
,
'no-distinfo'
,
'requested'
,
'no-record'
]
'requested'
,
'no-record'
,
'user'
]
if
HAS_USER_SITE
:
user_options
.
append
(
(
'user'
,
None
,
"install in user site-packages directory [%s]"
%
get_path
(
'purelib'
,
'%s_user'
%
os
.
name
)))
boolean_options
.
append
(
'user'
)
negative_opt
=
{
'no-compile'
:
'compile'
,
'no-requested'
:
'requested'
}
negative_opt
=
{
'no-compile'
:
'compile'
,
'no-requested'
:
'requested'
}
...
@@ -115,7 +107,6 @@ class install_dist(Command):
...
@@ -115,7 +107,6 @@ class install_dist(Command):
self
.
prefix
=
None
self
.
prefix
=
None
self
.
exec_prefix
=
None
self
.
exec_prefix
=
None
self
.
home
=
None
self
.
home
=
None
if
HAS_USER_SITE
:
self
.
user
=
False
self
.
user
=
False
# These select only the installation base; it's up to the user to
# These select only the installation base; it's up to the user to
...
@@ -135,7 +126,6 @@ class install_dist(Command):
...
@@ -135,7 +126,6 @@ class install_dist(Command):
self
.
install_lib
=
None
# set to either purelib or platlib
self
.
install_lib
=
None
# set to either purelib or platlib
self
.
install_scripts
=
None
self
.
install_scripts
=
None
self
.
install_data
=
None
self
.
install_data
=
None
if
HAS_USER_SITE
:
self
.
install_userbase
=
get_config_var
(
'userbase'
)
self
.
install_userbase
=
get_config_var
(
'userbase'
)
self
.
install_usersite
=
get_path
(
'purelib'
,
'%s_user'
%
os
.
name
)
self
.
install_usersite
=
get_path
(
'purelib'
,
'%s_user'
%
os
.
name
)
...
@@ -219,8 +209,7 @@ class install_dist(Command):
...
@@ -219,8 +209,7 @@ class install_dist(Command):
raise
PackagingOptionError
(
raise
PackagingOptionError
(
"must supply either home or prefix/exec-prefix -- not both"
)
"must supply either home or prefix/exec-prefix -- not both"
)
if
HAS_USER_SITE
and
self
.
user
and
(
if
self
.
user
and
(
self
.
prefix
or
self
.
exec_prefix
or
self
.
home
or
self
.
prefix
or
self
.
exec_prefix
or
self
.
home
or
self
.
install_base
or
self
.
install_platbase
):
self
.
install_base
or
self
.
install_platbase
):
raise
PackagingOptionError
(
raise
PackagingOptionError
(
"can't combine user with prefix/exec_prefix/home or "
"can't combine user with prefix/exec_prefix/home or "
...
@@ -274,12 +263,10 @@ class install_dist(Command):
...
@@ -274,12 +263,10 @@ class install_dist(Command):
'exec_prefix'
:
exec_prefix
,
'exec_prefix'
:
exec_prefix
,
'srcdir'
:
srcdir
,
'srcdir'
:
srcdir
,
'projectbase'
:
projectbase
,
'projectbase'
:
projectbase
,
'userbase'
:
self
.
install_userbase
,
'usersite'
:
self
.
install_usersite
,
}
}
if
HAS_USER_SITE
:
self
.
config_vars
[
'userbase'
]
=
self
.
install_userbase
self
.
config_vars
[
'usersite'
]
=
self
.
install_usersite
self
.
expand_basedirs
()
self
.
expand_basedirs
()
self
.
dump_dirs
(
"post-expand_basedirs()"
)
self
.
dump_dirs
(
"post-expand_basedirs()"
)
...
@@ -295,9 +282,9 @@ class install_dist(Command):
...
@@ -295,9 +282,9 @@ class install_dist(Command):
self
.
dump_dirs
(
"post-expand_dirs()"
)
self
.
dump_dirs
(
"post-expand_dirs()"
)
# Create directories
in the home dir:
# Create directories
under USERBASE
if
HAS_USER_SITE
and
self
.
user
:
if
self
.
user
:
self
.
create_
home_path
()
self
.
create_
user_dirs
()
# Pick the actual directory to install all modules to: either
# Pick the actual directory to install all modules to: either
# install_purelib or install_platlib, depending on whether this
# install_purelib or install_platlib, depending on whether this
...
@@ -311,10 +298,8 @@ class install_dist(Command):
...
@@ -311,10 +298,8 @@ class install_dist(Command):
# Convert directories from Unix /-separated syntax to the local
# Convert directories from Unix /-separated syntax to the local
# convention.
# convention.
self
.
convert_paths
(
'lib'
,
'purelib'
,
'platlib'
,
self
.
convert_paths
(
'lib'
,
'purelib'
,
'platlib'
,
'scripts'
,
'scripts'
,
'data'
,
'headers'
)
'data'
,
'headers'
,
'userbase'
,
'usersite'
)
if
HAS_USER_SITE
:
self
.
convert_paths
(
'userbase'
,
'usersite'
)
# Well, we're not actually fully completely finalized yet: we still
# Well, we're not actually fully completely finalized yet: we still
# have to deal with 'extra_path', which is the hack for allowing
# have to deal with 'extra_path', which is the hack for allowing
...
@@ -355,7 +340,7 @@ class install_dist(Command):
...
@@ -355,7 +340,7 @@ class install_dist(Command):
"installation scheme is incomplete"
)
"installation scheme is incomplete"
)
return
return
if
HAS_USER_SITE
and
self
.
user
:
if
self
.
user
:
if
self
.
install_userbase
is
None
:
if
self
.
install_userbase
is
None
:
raise
PackagingPlatformError
(
raise
PackagingPlatformError
(
"user base directory is not specified"
)
"user base directory is not specified"
)
...
@@ -383,7 +368,7 @@ class install_dist(Command):
...
@@ -383,7 +368,7 @@ class install_dist(Command):
def
finalize_other
(
self
):
def
finalize_other
(
self
):
"""Finalize options for non-posix platforms"""
"""Finalize options for non-posix platforms"""
if
HAS_USER_SITE
and
self
.
user
:
if
self
.
user
:
if
self
.
install_userbase
is
None
:
if
self
.
install_userbase
is
None
:
raise
PackagingPlatformError
(
raise
PackagingPlatformError
(
"user base directory is not specified"
)
"user base directory is not specified"
)
...
@@ -494,10 +479,8 @@ class install_dist(Command):
...
@@ -494,10 +479,8 @@ class install_dist(Command):
attr
=
"install_"
+
name
attr
=
"install_"
+
name
setattr
(
self
,
attr
,
change_root
(
self
.
root
,
getattr
(
self
,
attr
)))
setattr
(
self
,
attr
,
change_root
(
self
.
root
,
getattr
(
self
,
attr
)))
def
create_home_path
(
self
):
def
create_user_dirs
(
self
):
"""Create directories under ~."""
"""Create directories under USERBASE as needed."""
if
HAS_USER_SITE
and
not
self
.
user
:
return
home
=
convert_path
(
os
.
path
.
expanduser
(
"~"
))
home
=
convert_path
(
os
.
path
.
expanduser
(
"~"
))
for
name
,
path
in
self
.
config_vars
.
items
():
for
name
,
path
in
self
.
config_vars
.
items
():
if
path
.
startswith
(
home
)
and
not
os
.
path
.
isdir
(
path
):
if
path
.
startswith
(
home
)
and
not
os
.
path
.
isdir
(
path
):
...
...
Lib/packaging/command/install_distinfo.py
View file @
becf1c58
...
@@ -2,14 +2,13 @@
...
@@ -2,14 +2,13 @@
# Forked from the former install_egg_info command by Josip Djolonga
# Forked from the former install_egg_info command by Josip Djolonga
import
csv
import
os
import
os
import
re
import
csv
import
hashlib
import
hashlib
from
shutil
import
rmtree
from
packaging.command.cmd
import
Command
from
packaging
import
logger
from
packaging
import
logger
from
shutil
import
rmtree
from
packaging.command.cmd
import
Command
class
install_distinfo
(
Command
):
class
install_distinfo
(
Command
):
...
@@ -28,7 +27,7 @@ class install_distinfo(Command):
...
@@ -28,7 +27,7 @@ class install_distinfo(Command):
(
'no-record'
,
None
,
(
'no-record'
,
None
,
"do not generate a RECORD file"
),
"do not generate a RECORD file"
),
(
'no-resources'
,
None
,
(
'no-resources'
,
None
,
"do not generate a RES
SOURCES list installed
file"
),
"do not generate a RES
OURCES
file"
),
]
]
boolean_options
=
[
'requested'
,
'no-record'
,
'no-resources'
]
boolean_options
=
[
'requested'
,
'no-record'
,
'no-resources'
]
...
...
Lib/packaging/command/install_lib.py
View file @
becf1c58
...
@@ -114,7 +114,7 @@ class install_lib(Command):
...
@@ -114,7 +114,7 @@ class install_lib(Command):
return
outfiles
return
outfiles
def
byte_compile
(
self
,
files
):
def
byte_compile
(
self
,
files
):
if
getattr
(
sys
,
'dont_write_bytecode'
)
:
if
sys
.
dont_write_bytecode
:
# XXX do we want this? because a Python runs without bytecode
# XXX do we want this? because a Python runs without bytecode
# doesn't mean that the *dists should not contain bytecode
# doesn't mean that the *dists should not contain bytecode
#--or does it?
#--or does it?
...
...
Lib/packaging/command/upload_docs.py
View file @
becf1c58
...
@@ -87,6 +87,7 @@ class upload_docs(Command):
...
@@ -87,6 +87,7 @@ class upload_docs(Command):
content_type
,
body
=
encode_multipart
(
fields
,
files
)
content_type
,
body
=
encode_multipart
(
fields
,
files
)
credentials
=
self
.
username
+
':'
+
self
.
password
credentials
=
self
.
username
+
':'
+
self
.
password
# FIXME should use explicit encoding
auth
=
b"Basic "
+
base64
.
encodebytes
(
credentials
.
encode
()).
strip
()
auth
=
b"Basic "
+
base64
.
encodebytes
(
credentials
.
encode
()).
strip
()
logger
.
info
(
"Submitting documentation to %s"
,
self
.
repository
)
logger
.
info
(
"Submitting documentation to %s"
,
self
.
repository
)
...
...
Lib/packaging/compat.py
View file @
becf1c58
"""Compatibility helpers.
"""Compatibility helpers."""
This module provides classes, variables and imports which are used to
support packaging across Python 2.x and 3.x.
"""
from
packaging
import
logger
from
packaging
import
logger
...
@@ -10,8 +6,6 @@ from packaging import logger
...
@@ -10,8 +6,6 @@ from packaging import logger
# XXX Having two classes with the same name is not a good thing.
# XXX Having two classes with the same name is not a good thing.
# XXX 2to3-related code should move from util to this module
# XXX 2to3-related code should move from util to this module
# TODO Move common code here: PY3 (bool indicating if we're on 3.x), any, etc.
try
:
try
:
from
packaging.util
import
Mixin2to3
as
_Mixin2to3
from
packaging.util
import
Mixin2to3
as
_Mixin2to3
_CONVERT
=
True
_CONVERT
=
True
...
...
Lib/packaging/compiler/bcppcompiler.py
View file @
becf1c58
...
@@ -352,5 +352,4 @@ class BCPPCompiler(CCompiler) :
...
@@ -352,5 +352,4 @@ class BCPPCompiler(CCompiler) :
try
:
try
:
self
.
spawn
(
pp_args
)
self
.
spawn
(
pp_args
)
except
PackagingExecError
as
msg
:
except
PackagingExecError
as
msg
:
print
(
msg
)
raise
CompileError
(
msg
)
raise
CompileError
(
msg
)
Lib/packaging/compiler/ccompiler.py
View file @
becf1c58
...
@@ -5,7 +5,6 @@ interface for the compiler abstraction model used by packaging.
...
@@ -5,7 +5,6 @@ interface for the compiler abstraction model used by packaging.
"""
"""
import
os
import
os
import
sys
from
shutil
import
move
from
shutil
import
move
from
packaging
import
logger
from
packaging
import
logger
from
packaging.util
import
split_quoted
,
execute
,
newer_group
,
spawn
from
packaging.util
import
split_quoted
,
execute
,
newer_group
,
spawn
...
...
Lib/packaging/compiler/unixccompiler.py
View file @
becf1c58
...
@@ -127,7 +127,7 @@ class UnixCCompiler(CCompiler):
...
@@ -127,7 +127,7 @@ class UnixCCompiler(CCompiler):
executables
[
'ranlib'
]
=
[
"ranlib"
]
executables
[
'ranlib'
]
=
[
"ranlib"
]
# Needed for the filename generation methods provided by the base
# Needed for the filename generation methods provided by the base
# class, CCompiler.
NB.
whoever instantiates/uses a particular
# class, CCompiler.
XXX
whoever instantiates/uses a particular
# UnixCCompiler instance should set 'shared_lib_ext' -- we set a
# UnixCCompiler instance should set 'shared_lib_ext' -- we set a
# reasonable common default here, but it's not necessarily used on all
# reasonable common default here, but it's not necessarily used on all
# Unices!
# Unices!
...
...
Lib/packaging/create.py
View file @
becf1c58
...
@@ -25,11 +25,11 @@ import sys
...
@@ -25,11 +25,11 @@ import sys
import
glob
import
glob
import
shutil
import
shutil
import
sysconfig
import
sysconfig
import
tokenize
from
hashlib
import
md5
from
hashlib
import
md5
from
textwrap
import
dedent
from
textwrap
import
dedent
from
functools
import
cmp_to_key
from
tokenize
import
detect_encoding
from
configparser
import
RawConfigParser
from
configparser
import
RawConfigParser
# importing this with an underscore as it should be replaced by the
# importing this with an underscore as it should be replaced by the
# dict form or another structures for all purposes
# dict form or another structures for all purposes
from
packaging._trove
import
all_classifiers
as
_CLASSIFIERS_LIST
from
packaging._trove
import
all_classifiers
as
_CLASSIFIERS_LIST
...
@@ -112,7 +112,7 @@ def load_setup():
...
@@ -112,7 +112,7 @@ def load_setup():
been loaded before, because we are monkey patching its setup function with
been loaded before, because we are monkey patching its setup function with
a particular one"""
a particular one"""
with
open
(
"setup.py"
,
"rb"
)
as
f
:
with
open
(
"setup.py"
,
"rb"
)
as
f
:
encoding
,
lines
=
tokenize
.
detect_encoding
(
f
.
readline
)
encoding
,
lines
=
detect_encoding
(
f
.
readline
)
with
open
(
"setup.py"
,
encoding
=
encoding
)
as
f
:
with
open
(
"setup.py"
,
encoding
=
encoding
)
as
f
:
imp
.
load_module
(
"setup"
,
f
,
"setup.py"
,
(
".py"
,
"r"
,
imp
.
PY_SOURCE
))
imp
.
load_module
(
"setup"
,
f
,
"setup.py"
,
(
".py"
,
"r"
,
imp
.
PY_SOURCE
))
...
@@ -370,21 +370,9 @@ class MainProgram:
...
@@ -370,21 +370,9 @@ class MainProgram:
dist
.
data_files
=
[(
''
,
dist
.
data_files
)]
dist
.
data_files
=
[(
''
,
dist
.
data_files
)]
# add tokens in the destination paths
# add tokens in the destination paths
vars
=
{
'distribution.name'
:
data
[
'name'
]}
vars
=
{
'distribution.name'
:
data
[
'name'
]}
path_tokens
=
list
(
sysconfig
.
get_paths
(
vars
=
vars
).
items
())
path_tokens
=
sysconfig
.
get_paths
(
vars
=
vars
).
items
()
# TODO replace this with a key function
def
length_comparison
(
x
,
y
):
len_x
=
len
(
x
[
1
])
len_y
=
len
(
y
[
1
])
if
len_x
==
len_y
:
return
0
elif
len_x
<
len_y
:
return
-
1
else
:
return
1
# sort tokens to use the longest one first
# sort tokens to use the longest one first
path_tokens
.
sort
(
key
=
cmp_to_key
(
length_comparison
))
path_tokens
=
sorted
(
path_tokens
,
key
=
lambda
x
:
len
(
x
[
1
]
))
for
dest
,
srcs
in
(
dist
.
data_files
or
[]):
for
dest
,
srcs
in
(
dist
.
data_files
or
[]):
dest
=
os
.
path
.
join
(
sys
.
prefix
,
dest
)
dest
=
os
.
path
.
join
(
sys
.
prefix
,
dest
)
dest
=
dest
.
replace
(
os
.
path
.
sep
,
'/'
)
dest
=
dest
.
replace
(
os
.
path
.
sep
,
'/'
)
...
...
Lib/packaging/database.py
View file @
becf1c58
"""PEP 376 implementation."""
"""PEP 376 implementation."""
import
io
import
os
import
os
import
re
import
re
import
csv
import
csv
import
sys
import
sys
import
zipimport
import
zipimport
from
io
import
StringIO
from
hashlib
import
md5
from
hashlib
import
md5
from
packaging
import
logger
from
packaging
import
logger
from
packaging.errors
import
PackagingError
from
packaging.errors
import
PackagingError
from
packaging.version
import
suggest_normalized_version
,
VersionPredicate
from
packaging.version
import
suggest_normalized_version
,
VersionPredicate
...
@@ -334,7 +335,7 @@ class EggInfoDistribution:
...
@@ -334,7 +335,7 @@ class EggInfoDistribution:
else
:
else
:
# FIXME handle the case where zipfile is not available
# FIXME handle the case where zipfile is not available
zipf
=
zipimport
.
zipimporter
(
path
)
zipf
=
zipimport
.
zipimporter
(
path
)
fileobj
=
io
.
StringIO
(
fileobj
=
StringIO
(
zipf
.
get_data
(
'EGG-INFO/PKG-INFO'
).
decode
(
'utf8'
))
zipf
.
get_data
(
'EGG-INFO/PKG-INFO'
).
decode
(
'utf8'
))
self
.
metadata
=
Metadata
(
fileobj
=
fileobj
)
self
.
metadata
=
Metadata
(
fileobj
=
fileobj
)
try
:
try
:
...
...
Lib/packaging/dist.py
View file @
becf1c58
...
@@ -537,7 +537,7 @@ Common commands: (see '--help-commands' for more)
...
@@ -537,7 +537,7 @@ Common commands: (see '--help-commands' for more)
def
_get_command_groups
(
self
):
def
_get_command_groups
(
self
):
"""Helper function to retrieve all the command class names divided
"""Helper function to retrieve all the command class names divided
into standard commands (listed in
into standard commands (listed in
packaging
2
.command.STANDARD_COMMANDS) and extra commands (given in
packaging.command.STANDARD_COMMANDS) and extra commands (given in
self.cmdclass and not standard commands).
self.cmdclass and not standard commands).
"""
"""
extra_commands
=
[
cmd
for
cmd
in
self
.
cmdclass
extra_commands
=
[
cmd
for
cmd
in
self
.
cmdclass
...
@@ -547,7 +547,7 @@ Common commands: (see '--help-commands' for more)
...
@@ -547,7 +547,7 @@ Common commands: (see '--help-commands' for more)
def
print_commands
(
self
):
def
print_commands
(
self
):
"""Print out a help message listing all available commands with a
"""Print out a help message listing all available commands with a
description of each. The list is divided into standard commands
description of each. The list is divided into standard commands
(listed in packaging
2
.command.STANDARD_COMMANDS) and extra commands
(listed in packaging.command.STANDARD_COMMANDS) and extra commands
(given in self.cmdclass and not standard commands). The
(given in self.cmdclass and not standard commands). The
descriptions come from the command class attribute
descriptions come from the command class attribute
'description'.
'description'.
...
...
Lib/packaging/metadata.py
View file @
becf1c58
...
@@ -552,16 +552,17 @@ class Metadata:
...
@@ -552,16 +552,17 @@ class Metadata:
return
data
return
data
# Mapping API
# Mapping API
# XXX these methods should return views or sets in 3.x
def
keys
(
self
):
def
keys
(
self
):
return
_version2fieldlist
(
self
[
'Metadata-Version'
]
)
return
list
(
_version2fieldlist
(
self
[
'Metadata-Version'
])
)
def
__iter__
(
self
):
def
__iter__
(
self
):
for
key
in
self
.
keys
():
for
key
in
self
.
keys
():
yield
key
yield
key
def
values
(
self
):
def
values
(
self
):
return
[
self
[
key
]
for
key
in
list
(
self
.
keys
()
)]
return
[
self
[
key
]
for
key
in
self
.
keys
(
)]
def
items
(
self
):
def
items
(
self
):
return
[(
key
,
self
[
key
])
for
key
in
list
(
self
.
keys
()
)]
return
[(
key
,
self
[
key
])
for
key
in
self
.
keys
(
)]
Lib/packaging/pypi/simple.py
View file @
becf1c58
...
@@ -28,7 +28,6 @@ from packaging.pypi.errors import (PackagingPyPIError, DownloadError,
...
@@ -28,7 +28,6 @@ from packaging.pypi.errors import (PackagingPyPIError, DownloadError,
UnableToDownload
,
CantParseArchiveName
,
UnableToDownload
,
CantParseArchiveName
,
ReleaseNotFound
,
ProjectNotFound
)
ReleaseNotFound
,
ProjectNotFound
)
from
packaging.pypi.mirrors
import
get_mirrors
from
packaging.pypi.mirrors
import
get_mirrors
from
packaging.metadata
import
Metadata
__all__
=
[
'Crawler'
,
'DEFAULT_SIMPLE_INDEX_URL'
]
__all__
=
[
'Crawler'
,
'DEFAULT_SIMPLE_INDEX_URL'
]
...
...
Lib/packaging/tests/__init__.py
View file @
becf1c58
...
@@ -6,17 +6,15 @@ packaging.tests package. Each test module has a name starting with
...
@@ -6,17 +6,15 @@ packaging.tests package. Each test module has a name starting with
to return an initialized unittest.TestSuite instance.
to return an initialized unittest.TestSuite instance.
Utility code is included in packaging.tests.support.
Utility code is included in packaging.tests.support.
"""
# Put this text back for the backport
Always import unittest from this module: it will be unittest from the
#Always import unittest from this module, it will be the right version
standard library for packaging tests and unittest2 for distutils2 tests.
#(standard library unittest for 3.2 and higher, third-party unittest2
"""
#elease for older versions).
import
os
import
os
import
sys
import
sys
import
unittest
import
unittest
from
test.support
import
TESTFN
from
io
import
StringIO
# XXX move helpers to support, add tests for them, remove things that
# XXX move helpers to support, add tests for them, remove things that
# duplicate test.support (or keep them for the backport; needs thinking)
# duplicate test.support (or keep them for the backport; needs thinking)
...
@@ -115,9 +113,8 @@ def reap_children():
...
@@ -115,9 +113,8 @@ def reap_children():
def
captured_stdout
(
func
,
*
args
,
**
kw
):
def
captured_stdout
(
func
,
*
args
,
**
kw
):
import
io
orig_stdout
=
getattr
(
sys
,
'stdout'
)
orig_stdout
=
getattr
(
sys
,
'stdout'
)
setattr
(
sys
,
'stdout'
,
io
.
StringIO
())
setattr
(
sys
,
'stdout'
,
StringIO
())
try
:
try
:
res
=
func
(
*
args
,
**
kw
)
res
=
func
(
*
args
,
**
kw
)
sys
.
stdout
.
seek
(
0
)
sys
.
stdout
.
seek
(
0
)
...
...
Lib/packaging/tests/__main__.py
View file @
becf1c58
...
@@ -14,6 +14,8 @@ def test_main():
...
@@ -14,6 +14,8 @@ def test_main():
start_dir
=
os
.
path
.
dirname
(
__file__
)
start_dir
=
os
.
path
.
dirname
(
__file__
)
top_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
start_dir
))
top_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
start_dir
))
test_loader
=
unittest
.
TestLoader
()
test_loader
=
unittest
.
TestLoader
()
# XXX find out how to use unittest.main, to get command-line options
# (failfast, catch, etc.)
run_unittest
(
test_loader
.
discover
(
start_dir
,
top_level_dir
=
top_dir
))
run_unittest
(
test_loader
.
discover
(
start_dir
,
top_level_dir
=
top_dir
))
finally
:
finally
:
reap_children
()
reap_children
()
...
...
Lib/packaging/tests/pypi_server.py
View file @
becf1c58
...
@@ -40,6 +40,7 @@ from xmlrpc.server import SimpleXMLRPCServer
...
@@ -40,6 +40,7 @@ from xmlrpc.server import SimpleXMLRPCServer
from
packaging.tests
import
unittest
from
packaging.tests
import
unittest
PYPI_DEFAULT_STATIC_PATH
=
os
.
path
.
join
(
PYPI_DEFAULT_STATIC_PATH
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'pypiserver'
)
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'pypiserver'
)
...
@@ -219,7 +220,7 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
...
@@ -219,7 +220,7 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
relative_path
+=
"index.html"
relative_path
+=
"index.html"
if
relative_path
.
endswith
(
'.tar.gz'
):
if
relative_path
.
endswith
(
'.tar.gz'
):
with
open
(
fs_path
+
relative_path
,
'
br
'
)
as
file
:
with
open
(
fs_path
+
relative_path
,
'
rb
'
)
as
file
:
data
=
file
.
read
()
data
=
file
.
read
()
headers
=
[(
'Content-type'
,
'application/x-gtar'
)]
headers
=
[(
'Content-type'
,
'application/x-gtar'
)]
else
:
else
:
...
@@ -260,8 +261,8 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
...
@@ -260,8 +261,8 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
self
.
send_header
(
header
,
value
)
self
.
send_header
(
header
,
value
)
self
.
end_headers
()
self
.
end_headers
()
if
type
(
data
)
is
str
:
if
isinstance
(
data
,
str
)
:
data
=
data
.
encode
()
data
=
data
.
encode
(
'utf-8'
)
self
.
wfile
.
write
(
data
)
self
.
wfile
.
write
(
data
)
...
...
Lib/packaging/tests/test_command_bdist_dumb.py
View file @
becf1c58
...
@@ -35,7 +35,7 @@ class BuildDumbTestCase(support.TempdirManager,
...
@@ -35,7 +35,7 @@ class BuildDumbTestCase(support.TempdirManager,
dist
=
Distribution
({
'name'
:
'foo'
,
'version'
:
'0.1'
,
dist
=
Distribution
({
'name'
:
'foo'
,
'version'
:
'0.1'
,
'py_modules'
:
[
'foo'
],
'py_modules'
:
[
'foo'
],
'home
-
page'
:
'xxx'
,
'author'
:
'xxx'
,
'home
_
page'
:
'xxx'
,
'author'
:
'xxx'
,
'author_email'
:
'xxx'
})
'author_email'
:
'xxx'
})
os
.
chdir
(
pkg_dir
)
os
.
chdir
(
pkg_dir
)
cmd
=
bdist_dumb
(
dist
)
cmd
=
bdist_dumb
(
dist
)
...
...
Lib/packaging/tests/test_command_build_ext.py
View file @
becf1c58
...
@@ -9,8 +9,8 @@ from packaging.errors import (UnknownFileError, CompileError,
...
@@ -9,8 +9,8 @@ from packaging.errors import (UnknownFileError, CompileError,
PackagingPlatformError
)
PackagingPlatformError
)
from
packaging.command.build_ext
import
build_ext
from
packaging.command.build_ext
import
build_ext
from
packaging.compiler.extension
import
Extension
from
packaging.compiler.extension
import
Extension
from
test.script_helper
import
assert_python_ok
from
test.script_helper
import
assert_python_ok
from
packaging.tests
import
support
,
unittest
,
verbose
from
packaging.tests
import
support
,
unittest
,
verbose
...
@@ -18,18 +18,13 @@ class BuildExtTestCase(support.TempdirManager,
...
@@ -18,18 +18,13 @@ class BuildExtTestCase(support.TempdirManager,
support
.
LoggingCatcher
,
support
.
LoggingCatcher
,
unittest
.
TestCase
):
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
# Create a simple test environment
# Note that we're making changes to sys.path
super
(
BuildExtTestCase
,
self
).
setUp
()
super
(
BuildExtTestCase
,
self
).
setUp
()
self
.
tmp_dir
=
self
.
mkdtemp
()
self
.
tmp_dir
=
self
.
mkdtemp
()
self
.
old_user_base
=
site
.
USER_BASE
self
.
old_user_base
=
site
.
USER_BASE
site
.
USER_BASE
=
self
.
mkdtemp
()
site
.
USER_BASE
=
self
.
mkdtemp
()
def
tearDown
(
self
):
def
tearDown
(
self
):
# Get everything back to normal
if
sys
.
version
>
"2.6"
:
site
.
USER_BASE
=
self
.
old_user_base
site
.
USER_BASE
=
self
.
old_user_base
super
(
BuildExtTestCase
,
self
).
tearDown
()
super
(
BuildExtTestCase
,
self
).
tearDown
()
def
test_build_ext
(
self
):
def
test_build_ext
(
self
):
...
@@ -78,23 +73,21 @@ class BuildExtTestCase(support.TempdirManager,
...
@@ -78,23 +73,21 @@ class BuildExtTestCase(support.TempdirManager,
old
=
sys
.
platform
old
=
sys
.
platform
sys
.
platform
=
'sunos'
# fooling finalize_options
sys
.
platform
=
'sunos'
# fooling finalize_options
from
sysconfig
import
_CONFIG_VARS
old_var
=
_CONFIG_VARS
.
get
(
'Py_ENABLE_SHARED'
)
old_var
=
sysconfig
.
get_config_var
(
'Py_ENABLE_SHARED'
)
_CONFIG_VARS
[
'Py_ENABLE_SHARED'
]
=
1
sysconfig
.
_CONFIG_VARS
[
'Py_ENABLE_SHARED'
]
=
1
try
:
try
:
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
finally
:
finally
:
sys
.
platform
=
old
sys
.
platform
=
old
if
old_var
is
None
:
if
old_var
is
None
:
del
_CONFIG_VARS
[
'Py_ENABLE_SHARED'
]
del
sysconfig
.
_CONFIG_VARS
[
'Py_ENABLE_SHARED'
]
else
:
else
:
_CONFIG_VARS
[
'Py_ENABLE_SHARED'
]
=
old_var
sysconfig
.
_CONFIG_VARS
[
'Py_ENABLE_SHARED'
]
=
old_var
# make sure we get some library dirs under solaris
# make sure we get some library dirs under solaris
self
.
assertGreater
(
len
(
cmd
.
library_dirs
),
0
)
self
.
assertGreater
(
len
(
cmd
.
library_dirs
),
0
)
@
unittest
.
skipIf
(
sys
.
version
<
'2.6'
,
'requires Python 2.6 or higher'
)
def
test_user_site
(
self
):
def
test_user_site
(
self
):
dist
=
Distribution
({
'name'
:
'xx'
})
dist
=
Distribution
({
'name'
:
'xx'
})
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
...
...
Lib/packaging/tests/test_command_build_py.py
View file @
becf1c58
...
@@ -99,8 +99,6 @@ class BuildPyTestCase(support.TempdirManager,
...
@@ -99,8 +99,6 @@ class BuildPyTestCase(support.TempdirManager,
os
.
chdir
(
cwd
)
os
.
chdir
(
cwd
)
sys
.
stdout
=
old_stdout
sys
.
stdout
=
old_stdout
@
unittest
.
skipUnless
(
hasattr
(
sys
,
'dont_write_bytecode'
),
'sys.dont_write_bytecode not supported'
)
def
test_dont_write_bytecode
(
self
):
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
# makes sure byte_compile is not used
pkg_dir
,
dist
=
self
.
create_dist
()
pkg_dir
,
dist
=
self
.
create_dist
()
...
...
Lib/packaging/tests/test_command_install_dist.py
View file @
becf1c58
...
@@ -72,7 +72,6 @@ class InstallTestCase(support.TempdirManager,
...
@@ -72,7 +72,6 @@ class InstallTestCase(support.TempdirManager,
check_path
(
cmd
.
install_scripts
,
os
.
path
.
join
(
destination
,
"bin"
))
check_path
(
cmd
.
install_scripts
,
os
.
path
.
join
(
destination
,
"bin"
))
check_path
(
cmd
.
install_data
,
destination
)
check_path
(
cmd
.
install_data
,
destination
)
@
unittest
.
skipIf
(
sys
.
version
<
'2.6'
,
'requires Python 2.6 or higher'
)
def
test_user_site
(
self
):
def
test_user_site
(
self
):
# test install with --user
# test install with --user
# preparing the environment for the test
# preparing the environment for the test
...
@@ -173,7 +172,6 @@ class InstallTestCase(support.TempdirManager,
...
@@ -173,7 +172,6 @@ class InstallTestCase(support.TempdirManager,
cmd
.
home
=
'home'
cmd
.
home
=
'home'
self
.
assertRaises
(
PackagingOptionError
,
cmd
.
finalize_options
)
self
.
assertRaises
(
PackagingOptionError
,
cmd
.
finalize_options
)
if
sys
.
version
>=
'2.6'
:
# can't combine user with with prefix/exec_prefix/home or
# can't combine user with with prefix/exec_prefix/home or
# install_(plat)base
# install_(plat)base
cmd
.
prefix
=
None
cmd
.
prefix
=
None
...
...
Lib/packaging/tests/test_command_install_lib.py
View file @
becf1c58
...
@@ -7,13 +7,6 @@ from packaging.command.install_lib import install_lib
...
@@ -7,13 +7,6 @@ from packaging.command.install_lib import install_lib
from
packaging.compiler.extension
import
Extension
from
packaging.compiler.extension
import
Extension
from
packaging.errors
import
PackagingOptionError
from
packaging.errors
import
PackagingOptionError
try
:
no_bytecode
=
sys
.
dont_write_bytecode
bytecode_support
=
True
except
AttributeError
:
no_bytecode
=
False
bytecode_support
=
False
class
InstallLibTestCase
(
support
.
TempdirManager
,
class
InstallLibTestCase
(
support
.
TempdirManager
,
support
.
LoggingCatcher
,
support
.
LoggingCatcher
,
...
@@ -40,7 +33,7 @@ class InstallLibTestCase(support.TempdirManager,
...
@@ -40,7 +33,7 @@ class InstallLibTestCase(support.TempdirManager,
cmd
.
finalize_options
()
cmd
.
finalize_options
()
self
.
assertEqual
(
cmd
.
optimize
,
2
)
self
.
assertEqual
(
cmd
.
optimize
,
2
)
@
unittest
.
skipIf
(
no_bytecode
,
'byte-compile not support
ed'
)
@
unittest
.
skipIf
(
sys
.
dont_write_bytecode
,
'byte-compile disabl
ed'
)
def
test_byte_compile
(
self
):
def
test_byte_compile
(
self
):
pkg_dir
,
dist
=
self
.
create_dist
()
pkg_dir
,
dist
=
self
.
create_dist
()
cmd
=
install_lib
(
dist
)
cmd
=
install_lib
(
dist
)
...
@@ -89,8 +82,6 @@ class InstallLibTestCase(support.TempdirManager,
...
@@ -89,8 +82,6 @@ class InstallLibTestCase(support.TempdirManager,
# get_input should return 2 elements
# get_input should return 2 elements
self
.
assertEqual
(
len
(
cmd
.
get_inputs
()),
2
)
self
.
assertEqual
(
len
(
cmd
.
get_inputs
()),
2
)
@
unittest
.
skipUnless
(
bytecode_support
,
'sys.dont_write_bytecode not supported'
)
def
test_dont_write_bytecode
(
self
):
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
# makes sure byte_compile is not used
pkg_dir
,
dist
=
self
.
create_dist
()
pkg_dir
,
dist
=
self
.
create_dist
()
...
...
Lib/packaging/tests/test_command_register.py
View file @
becf1c58
...
@@ -99,7 +99,7 @@ class RegisterTestCase(support.TempdirManager,
...
@@ -99,7 +99,7 @@ class RegisterTestCase(support.TempdirManager,
def
_get_cmd
(
self
,
metadata
=
None
):
def
_get_cmd
(
self
,
metadata
=
None
):
if
metadata
is
None
:
if
metadata
is
None
:
metadata
=
{
'home
-
page'
:
'xxx'
,
'author'
:
'xxx'
,
metadata
=
{
'home
_
page'
:
'xxx'
,
'author'
:
'xxx'
,
'author_email'
:
'xxx'
,
'author_email'
:
'xxx'
,
'name'
:
'xxx'
,
'version'
:
'xxx'
}
'name'
:
'xxx'
,
'version'
:
'xxx'
}
pkg_info
,
dist
=
self
.
create_dist
(
**
metadata
)
pkg_info
,
dist
=
self
.
create_dist
(
**
metadata
)
...
...
Lib/packaging/tests/test_command_upload.py
View file @
becf1c58
"""Tests for packaging.command.upload."""
"""Tests for packaging.command.upload."""
import
os
import
os
import
sys
from
packaging.command.upload
import
upload
from
packaging.command.upload
import
upload
from
packaging.dist
import
Distribution
from
packaging.dist
import
Distribution
...
@@ -103,22 +102,23 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
...
@@ -103,22 +102,23 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
command
,
pyversion
,
filename
=
'xxx'
,
'3.3'
,
path
command
,
pyversion
,
filename
=
'xxx'
,
'3.3'
,
path
dist_files
=
[(
command
,
pyversion
,
filename
)]
dist_files
=
[(
command
,
pyversion
,
filename
)]
# lets run it
# let
'
s run it
pkg_dir
,
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)[
1
]
cmd
=
upload
(
dist
)
cmd
=
upload
(
dist
)
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
cmd
.
repository
=
self
.
pypi
.
full_address
cmd
.
repository
=
self
.
pypi
.
full_address
cmd
.
run
()
cmd
.
run
()
# what did we send
?
# what did we send?
handler
,
request_data
=
self
.
pypi
.
requests
[
-
1
]
handler
,
request_data
=
self
.
pypi
.
requests
[
-
1
]
headers
=
handler
.
headers
headers
=
handler
.
headers
#self.assertIn('dédé', str(request_data)
)
self
.
assertIn
(
'dédé'
.
encode
(
'utf-8'
),
request_data
)
self
.
assertIn
(
b'xxx'
,
request_data
)
self
.
assertIn
(
b'xxx'
,
request_data
)
self
.
assertEqual
(
int
(
headers
[
'content-length'
]),
len
(
request_data
))
self
.
assertEqual
(
int
(
headers
[
'content-length'
]),
len
(
request_data
))
self
.
assertLess
(
int
(
headers
[
'content-length'
]),
2500
)
self
.
assertLess
(
int
(
headers
[
'content-length'
]),
2500
)
self
.
assertTrue
(
headers
[
'content-type'
].
startswith
(
'multipart/form-data'
))
self
.
assertTrue
(
headers
[
'content-type'
].
startswith
(
'multipart/form-data'
))
self
.
assertEqual
(
handler
.
command
,
'POST'
)
self
.
assertEqual
(
handler
.
command
,
'POST'
)
self
.
assertNotIn
(
'
\
n
'
,
headers
[
'authorization'
])
self
.
assertNotIn
(
'
\
n
'
,
headers
[
'authorization'
])
...
@@ -132,20 +132,16 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
...
@@ -132,20 +132,16 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
self
.
write_file
(
os
.
path
.
join
(
docs_path
,
"index.html"
),
"yellow"
)
self
.
write_file
(
os
.
path
.
join
(
docs_path
,
"index.html"
),
"yellow"
)
self
.
write_file
(
self
.
rc
,
PYPIRC
)
self
.
write_file
(
self
.
rc
,
PYPIRC
)
# lets run it
# let
'
s run it
pkg_dir
,
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)[
1
]
cmd
=
upload
(
dist
)
cmd
=
upload
(
dist
)
cmd
.
get_finalized_command
(
"build"
).
run
()
cmd
.
get_finalized_command
(
"build"
).
run
()
cmd
.
upload_docs
=
True
cmd
.
upload_docs
=
True
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
cmd
.
repository
=
self
.
pypi
.
full_address
cmd
.
repository
=
self
.
pypi
.
full_address
prev_dir
=
os
.
getcwd
()
try
:
os
.
chdir
(
self
.
tmp_dir
)
os
.
chdir
(
self
.
tmp_dir
)
cmd
.
run
()
cmd
.
run
()
finally
:
os
.
chdir
(
prev_dir
)
handler
,
request_data
=
self
.
pypi
.
requests
[
-
1
]
handler
,
request_data
=
self
.
pypi
.
requests
[
-
1
]
action
,
name
,
content
=
request_data
.
split
(
action
,
name
,
content
=
request_data
.
split
(
...
...
Lib/packaging/tests/test_command_upload_docs.py
View file @
becf1c58
"""Tests for packaging.command.upload_docs."""
"""Tests for packaging.command.upload_docs."""
import
os
import
os
import
sys
import
shutil
import
shutil
import
zipfile
import
zipfile
try
:
try
:
...
@@ -19,7 +18,7 @@ try:
...
@@ -19,7 +18,7 @@ try:
from
packaging.tests.pypi_server
import
PyPIServerTestCase
from
packaging.tests.pypi_server
import
PyPIServerTestCase
except
ImportError
:
except
ImportError
:
threading
=
None
threading
=
None
PyPIServerTestCase
=
object
PyPIServerTestCase
=
unittest
.
TestCase
PYPIRC
=
"""
\
PYPIRC
=
"""
\
...
@@ -52,34 +51,27 @@ class UploadDocsTestCase(support.TempdirManager,
...
@@ -52,34 +51,27 @@ class UploadDocsTestCase(support.TempdirManager,
def
test_default_uploaddir
(
self
):
def
test_default_uploaddir
(
self
):
sandbox
=
self
.
mkdtemp
()
sandbox
=
self
.
mkdtemp
()
previous
=
os
.
getcwd
()
os
.
chdir
(
sandbox
)
os
.
chdir
(
sandbox
)
try
:
os
.
mkdir
(
"build"
)
os
.
mkdir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
self
.
cmd
.
ensure_finalized
()
self
.
cmd
.
ensure_finalized
()
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"docs"
))
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"docs"
))
finally
:
os
.
chdir
(
previous
)
def
test_default_uploaddir_looks_for_doc_also
(
self
):
def
test_default_uploaddir_looks_for_doc_also
(
self
):
sandbox
=
self
.
mkdtemp
()
sandbox
=
self
.
mkdtemp
()
previous
=
os
.
getcwd
()
os
.
chdir
(
sandbox
)
os
.
chdir
(
sandbox
)
try
:
os
.
mkdir
(
"build"
)
os
.
mkdir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
os
.
rename
(
os
.
path
.
join
(
"build"
,
"docs"
),
os
.
path
.
join
(
"build"
,
"doc"
))
os
.
rename
(
os
.
path
.
join
(
"build"
,
"docs"
),
os
.
path
.
join
(
"build"
,
"doc"
))
self
.
cmd
.
ensure_finalized
()
self
.
cmd
.
ensure_finalized
()
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"doc"
))
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"doc"
))
finally
:
os
.
chdir
(
previous
)
def
prepare_sample_dir
(
self
,
sample_dir
=
None
):
def
prepare_sample_dir
(
self
,
sample_dir
=
None
):
if
sample_dir
is
None
:
if
sample_dir
is
None
:
sample_dir
=
self
.
mkdtemp
()
sample_dir
=
self
.
mkdtemp
()
os
.
mkdir
(
os
.
path
.
join
(
sample_dir
,
"docs"
))
os
.
mkdir
(
os
.
path
.
join
(
sample_dir
,
"docs"
))
self
.
write_file
(
os
.
path
.
join
(
sample_dir
,
"docs"
,
"index.html"
),
"Ce mortel ennui"
)
self
.
write_file
(
os
.
path
.
join
(
sample_dir
,
"docs"
,
"index.html"
),
"Ce mortel ennui"
)
self
.
write_file
(
os
.
path
.
join
(
sample_dir
,
"index.html"
),
"Oh la la"
)
self
.
write_file
(
os
.
path
.
join
(
sample_dir
,
"index.html"
),
"Oh la la"
)
return
sample_dir
return
sample_dir
...
@@ -108,9 +100,8 @@ class UploadDocsTestCase(support.TempdirManager,
...
@@ -108,9 +100,8 @@ class UploadDocsTestCase(support.TempdirManager,
self
.
assertTrue
(
handler
.
headers
[
'content-type'
]
self
.
assertTrue
(
handler
.
headers
[
'content-type'
]
.
startswith
(
'multipart/form-data;'
))
.
startswith
(
'multipart/form-data;'
))
action
,
name
,
version
,
content
=
\
action
,
name
,
version
,
content
=
request_data
.
split
(
request_data
.
split
(
"----------------GHSKFJDLGDS7543FJKLFHRE75642756743254"
.
encode
())[
1
:
5
]
b'----------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
)[
1
:
5
]
# check that we picked the right chunks
# check that we picked the right chunks
self
.
assertIn
(
b'name=":action"'
,
action
)
self
.
assertIn
(
b'name=":action"'
,
action
)
...
@@ -126,27 +117,25 @@ class UploadDocsTestCase(support.TempdirManager,
...
@@ -126,27 +117,25 @@ class UploadDocsTestCase(support.TempdirManager,
@
unittest
.
skipIf
(
_ssl
is
None
,
'Needs SSL support'
)
@
unittest
.
skipIf
(
_ssl
is
None
,
'Needs SSL support'
)
def
test_https_connection
(
self
):
def
test_https_connection
(
self
):
https_called
=
False
self
.
https_called
=
False
self
.
addCleanup
(
orig_https
=
upload_docs_mod
.
http
.
client
.
HTTPSConnection
setattr
,
upload_docs_mod
.
http
.
client
,
'HTTPSConnection'
,
upload_docs_mod
.
http
.
client
.
HTTPSConnection
)
def
https_conn_wrapper
(
*
args
):
def
https_conn_wrapper
(
*
args
):
nonlocal
https_called
self
.
https_called
=
True
https_called
=
True
# the testing server is http
# the testing server is http
return
upload_docs_mod
.
http
.
client
.
HTTPConnection
(
*
args
)
return
upload_docs_mod
.
http
.
client
.
HTTPConnection
(
*
args
)
upload_docs_mod
.
http
.
client
.
HTTPSConnection
=
https_conn_wrapper
upload_docs_mod
.
http
.
client
.
HTTPSConnection
=
https_conn_wrapper
try
:
self
.
prepare_command
()
self
.
prepare_command
()
self
.
cmd
.
run
()
self
.
cmd
.
run
()
self
.
assertFalse
(
https_called
)
self
.
assertFalse
(
self
.
https_called
)
self
.
cmd
.
repository
=
self
.
cmd
.
repository
.
replace
(
"http"
,
"https"
)
self
.
cmd
.
repository
=
self
.
cmd
.
repository
.
replace
(
"http"
,
"https"
)
self
.
cmd
.
run
()
self
.
cmd
.
run
()
self
.
assertTrue
(
https_called
)
self
.
assertTrue
(
self
.
https_called
)
finally
:
upload_docs_mod
.
http
.
client
.
HTTPSConnection
=
orig_https
def
test_handling_response
(
self
):
def
test_handling_response
(
self
):
self
.
pypi
.
default_response_status
=
'403 Forbidden'
self
.
pypi
.
default_response_status
=
'403 Forbidden'
...
@@ -155,7 +144,8 @@ class UploadDocsTestCase(support.TempdirManager,
...
@@ -155,7 +144,8 @@ class UploadDocsTestCase(support.TempdirManager,
self
.
assertIn
(
'Upload failed (403): Forbidden'
,
self
.
get_logs
()[
-
1
])
self
.
assertIn
(
'Upload failed (403): Forbidden'
,
self
.
get_logs
()[
-
1
])
self
.
pypi
.
default_response_status
=
'301 Moved Permanently'
self
.
pypi
.
default_response_status
=
'301 Moved Permanently'
self
.
pypi
.
default_response_headers
.
append
((
"Location"
,
"brand_new_location"
))
self
.
pypi
.
default_response_headers
.
append
(
(
"Location"
,
"brand_new_location"
))
self
.
cmd
.
run
()
self
.
cmd
.
run
()
self
.
assertIn
(
'brand_new_location'
,
self
.
get_logs
()[
-
1
])
self
.
assertIn
(
'brand_new_location'
,
self
.
get_logs
()[
-
1
])
...
@@ -185,6 +175,7 @@ class UploadDocsTestCase(support.TempdirManager,
...
@@ -185,6 +175,7 @@ class UploadDocsTestCase(support.TempdirManager,
self
.
assertTrue
(
record
,
"should report the response"
)
self
.
assertTrue
(
record
,
"should report the response"
)
self
.
assertIn
(
self
.
pypi
.
default_response_data
,
record
)
self
.
assertIn
(
self
.
pypi
.
default_response_data
,
record
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
UploadDocsTestCase
)
return
unittest
.
makeSuite
(
UploadDocsTestCase
)
...
...
Lib/packaging/tests/test_create.py
View file @
becf1c58
"""Tests for packaging.create."""
"""Tests for packaging.create."""
import
io
import
os
import
os
import
sys
import
sys
import
sysconfig
import
sysconfig
from
io
import
StringIO
from
textwrap
import
dedent
from
textwrap
import
dedent
from
packaging.create
import
MainProgram
,
ask_yn
,
ask
,
main
from
packaging.create
import
MainProgram
,
ask_yn
,
ask
,
main
...
@@ -20,8 +20,8 @@ class CreateTestCase(support.TempdirManager,
...
@@ -20,8 +20,8 @@ class CreateTestCase(support.TempdirManager,
super
(
CreateTestCase
,
self
).
setUp
()
super
(
CreateTestCase
,
self
).
setUp
()
self
.
_stdin
=
sys
.
stdin
# TODO use Inputs
self
.
_stdin
=
sys
.
stdin
# TODO use Inputs
self
.
_stdout
=
sys
.
stdout
self
.
_stdout
=
sys
.
stdout
sys
.
stdin
=
io
.
StringIO
()
sys
.
stdin
=
StringIO
()
sys
.
stdout
=
io
.
StringIO
()
sys
.
stdout
=
StringIO
()
self
.
_cwd
=
os
.
getcwd
()
self
.
_cwd
=
os
.
getcwd
()
self
.
wdir
=
self
.
mkdtemp
()
self
.
wdir
=
self
.
mkdtemp
()
os
.
chdir
(
self
.
wdir
)
os
.
chdir
(
self
.
wdir
)
...
@@ -135,7 +135,8 @@ class CreateTestCase(support.TempdirManager,
...
@@ -135,7 +135,8 @@ class CreateTestCase(support.TempdirManager,
sys
.
stdin
.
seek
(
0
)
sys
.
stdin
.
seek
(
0
)
main
()
main
()
with
open
(
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
),
encoding
=
'utf-8'
)
as
fp
:
path
=
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
)
with
open
(
path
,
encoding
=
'utf-8'
)
as
fp
:
contents
=
fp
.
read
()
contents
=
fp
.
read
()
self
.
assertEqual
(
contents
,
dedent
(
"""
\
self
.
assertEqual
(
contents
,
dedent
(
"""
\
...
@@ -210,7 +211,9 @@ ho, baby!
...
@@ -210,7 +211,9 @@ ho, baby!
sys
.
stdin
.
seek
(
0
)
sys
.
stdin
.
seek
(
0
)
# FIXME Out of memory error.
# FIXME Out of memory error.
main
()
main
()
with
open
(
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
),
encoding
=
'utf-8'
)
as
fp
:
path
=
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
)
with
open
(
path
,
encoding
=
'utf-8'
)
as
fp
:
contents
=
fp
.
read
()
contents
=
fp
.
read
()
self
.
assertEqual
(
contents
,
dedent
(
"""
\
self
.
assertEqual
(
contents
,
dedent
(
"""
\
...
...
Lib/packaging/tests/test_database.py
View file @
becf1c58
...
@@ -49,8 +49,8 @@ class FakeDistsMixin:
...
@@ -49,8 +49,8 @@ class FakeDistsMixin:
# distributions
# distributions
tmpdir
=
tempfile
.
mkdtemp
()
tmpdir
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
tmpdir
)
self
.
addCleanup
(
shutil
.
rmtree
,
tmpdir
)
self
.
fake_dists_path
=
os
.
path
.
join
(
tmpdir
,
'fake_dists'
)
self
.
fake_dists_path
=
os
.
path
.
realpath
(
self
.
fake_dists_path
=
os
.
path
.
realpath
(
self
.
fake_dists_path
)
os
.
path
.
join
(
tmpdir
,
'fake_dists'
)
)
fake_dists_src
=
os
.
path
.
abspath
(
fake_dists_src
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'fake_dists'
))
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'fake_dists'
))
shutil
.
copytree
(
fake_dists_src
,
self
.
fake_dists_path
)
shutil
.
copytree
(
fake_dists_src
,
self
.
fake_dists_path
)
...
@@ -58,6 +58,7 @@ class FakeDistsMixin:
...
@@ -58,6 +58,7 @@ class FakeDistsMixin:
# back (to avoid getting a read-only copy of a read-only file). we
# back (to avoid getting a read-only copy of a read-only file). we
# could pass a custom copy_function to change the mode of files, but
# could pass a custom copy_function to change the mode of files, but
# shutil gives no control over the mode of directories :(
# shutil gives no control over the mode of directories :(
# see http://bugs.python.org/issue1666318
for
root
,
dirs
,
files
in
os
.
walk
(
self
.
fake_dists_path
):
for
root
,
dirs
,
files
in
os
.
walk
(
self
.
fake_dists_path
):
os
.
chmod
(
root
,
0o755
)
os
.
chmod
(
root
,
0o755
)
for
f
in
files
:
for
f
in
files
:
...
...
Lib/packaging/tests/test_depgraph.py
View file @
becf1c58
"""Tests for packaging.depgraph """
"""Tests for packaging.depgraph """
import
io
import
os
import
os
import
re
import
re
import
sys
import
sys
import
packaging.database
from
io
import
StringIO
from
packaging
import
depgraph
from
packaging
import
depgraph
from
packaging.database
import
get_distribution
,
enable_cache
,
disable_cache
from
packaging.tests
import
unittest
,
support
from
packaging.tests
import
unittest
,
support
from
packaging.tests.support
import
requires_zlib
from
packaging.tests.support
import
requires_zlib
...
@@ -30,13 +31,13 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -30,13 +31,13 @@ class DepGraphTestCase(support.LoggingCatcher,
path = os.path.abspath(path)
path = os.path.abspath(path)
sys.path.insert(0, path)
sys.path.insert(0, path)
self.addCleanup(sys.path.remove, path)
self.addCleanup(sys.path.remove, path)
self.addCleanup(
packaging.database.
enable_cache)
self.addCleanup(enable_cache)
packaging.database.
disable_cache()
disable_cache()
def test_generate_graph(self):
def test_generate_graph(self):
dists = []
dists = []
for name in self.DISTROS_DIST:
for name in self.DISTROS_DIST:
dist =
packaging.database.
get_distribution(name)
dist = get_distribution(name)
self.assertNotEqual(dist, None)
self.assertNotEqual(dist, None)
dists.append(dist)
dists.append(dist)
...
@@ -61,7 +62,7 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -61,7 +62,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def test_generate_graph_egg(self):
def test_generate_graph_egg(self):
dists = []
dists = []
for name in self.DISTROS_DIST + self.DISTROS_EGG:
for name in self.DISTROS_DIST + self.DISTROS_EGG:
dist =
packaging.database.
get_distribution(name, use_egg_info=True)
dist = get_distribution(name, use_egg_info=True)
self.assertNotEqual(dist, None)
self.assertNotEqual(dist, None)
dists.append(dist)
dists.append(dist)
...
@@ -104,7 +105,7 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -104,7 +105,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def test_dependent_dists(self):
def test_dependent_dists(self):
dists = []
dists = []
for name in self.DISTROS_DIST:
for name in self.DISTROS_DIST:
dist =
packaging.database.
get_distribution(name)
dist = get_distribution(name)
self.assertNotEqual(dist, None)
self.assertNotEqual(dist, None)
dists.append(dist)
dists.append(dist)
...
@@ -123,7 +124,7 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -123,7 +124,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def test_dependent_dists_egg(self):
def test_dependent_dists_egg(self):
dists = []
dists = []
for name in self.DISTROS_DIST + self.DISTROS_EGG:
for name in self.DISTROS_DIST + self.DISTROS_EGG:
dist =
packaging.database.
get_distribution(name, use_egg_info=True)
dist = get_distribution(name, use_egg_info=True)
self.assertNotEqual(dist, None)
self.assertNotEqual(dist, None)
dists.append(dist)
dists.append(dist)
...
@@ -158,12 +159,12 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -158,12 +159,12 @@ class DepGraphTestCase(support.LoggingCatcher,
dists = []
dists = []
for name in self.DISTROS_DIST + self.DISTROS_EGG:
for name in self.DISTROS_DIST + self.DISTROS_EGG:
dist =
packaging.database.
get_distribution(name, use_egg_info=True)
dist = get_distribution(name, use_egg_info=True)
self.assertNotEqual(dist, None)
self.assertNotEqual(dist, None)
dists.append(dist)
dists.append(dist)
graph = depgraph.generate_graph(dists)
graph = depgraph.generate_graph(dists)
buf =
io.
StringIO()
buf = StringIO()
depgraph.graph_to_dot(graph, buf)
depgraph.graph_to_dot(graph, buf)
buf.seek(0)
buf.seek(0)
matches = []
matches = []
...
@@ -189,12 +190,12 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -189,12 +190,12 @@ class DepGraphTestCase(support.LoggingCatcher,
dists = []
dists = []
for name in self.DISTROS_DIST + self.DISTROS_EGG:
for name in self.DISTROS_DIST + self.DISTROS_EGG:
dist =
packaging.database.
get_distribution(name, use_egg_info=True)
dist = get_distribution(name, use_egg_info=True)
self.assertNotEqual(dist, None)
self.assertNotEqual(dist, None)
dists.append(dist)
dists.append(dist)
graph = depgraph.generate_graph(dists)
graph = depgraph.generate_graph(dists)
buf =
io.
StringIO()
buf = StringIO()
depgraph.graph_to_dot(graph, buf, skip_disconnected=False)
depgraph.graph_to_dot(graph, buf, skip_disconnected=False)
buf.seek(0)
buf.seek(0)
lines = buf.readlines()
lines = buf.readlines()
...
@@ -250,12 +251,12 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -250,12 +251,12 @@ class DepGraphTestCase(support.LoggingCatcher,
dists
=
[]
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
+
self
.
BAD_EGGS
:
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
+
self
.
BAD_EGGS
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
dists
.
append
(
dist
)
graph
=
depgraph
.
generate_graph
(
dists
)
graph
=
depgraph
.
generate_graph
(
dists
)
buf
=
io
.
StringIO
()
buf
=
StringIO
()
depgraph
.
graph_to_dot
(
graph
,
buf
)
depgraph
.
graph_to_dot
(
graph
,
buf
)
buf
.
seek
(
0
)
buf
.
seek
(
0
)
matches
=
[]
matches
=
[]
...
@@ -273,7 +274,7 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -273,7 +274,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def
test_repr
(
self
):
def
test_repr
(
self
):
dists
=
[]
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
+
self
.
BAD_EGGS
:
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
+
self
.
BAD_EGGS
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
dists
.
append
(
dist
)
...
@@ -282,7 +283,7 @@ class DepGraphTestCase(support.LoggingCatcher,
...
@@ -282,7 +283,7 @@ class DepGraphTestCase(support.LoggingCatcher,
@
requires_zlib
@
requires_zlib
def
test_main
(
self
):
def
test_main
(
self
):
tempout
=
io
.
StringIO
()
tempout
=
StringIO
()
old
=
sys
.
stdout
old
=
sys
.
stdout
sys
.
stdout
=
tempout
sys
.
stdout
=
tempout
oldargv
=
sys
.
argv
[:]
oldargv
=
sys
.
argv
[:]
...
...
Lib/packaging/tests/test_dist.py
View file @
becf1c58
...
@@ -3,13 +3,14 @@ import os
...
@@ -3,13 +3,14 @@ import os
import
sys
import
sys
import
logging
import
logging
import
textwrap
import
textwrap
import
packaging.dist
import
packaging.dist
from
packaging.dist
import
Distribution
from
packaging.dist
import
Distribution
from
packaging.command
import
set_command
from
packaging.command
import
set_command
from
packaging.command.cmd
import
Command
from
packaging.command.cmd
import
Command
from
packaging.errors
import
PackagingModuleError
,
PackagingOptionError
from
packaging.errors
import
PackagingModuleError
,
PackagingOptionError
from
packaging.tests
import
TESTFN
,
captured_stdout
from
packaging.tests
import
captured_stdout
from
packaging.tests
import
support
,
unittest
from
packaging.tests
import
support
,
unittest
from
packaging.tests.support
import
create_distribution
from
packaging.tests.support
import
create_distribution
from
test.support
import
unload
from
test.support
import
unload
...
@@ -48,12 +49,13 @@ class DistributionTestCase(support.TempdirManager,
...
@@ -48,12 +49,13 @@ class DistributionTestCase(support.TempdirManager,
@
unittest
.
skip
(
'needs to be updated'
)
@
unittest
.
skip
(
'needs to be updated'
)
def
test_debug_mode
(
self
):
def
test_debug_mode
(
self
):
self
.
addCleanup
(
os
.
unlink
,
TESTFN
)
tmpdir
=
self
.
mkdtemp
()
with
open
(
TESTFN
,
"w"
)
as
f
:
setupcfg
=
os
.
path
.
join
(
tmpdir
,
'setup.cfg'
)
with
open
(
setupcfg
,
"w"
)
as
f
:
f
.
write
(
"[global]
\
n
"
)
f
.
write
(
"[global]
\
n
"
)
f
.
write
(
"command_packages = foo.bar, splat"
)
f
.
write
(
"command_packages = foo.bar, splat"
)
files
=
[
TESTFN
]
files
=
[
setupcfg
]
sys
.
argv
.
append
(
"build"
)
sys
.
argv
.
append
(
"build"
)
__
,
stdout
=
captured_stdout
(
create_distribution
,
files
)
__
,
stdout
=
captured_stdout
(
create_distribution
,
files
)
self
.
assertEqual
(
stdout
,
''
)
self
.
assertEqual
(
stdout
,
''
)
...
@@ -70,7 +72,7 @@ class DistributionTestCase(support.TempdirManager,
...
@@ -70,7 +72,7 @@ class DistributionTestCase(support.TempdirManager,
Distribution
(
attrs
=
{
'author'
:
'xxx'
,
Distribution
(
attrs
=
{
'author'
:
'xxx'
,
'name'
:
'xxx'
,
'name'
:
'xxx'
,
'version'
:
'1.2'
,
'version'
:
'1.2'
,
'home
-
page'
:
'xxxx'
,
'home
_
page'
:
'xxxx'
,
'badoptname'
:
'xxx'
})
'badoptname'
:
'xxx'
})
logs
=
self
.
get_logs
(
logging
.
WARNING
)
logs
=
self
.
get_logs
(
logging
.
WARNING
)
self
.
assertEqual
(
len
(
logs
),
1
)
self
.
assertEqual
(
len
(
logs
),
1
)
...
@@ -80,7 +82,7 @@ class DistributionTestCase(support.TempdirManager,
...
@@ -80,7 +82,7 @@ class DistributionTestCase(support.TempdirManager,
# an empty options dictionary should not stay in the
# an empty options dictionary should not stay in the
# list of attributes
# list of attributes
dist
=
Distribution
(
attrs
=
{
'author'
:
'xxx'
,
'name'
:
'xxx'
,
dist
=
Distribution
(
attrs
=
{
'author'
:
'xxx'
,
'name'
:
'xxx'
,
'version'
:
'1.2'
,
'home
-
page'
:
'xxxx'
,
'version'
:
'1.2'
,
'home
_
page'
:
'xxxx'
,
'options'
:
{}})
'options'
:
{}})
self
.
assertEqual
([],
self
.
get_logs
(
logging
.
WARNING
))
self
.
assertEqual
([],
self
.
get_logs
(
logging
.
WARNING
))
...
@@ -97,7 +99,7 @@ class DistributionTestCase(support.TempdirManager,
...
@@ -97,7 +99,7 @@ class DistributionTestCase(support.TempdirManager,
dist
=
Distribution
(
attrs
=
{
'author'
:
'xxx'
,
dist
=
Distribution
(
attrs
=
{
'author'
:
'xxx'
,
'name'
:
'xxx'
,
'name'
:
'xxx'
,
'version'
:
'xxx'
,
'version'
:
'xxx'
,
'home
-
page'
:
'xxxx'
,
'home
_
page'
:
'xxxx'
,
'options'
:
{
'sdist'
:
{
'owner'
:
'root'
}}})
'options'
:
{
'sdist'
:
{
'owner'
:
'root'
}}})
self
.
assertIn
(
'owner'
,
dist
.
get_option_dict
(
'sdist'
))
self
.
assertIn
(
'owner'
,
dist
.
get_option_dict
(
'sdist'
))
...
...
Lib/packaging/tests/test_install.py
View file @
becf1c58
"""Tests for the packaging.install module."""
"""Tests for the packaging.install module."""
import
os
import
os
import
logging
import
logging
from
sysconfig
import
is_python_build
from
tempfile
import
mkstemp
from
tempfile
import
mkstemp
from
sysconfig
import
is_python_build
from
packaging
import
install
from
packaging
import
install
from
packaging.pypi.xmlrpc
import
Client
from
packaging.pypi.xmlrpc
import
Client
...
...
Lib/packaging/tests/test_metadata.py
View file @
becf1c58
...
@@ -101,7 +101,7 @@ class MetadataTestCase(LoggingCatcher,
...
@@ -101,7 +101,7 @@ class MetadataTestCase(LoggingCatcher,
# XXX caveat: the keys method and friends are not 3.x-style views
# XXX caveat: the keys method and friends are not 3.x-style views
# should be changed or documented
# should be changed or documented
self
.
assertEqual
(
list
(
metadata
),
list
(
metadata
.
keys
()
))
self
.
assertEqual
(
list
(
metadata
),
metadata
.
keys
(
))
def
test_read_metadata
(
self
):
def
test_read_metadata
(
self
):
fields
=
{
'name'
:
'project'
,
fields
=
{
'name'
:
'project'
,
...
@@ -301,7 +301,7 @@ class MetadataTestCase(LoggingCatcher,
...
@@ -301,7 +301,7 @@ class MetadataTestCase(LoggingCatcher,
Metadata
(
mapping
=
{
'author'
:
'xxx'
,
Metadata
(
mapping
=
{
'author'
:
'xxx'
,
'name'
:
'xxx'
,
'name'
:
'xxx'
,
'version'
:
'xxx'
,
'version'
:
'xxx'
,
'home
-
page'
:
'xxxx'
})
'home
_
page'
:
'xxxx'
})
logs
=
self
.
get_logs
(
logging
.
WARNING
)
logs
=
self
.
get_logs
(
logging
.
WARNING
)
self
.
assertEqual
(
1
,
len
(
logs
))
self
.
assertEqual
(
1
,
len
(
logs
))
self
.
assertIn
(
'not a valid version'
,
logs
[
0
])
self
.
assertIn
(
'not a valid version'
,
logs
[
0
])
...
...
Lib/packaging/tests/test_mixin2to3.py
View file @
becf1c58
...
@@ -9,7 +9,6 @@ class Mixin2to3TestCase(support.TempdirManager,
...
@@ -9,7 +9,6 @@ class Mixin2to3TestCase(support.TempdirManager,
support
.
LoggingCatcher
,
support
.
LoggingCatcher
,
unittest
.
TestCase
):
unittest
.
TestCase
):
@
unittest
.
skipIf
(
sys
.
version
<
'2.6'
,
'requires Python 2.6 or higher'
)
def
test_convert_code_only
(
self
):
def
test_convert_code_only
(
self
):
# used to check if code gets converted properly.
# used to check if code gets converted properly.
code
=
"print 'test'"
code
=
"print 'test'"
...
@@ -26,7 +25,6 @@ class Mixin2to3TestCase(support.TempdirManager,
...
@@ -26,7 +25,6 @@ class Mixin2to3TestCase(support.TempdirManager,
self
.
assertEqual
(
expected
,
converted
)
self
.
assertEqual
(
expected
,
converted
)
@
unittest
.
skipIf
(
sys
.
version
<
'2.6'
,
'requires Python 2.6 or higher'
)
def
test_doctests_only
(
self
):
def
test_doctests_only
(
self
):
# used to check if doctests gets converted properly.
# used to check if doctests gets converted properly.
doctest
=
textwrap
.
dedent
(
'''
\
doctest
=
textwrap
.
dedent
(
'''
\
...
@@ -57,7 +55,6 @@ class Mixin2to3TestCase(support.TempdirManager,
...
@@ -57,7 +55,6 @@ class Mixin2to3TestCase(support.TempdirManager,
self
.
assertEqual
(
expected
,
converted
)
self
.
assertEqual
(
expected
,
converted
)
@
unittest
.
skipIf
(
sys
.
version
<
'2.6'
,
'requires Python 2.6 or higher'
)
def
test_additional_fixers
(
self
):
def
test_additional_fixers
(
self
):
# used to check if use_2to3_fixers works
# used to check if use_2to3_fixers works
code
=
'type(x) is not T'
code
=
'type(x) is not T'
...
...
Lib/packaging/tests/test_pypi_server.py
View file @
becf1c58
"""Tests for packaging.command.bdist."""
"""Tests for packaging.command.bdist."""
import
sys
import
urllib.request
import
urllib.request
import
urllib.parse
import
urllib.parse
import
urllib.error
import
urllib.error
try
:
try
:
import
threading
import
threading
from
packaging.tests.pypi_server
import
PyPIServer
,
PYPI_DEFAULT_STATIC_PATH
from
packaging.tests.pypi_server
import
(
PyPIServer
,
PYPI_DEFAULT_STATIC_PATH
)
except
ImportError
:
except
ImportError
:
threading
=
None
threading
=
None
PyPIServer
=
None
PyPIServer
=
None
...
@@ -32,18 +31,19 @@ class PyPIServerTest(unittest.TestCase):
...
@@ -32,18 +31,19 @@ class PyPIServerTest(unittest.TestCase):
headers
=
{
"X-test-header"
:
"Mister Iceberg"
}
headers
=
{
"X-test-header"
:
"Mister Iceberg"
}
request
=
urllib
.
request
.
Request
(
server
.
full_address
,
data
,
headers
)
request
=
urllib
.
request
.
Request
(
server
.
full_address
,
data
,
headers
)
urllib
.
request
.
urlopen
(
request
)
urllib
.
request
.
urlopen
(
request
)
self
.
assertEqual
(
len
(
server
.
requests
),
1
)
self
.
assertEqual
(
len
(
server
.
requests
),
1
)
handler
,
request_data
=
server
.
requests
[
-
1
]
handler
,
request_data
=
server
.
requests
[
-
1
]
self
.
assertIn
(
data
,
request_data
)
self
.
assertIn
(
data
,
request_data
)
self
.
assertIn
(
"x-test-header"
,
handler
.
headers
)
self
.
assertIn
(
"x-test-header"
,
handler
.
headers
)
self
.
assertEqual
(
handler
.
headers
[
"x-test-header"
],
"Mister Iceberg"
)
self
.
assertEqual
(
handler
.
headers
[
"x-test-header"
],
"Mister Iceberg"
)
finally
:
finally
:
server
.
stop
()
server
.
stop
()
def
test_serve_static_content
(
self
):
def
test_serve_static_content
(
self
):
# PYPI Mocked server can serve static content from disk.
# PYPI Mocked server can serve static content from disk.
...
@@ -74,7 +74,8 @@ class PyPIServerTest(unittest.TestCase):
...
@@ -74,7 +74,8 @@ class PyPIServerTest(unittest.TestCase):
self
.
assertTrue
(
uses_local_files_for
(
server
,
"/simple/index.html"
))
self
.
assertTrue
(
uses_local_files_for
(
server
,
"/simple/index.html"
))
# and another one in another root path
# and another one in another root path
self
.
assertTrue
(
uses_local_files_for
(
server
,
"/external/index.html"
))
self
.
assertTrue
(
uses_local_files_for
(
server
,
"/external/index.html"
))
finally
:
finally
:
server
.
stop
()
server
.
stop
()
...
...
Lib/packaging/tests/test_run.py
View file @
becf1c58
...
@@ -2,11 +2,10 @@
...
@@ -2,11 +2,10 @@
import
os
import
os
import
sys
import
sys
import
shutil
from
io
import
StringIO
from
io
import
StringIO
from
packaging
import
install
from
packaging
import
install
from
packaging.tests
import
unittest
,
support
,
TESTFN
from
packaging.tests
import
unittest
,
support
from
packaging.run
import
main
from
packaging.run
import
main
from
test.script_helper
import
assert_python_ok
from
test.script_helper
import
assert_python_ok
...
@@ -35,28 +34,14 @@ class RunTestCase(support.TempdirManager,
...
@@ -35,28 +34,14 @@ class RunTestCase(support.TempdirManager,
def
setUp
(
self
):
def
setUp
(
self
):
super
(
RunTestCase
,
self
).
setUp
()
super
(
RunTestCase
,
self
).
setUp
()
self
.
old_stdout
=
sys
.
stdout
self
.
old_stdout
=
sys
.
stdout
self
.
cleanup_testfn
()
self
.
old_argv
=
sys
.
argv
,
sys
.
argv
[:]
self
.
old_argv
=
sys
.
argv
,
sys
.
argv
[:]
def
tearDown
(
self
):
def
tearDown
(
self
):
sys
.
stdout
=
self
.
old_stdout
sys
.
stdout
=
self
.
old_stdout
self
.
cleanup_testfn
()
sys
.
argv
=
self
.
old_argv
[
0
]
sys
.
argv
=
self
.
old_argv
[
0
]
sys
.
argv
[:]
=
self
.
old_argv
[
1
]
sys
.
argv
[:]
=
self
.
old_argv
[
1
]
super
(
RunTestCase
,
self
).
tearDown
()
super
(
RunTestCase
,
self
).
tearDown
()
def
cleanup_testfn
(
self
):
path
=
TESTFN
if
os
.
path
.
isfile
(
path
):
os
.
remove
(
path
)
elif
os
.
path
.
isdir
(
path
):
shutil
.
rmtree
(
path
)
def
write_setup
(
self
,
text
,
path
=
TESTFN
):
with
open
(
path
,
"w"
)
as
fp
:
fp
.
write
(
text
)
return
path
# TODO restore the tests removed six months ago and port them to pysetup
# TODO restore the tests removed six months ago and port them to pysetup
def
test_install
(
self
):
def
test_install
(
self
):
...
...
Lib/packaging/tests/test_util.py
View file @
becf1c58
...
@@ -15,7 +15,7 @@ from packaging.errors import (
...
@@ -15,7 +15,7 @@ from packaging.errors import (
from
packaging
import
util
from
packaging
import
util
from
packaging.dist
import
Distribution
from
packaging.dist
import
Distribution
from
packaging.util
import
(
from
packaging.util
import
(
convert_path
,
change_root
,
split_quoted
,
strtobool
,
convert_path
,
change_root
,
split_quoted
,
strtobool
,
run_2to3
,
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
,
...
@@ -319,8 +319,6 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -319,8 +319,6 @@ class UtilTestCase(support.EnvironRestorer,
res
=
get_compiler_versions
()
res
=
get_compiler_versions
()
self
.
assertEqual
(
res
[
2
],
None
)
self
.
assertEqual
(
res
[
2
],
None
)
@
unittest
.
skipUnless
(
hasattr
(
sys
,
'dont_write_bytecode'
),
'sys.dont_write_bytecode not supported'
)
def
test_dont_write_bytecode
(
self
):
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile raise a PackagingError
# makes sure byte_compile raise a PackagingError
# if sys.dont_write_bytecode is True
# if sys.dont_write_bytecode is True
...
@@ -407,7 +405,6 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -407,7 +405,6 @@ class UtilTestCase(support.EnvironRestorer,
finally
:
finally
:
sys
.
path
.
remove
(
tmp_dir
)
sys
.
path
.
remove
(
tmp_dir
)
@
unittest
.
skipIf
(
sys
.
version
<
'2.6'
,
'requires Python 2.6 or higher'
)
def
test_run_2to3_on_code
(
self
):
def
test_run_2to3_on_code
(
self
):
content
=
"print 'test'"
content
=
"print 'test'"
converted_content
=
"print('test')"
converted_content
=
"print('test')"
...
@@ -416,13 +413,11 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -416,13 +413,11 @@ class UtilTestCase(support.EnvironRestorer,
file_handle
.
write
(
content
)
file_handle
.
write
(
content
)
file_handle
.
flush
()
file_handle
.
flush
()
file_handle
.
seek
(
0
)
file_handle
.
seek
(
0
)
from
packaging.util
import
run_2to3
run_2to3
([
file_name
])
run_2to3
([
file_name
])
new_content
=
""
.
join
(
file_handle
.
read
())
new_content
=
""
.
join
(
file_handle
.
read
())
file_handle
.
close
()
file_handle
.
close
()
self
.
assertEqual
(
new_content
,
converted_content
)
self
.
assertEqual
(
new_content
,
converted_content
)
@
unittest
.
skipIf
(
sys
.
version
<
'2.6'
,
'requires Python 2.6 or higher'
)
def
test_run_2to3_on_doctests
(
self
):
def
test_run_2to3_on_doctests
(
self
):
# to check if text files containing doctests only get converted.
# to check if text files containing doctests only get converted.
content
=
">>> print 'test'
\
n
test
\
n
"
content
=
">>> print 'test'
\
n
test
\
n
"
...
@@ -432,7 +427,6 @@ class UtilTestCase(support.EnvironRestorer,
...
@@ -432,7 +427,6 @@ class UtilTestCase(support.EnvironRestorer,
file_handle
.
write
(
content
)
file_handle
.
write
(
content
)
file_handle
.
flush
()
file_handle
.
flush
()
file_handle
.
seek
(
0
)
file_handle
.
seek
(
0
)
from
packaging.util
import
run_2to3
run_2to3
([
file_name
],
doctests_only
=
True
)
run_2to3
([
file_name
],
doctests_only
=
True
)
new_content
=
""
.
join
(
file_handle
.
readlines
())
new_content
=
""
.
join
(
file_handle
.
readlines
())
file_handle
.
close
()
file_handle
.
close
()
...
...
Lib/packaging/util.py
View file @
becf1c58
...
@@ -326,7 +326,7 @@ def byte_compile(py_files, optimize=0, force=False, prefix=None,
...
@@ -326,7 +326,7 @@ def byte_compile(py_files, optimize=0, force=False, prefix=None,
"""
"""
# nothing is done if sys.dont_write_bytecode is True
# nothing is done if sys.dont_write_bytecode is True
# FIXME this should not raise an error
# FIXME this should not raise an error
if
hasattr
(
sys
,
'dont_write_bytecode'
)
and
sys
.
dont_write_bytecode
:
if
sys
.
dont_write_bytecode
:
raise
PackagingByteCompileError
(
'byte-compiling is disabled.'
)
raise
PackagingByteCompileError
(
'byte-compiling is disabled.'
)
# First, if the caller didn't force us into direct or indirect mode,
# First, if the caller didn't force us into direct or indirect mode,
...
@@ -346,8 +346,10 @@ def byte_compile(py_files, optimize=0, force=False, prefix=None,
...
@@ -346,8 +346,10 @@ def byte_compile(py_files, optimize=0, force=False, prefix=None,
# run it with the appropriate flags.
# run it with the appropriate flags.
if
not
direct
:
if
not
direct
:
from
tempfile
import
mkstemp
from
tempfile
import
mkstemp
# XXX
script_fd may leak,
use something better than mkstemp
# XXX use something better than mkstemp
script_fd
,
script_name
=
mkstemp
(
".py"
)
script_fd
,
script_name
=
mkstemp
(
".py"
)
os
.
close
(
script_fd
)
script_fd
=
None
logger
.
info
(
"writing byte-compilation script '%s'"
,
script_name
)
logger
.
info
(
"writing byte-compilation script '%s'"
,
script_name
)
if
not
dry_run
:
if
not
dry_run
:
if
script_fd
is
not
None
:
if
script_fd
is
not
None
:
...
...
Lib/pkgutil.py
View file @
becf1c58
...
@@ -307,9 +307,9 @@ class ImpLoader:
...
@@ -307,9 +307,9 @@ class ImpLoader:
def
get_filename
(
self
,
fullname
=
None
):
def
get_filename
(
self
,
fullname
=
None
):
fullname
=
self
.
_fix_name
(
fullname
)
fullname
=
self
.
_fix_name
(
fullname
)
mod_type
=
self
.
etc
[
2
]
mod_type
=
self
.
etc
[
2
]
if
self
.
etc
[
2
]
==
imp
.
PKG_DIRECTORY
:
if
mod_type
==
imp
.
PKG_DIRECTORY
:
return
self
.
_get_delegate
().
get_filename
()
return
self
.
_get_delegate
().
get_filename
()
elif
self
.
etc
[
2
]
in
(
imp
.
PY_SOURCE
,
imp
.
PY_COMPILED
,
imp
.
C_EXTENSION
):
elif
mod_type
in
(
imp
.
PY_SOURCE
,
imp
.
PY_COMPILED
,
imp
.
C_EXTENSION
):
return
self
.
filename
return
self
.
filename
return
None
return
None
...
...
Lib/shutil.py
View file @
becf1c58
...
@@ -391,7 +391,7 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
...
@@ -391,7 +391,7 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
compress_ext
[
'bzip2'
]
=
'.bz2'
compress_ext
[
'bzip2'
]
=
'.bz2'
# flags for compression program, each element of list will be an argument
# flags for compression program, each element of list will be an argument
if
compress
is
not
None
and
compress
not
in
compress_ext
.
keys
()
:
if
compress
is
not
None
and
compress
not
in
compress_ext
:
raise
ValueError
(
"bad value for 'compress', or compression format not "
raise
ValueError
(
"bad value for 'compress', or compression format not "
"supported : {0}"
.
format
(
compress
))
"supported : {0}"
.
format
(
compress
))
...
@@ -497,7 +497,7 @@ _ARCHIVE_FORMATS = {
...
@@ -497,7 +497,7 @@ _ARCHIVE_FORMATS = {
'gztar'
:
(
_make_tarball
,
[(
'compress'
,
'gzip'
)],
"gzip'ed tar-file"
),
'gztar'
:
(
_make_tarball
,
[(
'compress'
,
'gzip'
)],
"gzip'ed tar-file"
),
'bztar'
:
(
_make_tarball
,
[(
'compress'
,
'bzip2'
)],
"bzip2'ed tar-file"
),
'bztar'
:
(
_make_tarball
,
[(
'compress'
,
'bzip2'
)],
"bzip2'ed tar-file"
),
'tar'
:
(
_make_tarball
,
[(
'compress'
,
None
)],
"uncompressed tar file"
),
'tar'
:
(
_make_tarball
,
[(
'compress'
,
None
)],
"uncompressed tar file"
),
'zip'
:
(
_make_zipfile
,
[],
"ZIP file"
)
'zip'
:
(
_make_zipfile
,
[],
"ZIP file"
)
}
}
if
_BZ2_SUPPORTED
:
if
_BZ2_SUPPORTED
:
...
@@ -530,7 +530,7 @@ def register_archive_format(name, function, extra_args=None, description=''):
...
@@ -530,7 +530,7 @@ def register_archive_format(name, function, extra_args=None, description=''):
if
not
isinstance
(
extra_args
,
(
tuple
,
list
)):
if
not
isinstance
(
extra_args
,
(
tuple
,
list
)):
raise
TypeError
(
'extra_args needs to be a sequence'
)
raise
TypeError
(
'extra_args needs to be a sequence'
)
for
element
in
extra_args
:
for
element
in
extra_args
:
if
not
isinstance
(
element
,
(
tuple
,
list
))
or
len
(
element
)
!=
2
:
if
not
isinstance
(
element
,
(
tuple
,
list
))
or
len
(
element
)
!=
2
:
raise
TypeError
(
'extra_args elements are : (arg_name, value)'
)
raise
TypeError
(
'extra_args elements are : (arg_name, value)'
)
_ARCHIVE_FORMATS
[
name
]
=
(
function
,
extra_args
,
description
)
_ARCHIVE_FORMATS
[
name
]
=
(
function
,
extra_args
,
description
)
...
@@ -682,7 +682,7 @@ def _unpack_zipfile(filename, extract_dir):
...
@@ -682,7 +682,7 @@ def _unpack_zipfile(filename, extract_dir):
if
not
name
.
endswith
(
'/'
):
if
not
name
.
endswith
(
'/'
):
# file
# file
data
=
zip
.
read
(
info
.
filename
)
data
=
zip
.
read
(
info
.
filename
)
f
=
open
(
target
,
'wb'
)
f
=
open
(
target
,
'wb'
)
try
:
try
:
f
.
write
(
data
)
f
.
write
(
data
)
finally
:
finally
:
...
...
Lib/test/regrtest.py
View file @
becf1c58
...
@@ -965,7 +965,9 @@ class saved_test_environment:
...
@@ -965,7 +965,9 @@ class saved_test_environment:
'warnings.filters', 'asyncore.socket_map',
'warnings.filters', 'asyncore.socket_map',
'logging._handlers', 'logging._handlerList', 'sys.gettrace',
'logging._handlers', 'logging._handlerList', 'sys.gettrace',
'sys.warnoptions', 'threading._dangling',
'sys.warnoptions', 'threading._dangling',
'multiprocessing.process._dangling')
'multiprocessing.process._dangling',
'sysconfig._CONFIG_VARS', 'sysconfig._SCHEMES',
)
def get_sys_argv(self):
def get_sys_argv(self):
return id(sys.argv), sys.argv, sys.argv[:]
return id(sys.argv), sys.argv, sys.argv[:]
...
@@ -1083,6 +1085,27 @@ class saved_test_environment:
...
@@ -1083,6 +1085,27 @@ class saved_test_environment:
multiprocessing.process._dangling.clear()
multiprocessing.process._dangling.clear()
multiprocessing.process._dangling.update(saved)
multiprocessing.process._dangling.update(saved)
def get_sysconfig__CONFIG_VARS(self):
# make sure the dict is initialized
sysconfig.get_config_var('prefix')
return (id(sysconfig._CONFIG_VARS), sysconfig._CONFIG_VARS,
dict(sysconfig._CONFIG_VARS))
def restore_sysconfig__CONFIG_VARS(self, saved):
sysconfig._CONFIG_VARS = saved[1]
sysconfig._CONFIG_VARS.clear()
sysconfig._CONFIG_VARS.update(saved[2])
def get_sysconfig__SCHEMES(self):
# it's mildly evil to look at the internal attribute, but it's easier
# than copying a RawConfigParser object
return (id(sysconfig._SCHEMES), sysconfig._SCHEMES._sections,
sysconfig._SCHEMES._sections.copy())
def restore_sysconfig__SCHEMES(self, saved):
sysconfig._SCHEMES._sections = saved[1]
sysconfig._SCHEMES._sections.clear()
sysconfig._SCHEMES._sections.update(saved[2])
def resource_info(self):
def resource_info(self):
for name in self.resources:
for name in self.resources:
method_suffix = name.replace('.', '_')
method_suffix = name.replace('.', '_')
...
...
Lib/test/test_sysconfig.py
View file @
becf1c58
...
@@ -39,7 +39,7 @@ class TestSysConfig(unittest.TestCase):
...
@@ -39,7 +39,7 @@ class TestSysConfig(unittest.TestCase):
self
.
_config_vars
=
copy
(
sysconfig
.
_CONFIG_VARS
)
self
.
_config_vars
=
copy
(
sysconfig
.
_CONFIG_VARS
)
self
.
_added_envvars
=
[]
self
.
_added_envvars
=
[]
self
.
_changed_envvars
=
[]
self
.
_changed_envvars
=
[]
for
var
in
(
'MACOSX_DEPLOYMENT_TARGET'
,
'P
ath
'
):
for
var
in
(
'MACOSX_DEPLOYMENT_TARGET'
,
'P
ATH
'
):
if
var
in
os
.
environ
:
if
var
in
os
.
environ
:
self
.
_changed_envvars
.
append
((
var
,
os
.
environ
[
var
]))
self
.
_changed_envvars
.
append
((
var
,
os
.
environ
[
var
]))
else
:
else
:
...
@@ -87,21 +87,19 @@ class TestSysConfig(unittest.TestCase):
...
@@ -87,21 +87,19 @@ class TestSysConfig(unittest.TestCase):
scheme
=
get_paths
()
scheme
=
get_paths
()
default_scheme
=
_get_default_scheme
()
default_scheme
=
_get_default_scheme
()
wanted
=
_expand_vars
(
default_scheme
,
None
)
wanted
=
_expand_vars
(
default_scheme
,
None
)
wanted
=
list
(
wanted
.
items
())
wanted
=
sorted
(
wanted
.
items
())
wanted
.
sort
()
scheme
=
sorted
(
scheme
.
items
())
scheme
=
list
(
scheme
.
items
())
scheme
.
sort
()
self
.
assertEqual
(
scheme
,
wanted
)
self
.
assertEqual
(
scheme
,
wanted
)
def
test_get_path
(
self
):
def
test_get_path
(
self
):
#
xxx
make real tests here
#
XXX
make real tests here
for
scheme
in
_SCHEMES
:
for
scheme
in
_SCHEMES
:
for
name
in
_SCHEMES
[
scheme
]:
for
name
in
_SCHEMES
[
scheme
]:
res
=
get_path
(
name
,
scheme
)
res
=
get_path
(
name
,
scheme
)
def
test_get_config_vars
(
self
):
def
test_get_config_vars
(
self
):
cvars
=
get_config_vars
()
cvars
=
get_config_vars
()
self
.
assert
True
(
isinstance
(
cvars
,
dict
)
)
self
.
assert
IsInstance
(
cvars
,
dict
)
self
.
assertTrue
(
cvars
)
self
.
assertTrue
(
cvars
)
def
test_get_platform
(
self
):
def
test_get_platform
(
self
):
...
@@ -236,8 +234,8 @@ class TestSysConfig(unittest.TestCase):
...
@@ -236,8 +234,8 @@ class TestSysConfig(unittest.TestCase):
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
# to add the directory to the path.
# to add the directory to the path.
if
sys
.
platform
==
"win32"
:
if
sys
.
platform
==
"win32"
:
os
.
environ
[
"P
ath
"
]
=
"{};{}"
.
format
(
os
.
environ
[
"P
ATH
"
]
=
"{};{}"
.
format
(
os
.
path
.
dirname
(
sys
.
executable
),
os
.
environ
[
"P
ath
"
])
os
.
path
.
dirname
(
sys
.
executable
),
os
.
environ
[
"P
ATH
"
])
# Issue 7880
# Issue 7880
def
get
(
python
):
def
get
(
python
):
...
...
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