Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
8e3f9d32
Commit
8e3f9d32
authored
Jun 18, 2014
by
Alex Grönholm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed PEP 8 compliancy of the setuptools.command package
parent
afea314a
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
734 additions
and
602 deletions
+734
-602
setuptools/command/__init__.py
setuptools/command/__init__.py
+3
-2
setuptools/command/alias.py
setuptools/command/alias.py
+8
-6
setuptools/command/bdist_egg.py
setuptools/command/bdist_egg.py
+87
-70
setuptools/command/bdist_rpm.py
setuptools/command/bdist_rpm.py
+2
-1
setuptools/command/bdist_wininst.py
setuptools/command/bdist_wininst.py
+1
-0
setuptools/command/build_ext.py
setuptools/command/build_ext.py
+69
-53
setuptools/command/build_py.py
setuptools/command/build_py.py
+37
-28
setuptools/command/develop.py
setuptools/command/develop.py
+21
-16
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+298
-231
setuptools/command/egg_info.py
setuptools/command/egg_info.py
+57
-43
setuptools/command/install.py
setuptools/command/install.py
+11
-7
setuptools/command/install_egg_info.py
setuptools/command/install_egg_info.py
+26
-44
setuptools/command/install_lib.py
setuptools/command/install_lib.py
+7
-5
setuptools/command/install_scripts.py
setuptools/command/install_scripts.py
+8
-5
setuptools/command/launcher manifest.xml
setuptools/command/launcher manifest.xml
+9
-9
setuptools/command/register.py
setuptools/command/register.py
+1
-0
setuptools/command/rotate.py
setuptools/command/rotate.py
+13
-10
setuptools/command/saveopts.py
setuptools/command/saveopts.py
+6
-8
setuptools/command/sdist.py
setuptools/command/sdist.py
+22
-17
setuptools/command/setopt.py
setuptools/command/setopt.py
+25
-20
setuptools/command/test.py
setuptools/command/test.py
+15
-17
setuptools/command/upload_docs.py
setuptools/command/upload_docs.py
+8
-10
No files found.
setuptools/command/__init__.py
View file @
8e3f9d32
...
...
@@ -5,10 +5,11 @@ __all__ = [
'register'
,
'bdist_wininst'
,
'upload_docs'
,
]
from
setuptools.command
import
install_scripts
from
distutils.command.bdist
import
bdist
import
sys
from
distutils.command.bdist
import
bdist
from
setuptools.command
import
install_scripts
if
'egg'
not
in
bdist
.
format_commands
:
bdist
.
format_command
[
'egg'
]
=
(
'bdist_egg'
,
"Python .egg file"
)
...
...
setuptools/command/alias.py
View file @
8e3f9d32
...
...
@@ -2,10 +2,12 @@ from distutils.errors import DistutilsOptionError
from
setuptools.command.setopt
import
edit_config
,
option_base
,
config_file
def
shquote
(
arg
):
"""Quote an argument for later parsing by shlex.split()"""
for
c
in
'"'
,
"'"
,
"
\
\
"
,
"#"
:
if
c
in
arg
:
return
repr
(
arg
)
if
c
in
arg
:
return
repr
(
arg
)
if
arg
.
split
()
!=
[
arg
]:
return
repr
(
arg
)
return
arg
...
...
@@ -18,7 +20,7 @@ class alias(option_base):
command_consumes_arguments
=
True
user_options
=
[
(
'remove'
,
'r'
,
'remove (unset) the alias'
),
(
'remove'
,
'r'
,
'remove (unset) the alias'
),
]
+
option_base
.
user_options
boolean_options
=
option_base
.
boolean_options
+
[
'remove'
]
...
...
@@ -46,7 +48,7 @@ class alias(option_base):
print
(
"setup.py alias"
,
format_alias
(
alias
,
aliases
))
return
elif
len
(
self
.
args
)
==
1
:
elif
len
(
self
.
args
)
==
1
:
alias
,
=
self
.
args
if
self
.
remove
:
command
=
None
...
...
@@ -58,9 +60,9 @@ class alias(option_base):
return
else
:
alias
=
self
.
args
[
0
]
command
=
' '
.
join
(
map
(
shquote
,
self
.
args
[
1
:]))
command
=
' '
.
join
(
map
(
shquote
,
self
.
args
[
1
:]))
edit_config
(
self
.
filename
,
{
'aliases'
:
{
alias
:
command
}},
self
.
dry_run
)
edit_config
(
self
.
filename
,
{
'aliases'
:
{
alias
:
command
}},
self
.
dry_run
)
def
format_alias
(
name
,
aliases
):
...
...
@@ -73,4 +75,4 @@ def format_alias(name, aliases):
source
=
''
else
:
source
=
'--filename=%r'
%
source
return
source
+
name
+
' '
+
command
return
source
+
name
+
' '
+
command
setuptools/command/bdist_egg.py
View file @
8e3f9d32
This diff is collapsed.
Click to expand it.
setuptools/command/bdist_rpm.py
View file @
8e3f9d32
import
distutils.command.bdist_rpm
as
orig
class
bdist_rpm
(
orig
.
bdist_rpm
):
"""
Override the default bdist_rpm behavior to do the following:
...
...
@@ -19,7 +20,7 @@ class bdist_rpm(orig.bdist_rpm):
def
_make_spec_file
(
self
):
version
=
self
.
distribution
.
get_version
()
rpmversion
=
version
.
replace
(
'-'
,
'_'
)
rpmversion
=
version
.
replace
(
'-'
,
'_'
)
spec
=
orig
.
bdist_rpm
.
_make_spec_file
(
self
)
line23
=
'%define version '
+
version
line24
=
'%define version '
+
rpmversion
...
...
setuptools/command/bdist_wininst.py
View file @
8e3f9d32
import
distutils.command.bdist_wininst
as
orig
class
bdist_wininst
(
orig
.
bdist_wininst
):
def
reinitialize_command
(
self
,
command
,
reinit_subcommands
=
0
):
"""
...
...
setuptools/command/build_ext.py
View file @
8e3f9d32
This diff is collapsed.
Click to expand it.
setuptools/command/build_py.py
View file @
8e3f9d32
from
glob
import
glob
from
distutils.util
import
convert_path
import
distutils.command.build_py
as
orig
import
os
import
sys
import
fnmatch
import
textwrap
import
distutils.command.build_py
as
orig
from
distutils.util
import
convert_path
from
glob
import
glob
try
:
from
setuptools.lib2to3_ex
import
Mixin2to3
...
...
@@ -13,6 +13,7 @@ except ImportError:
def
run_2to3
(
self
,
files
,
doctests
=
True
):
"do nothing"
class
build_py
(
orig
.
build_py
,
Mixin2to3
):
"""Enhanced 'build_py' command that includes data files with packages
...
...
@@ -22,11 +23,14 @@ class build_py(orig.build_py, Mixin2to3):
Also, this version of the 'build_py' command allows you to specify both
'py_modules' and 'packages' in the same setup operation.
"""
def
finalize_options
(
self
):
orig
.
build_py
.
finalize_options
(
self
)
self
.
package_data
=
self
.
distribution
.
package_data
self
.
exclude_package_data
=
self
.
distribution
.
exclude_package_data
or
{}
if
'data_files'
in
self
.
__dict__
:
del
self
.
__dict__
[
'data_files'
]
self
.
exclude_package_data
=
(
self
.
distribution
.
exclude_package_data
or
{})
if
'data_files'
in
self
.
__dict__
:
del
self
.
__dict__
[
'data_files'
]
self
.
__updated_files
=
[]
self
.
__doctests_2to3
=
[]
...
...
@@ -51,13 +55,14 @@ class build_py(orig.build_py, Mixin2to3):
self
.
byte_compile
(
orig
.
build_py
.
get_outputs
(
self
,
include_bytecode
=
0
))
def
__getattr__
(
self
,
attr
):
if
attr
==
'data_files'
:
# lazily compute data files
if
attr
==
'data_files'
:
# lazily compute data files
self
.
data_files
=
files
=
self
.
_get_data_files
()
return
files
return
orig
.
build_py
.
__getattr__
(
self
,
attr
)
return
orig
.
build_py
.
__getattr__
(
self
,
attr
)
def
build_module
(
self
,
module
,
module_file
,
package
):
outfile
,
copied
=
orig
.
build_py
.
build_module
(
self
,
module
,
module_file
,
package
)
outfile
,
copied
=
orig
.
build_py
.
build_module
(
self
,
module
,
module_file
,
package
)
if
copied
:
self
.
__updated_files
.
append
(
outfile
)
return
outfile
,
copied
...
...
@@ -74,12 +79,12 @@ class build_py(orig.build_py, Mixin2to3):
build_dir
=
os
.
path
.
join
(
*
([
self
.
build_lib
]
+
package
.
split
(
'.'
)))
# Length of path to strip from found files
plen
=
len
(
src_dir
)
+
1
plen
=
len
(
src_dir
)
+
1
# Strip directory from globbed filenames
filenames
=
[
file
[
plen
:]
for
file
in
self
.
find_data_files
(
package
,
src_dir
)
]
]
data
.
append
((
package
,
src_dir
,
build_dir
,
filenames
))
return
data
...
...
@@ -102,7 +107,8 @@ class build_py(orig.build_py, Mixin2to3):
srcfile
=
os
.
path
.
join
(
src_dir
,
filename
)
outf
,
copied
=
self
.
copy_file
(
srcfile
,
target
)
srcfile
=
os
.
path
.
abspath
(
srcfile
)
if
copied
and
srcfile
in
self
.
distribution
.
convert_2to3_doctests
:
if
(
copied
and
srcfile
in
self
.
distribution
.
convert_2to3_doctests
):
self
.
__doctests_2to3
.
append
(
outf
)
def
analyze_manifest
(
self
):
...
...
@@ -117,21 +123,22 @@ class build_py(orig.build_py, Mixin2to3):
self
.
run_command
(
'egg_info'
)
ei_cmd
=
self
.
get_finalized_command
(
'egg_info'
)
for
path
in
ei_cmd
.
filelist
.
files
:
d
,
f
=
os
.
path
.
split
(
assert_relative
(
path
))
d
,
f
=
os
.
path
.
split
(
assert_relative
(
path
))
prev
=
None
oldf
=
f
while
d
and
d
!=
prev
and
d
not
in
src_dirs
:
while
d
and
d
!=
prev
and
d
not
in
src_dirs
:
prev
=
d
d
,
df
=
os
.
path
.
split
(
d
)
f
=
os
.
path
.
join
(
df
,
f
)
if
d
in
src_dirs
:
if
path
.
endswith
(
'.py'
)
and
f
==
oldf
:
continue
# it's a module, not data
mf
.
setdefault
(
src_dirs
[
d
],[]).
append
(
path
)
if
path
.
endswith
(
'.py'
)
and
f
==
oldf
:
continue
# it's a module, not data
mf
.
setdefault
(
src_dirs
[
d
],
[]).
append
(
path
)
def
get_data_files
(
self
):
pass
# kludge 2.4 for lazy computation
def
get_data_files
(
self
):
pass
# kludge 2.4 for lazy computation
if
sys
.
version
<
"2.4"
:
# Python 2.4 already has this code
if
sys
.
version
<
"2.4"
:
# Python 2.4 already has this code
def
get_outputs
(
self
,
include_bytecode
=
1
):
"""Return complete list of files copied to the build directory
...
...
@@ -142,9 +149,9 @@ class build_py(orig.build_py, Mixin2to3):
"""
return
orig
.
build_py
.
get_outputs
(
self
,
include_bytecode
)
+
[
os
.
path
.
join
(
build_dir
,
filename
)
for
package
,
src_dir
,
build_dir
,
filenames
in
self
.
data_files
for
package
,
src_dir
,
build_dir
,
filenames
in
self
.
data_files
for
filename
in
filenames
]
]
def
check_package
(
self
,
package
,
package_dir
):
"""Check namespace packages' __init__ for declare_namespace"""
...
...
@@ -160,25 +167,26 @@ class build_py(orig.build_py, Mixin2to3):
return
init_py
for
pkg
in
self
.
distribution
.
namespace_packages
:
if
pkg
==
package
or
pkg
.
startswith
(
package
+
'.'
):
if
pkg
==
package
or
pkg
.
startswith
(
package
+
'.'
):
break
else
:
return
init_py
f
=
open
(
init_py
,
'rbU'
)
f
=
open
(
init_py
,
'rbU'
)
if
'declare_namespace'
.
encode
()
not
in
f
.
read
():
from
distutils.errors
import
DistutilsError
raise
DistutilsError
(
"Namespace package problem: %s is a namespace package, but
its
\
n
"
"
__init__.py does not call declare_namespace()! Please fix it.
\
n
"
'
(See the setuptools manual under "Namespace Packages" fo
r '
"details.)
\
n
"
%
(
package
,)
"Namespace package problem: %s is a namespace package, but "
"
its
\
n
__init__.py does not call declare_namespace()! Please
"
'
fix it.
\
n
(See the setuptools manual unde
r '
'"Namespace Packages" for details.)
\
n
"'
%
(
package
,)
)
f
.
close
()
return
init_py
def
initialize_options
(
self
):
self
.
packages_checked
=
{}
self
.
packages_checked
=
{}
orig
.
build_py
.
initialize_options
(
self
)
def
get_package_dir
(
self
,
package
):
...
...
@@ -202,7 +210,7 @@ class build_py(orig.build_py, Mixin2to3):
seen
=
{}
return
[
f
for
f
in
files
if
f
not
in
bad
and
f
not
in
seen
and
seen
.
setdefault
(
f
,
1
)
# ditch dupes
and
f
not
in
seen
and
seen
.
setdefault
(
f
,
1
)
# ditch dupes
]
...
...
@@ -210,6 +218,7 @@ def assert_relative(path):
if
not
os
.
path
.
isabs
(
path
):
return
path
from
distutils.errors
import
DistutilsSetupError
msg
=
textwrap
.
dedent
(
"""
Error: setup script specifies an absolute path:
...
...
setuptools/command/develop.py
View file @
8e3f9d32
import
os
import
glob
from
distutils.util
import
convert_path
from
distutils
import
log
from
distutils.errors
import
DistutilsError
,
DistutilsOptionError
import
os
import
glob
import
setuptools
from
pkg_resources
import
Distribution
,
PathMetadata
,
normalize_path
from
setuptools.command.easy_install
import
easy_install
from
setuptools.compat
import
PY3
import
setuptools
class
develop
(
easy_install
):
"""Set up package for development"""
...
...
@@ -36,7 +37,7 @@ class develop(easy_install):
self
.
egg_path
=
None
easy_install
.
initialize_options
(
self
)
self
.
setup_path
=
None
self
.
always_copy_from
=
'.'
# always copy eggs installed in curdir
self
.
always_copy_from
=
'.'
# always copy eggs installed in curdir
def
finalize_options
(
self
):
ei
=
self
.
get_finalized_command
(
"egg_info"
)
...
...
@@ -52,29 +53,31 @@ class develop(easy_install):
# pick up setup-dir .egg files only: no .egg-info
self
.
package_index
.
scan
(
glob
.
glob
(
'*.egg'
))
self
.
egg_link
=
os
.
path
.
join
(
self
.
install_dir
,
ei
.
egg_name
+
'.egg-link'
)
self
.
egg_link
=
os
.
path
.
join
(
self
.
install_dir
,
ei
.
egg_name
+
'.egg-link'
)
self
.
egg_base
=
ei
.
egg_base
if
self
.
egg_path
is
None
:
self
.
egg_path
=
os
.
path
.
abspath
(
ei
.
egg_base
)
target
=
normalize_path
(
self
.
egg_base
)
egg_path
=
normalize_path
(
os
.
path
.
join
(
self
.
install_dir
,
self
.
egg_path
))
egg_path
=
normalize_path
(
os
.
path
.
join
(
self
.
install_dir
,
self
.
egg_path
))
if
egg_path
!=
target
:
raise
DistutilsOptionError
(
"--egg-path must be a relative path from the install"
" directory to "
+
target
" directory to "
+
target
)
# Make a distribution for the package's source
self
.
dist
=
Distribution
(
target
,
PathMetadata
(
target
,
os
.
path
.
abspath
(
ei
.
egg_info
)),
project_name
=
ei
.
egg_name
project_name
=
ei
.
egg_name
)
p
=
self
.
egg_base
.
replace
(
os
.
sep
,
'/'
)
if
p
!=
os
.
curdir
:
p
=
'../'
*
(
p
.
count
(
'/'
)
+
1
)
p
=
self
.
egg_base
.
replace
(
os
.
sep
,
'/'
)
if
p
!=
os
.
curdir
:
p
=
'../'
*
(
p
.
count
(
'/'
)
+
1
)
self
.
setup_path
=
p
p
=
normalize_path
(
os
.
path
.
join
(
self
.
install_dir
,
self
.
egg_path
,
p
))
if
p
!=
normalize_path
(
os
.
curdir
):
...
...
@@ -103,7 +106,8 @@ class develop(easy_install):
ei_cmd
=
self
.
get_finalized_command
(
"egg_info"
)
self
.
egg_path
=
build_path
self
.
dist
.
location
=
build_path
self
.
dist
.
_provider
=
PathMetadata
(
build_path
,
ei_cmd
.
egg_info
)
# XXX
# XXX
self
.
dist
.
_provider
=
PathMetadata
(
build_path
,
ei_cmd
.
egg_info
)
else
:
# Without 2to3 inplace works fine:
self
.
run_command
(
'egg_info'
)
...
...
@@ -120,7 +124,7 @@ class develop(easy_install):
# create an .egg-link in the installation dir, pointing to our egg
log
.
info
(
"Creating %s (link to %s)"
,
self
.
egg_link
,
self
.
egg_base
)
if
not
self
.
dry_run
:
f
=
open
(
self
.
egg_link
,
"w"
)
f
=
open
(
self
.
egg_link
,
"w"
)
f
.
write
(
self
.
egg_path
+
"
\
n
"
+
self
.
setup_path
)
f
.
close
()
# postprocess the installed distro, fixing up .pth, installing scripts,
...
...
@@ -133,7 +137,8 @@ class develop(easy_install):
egg_link_file
=
open
(
self
.
egg_link
)
contents
=
[
line
.
rstrip
()
for
line
in
egg_link_file
]
egg_link_file
.
close
()
if
contents
not
in
([
self
.
egg_path
],
[
self
.
egg_path
,
self
.
setup_path
]):
if
contents
not
in
([
self
.
egg_path
],
[
self
.
egg_path
,
self
.
setup_path
]):
log
.
warn
(
"Link points to %s: uninstall aborted"
,
contents
)
return
if
not
self
.
dry_run
:
...
...
@@ -147,7 +152,7 @@ class develop(easy_install):
def
install_egg_scripts
(
self
,
dist
):
if
dist
is
not
self
.
dist
:
# Installing a dependency, so fall back to normal behavior
return
easy_install
.
install_egg_scripts
(
self
,
dist
)
return
easy_install
.
install_egg_scripts
(
self
,
dist
)
# create wrapper scripts in the script dir, pointing to dist.scripts
...
...
@@ -158,7 +163,7 @@ class develop(easy_install):
for
script_name
in
self
.
distribution
.
scripts
or
[]:
script_path
=
os
.
path
.
abspath
(
convert_path
(
script_name
))
script_name
=
os
.
path
.
basename
(
script_path
)
f
=
open
(
script_path
,
'rU'
)
f
=
open
(
script_path
,
'rU'
)
script_text
=
f
.
read
()
f
.
close
()
self
.
install_script
(
dist
,
script_name
,
script_text
,
script_path
)
setuptools/command/easy_install.py
View file @
8e3f9d32
This diff is collapsed.
Click to expand it.
setuptools/command/egg_info.py
View file @
8e3f9d32
This diff is collapsed.
Click to expand it.
setuptools/command/install.py
View file @
8e3f9d32
import
setuptools
from
distutils.errors
import
DistutilsArgError
import
inspect
import
glob
import
warnings
import
platform
import
distutils.command.install
as
orig
from
distutils.errors
import
DistutilsArgError
import
setuptools
# Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for
#
now. See https://bitbucket.org/pypa/setuptools/issue/199/
# now. See https://bitbucket.org/pypa/setuptools/issue/199/
_install
=
orig
.
install
class
install
(
orig
.
install
):
"""Use easy_install to install the package, w/dependencies"""
user_options
=
orig
.
install
.
user_options
+
[
(
'old-and-unmanageable'
,
None
,
"Try not to use this!"
),
(
'single-version-externally-managed'
,
None
,
"used by system package builders to create 'flat' eggs"
),
"used by system package builders to create 'flat' eggs"
),
]
boolean_options
=
orig
.
install
.
boolean_options
+
[
'old-and-unmanageable'
,
'single-version-externally-managed'
,
...
...
@@ -115,7 +117,9 @@ class install(orig.install):
cmd
.
run
()
setuptools
.
bootstrap_install_from
=
None
# XXX Python 3.1 doesn't see _nc if this is inside the class
install
.
sub_commands
=
[
cmd
for
cmd
in
orig
.
install
.
sub_commands
if
cmd
[
0
]
not
in
install
.
_nc
]
+
install
.
new_commands
install
.
sub_commands
=
(
[
cmd
for
cmd
in
orig
.
install
.
sub_commands
if
cmd
[
0
]
not
in
install
.
_nc
]
+
install
.
new_commands
)
setuptools/command/install_egg_info.py
View file @
8e3f9d32
from
distutils
import
log
,
dir_util
import
os
from
setuptools
import
Command
from
setuptools.archive_util
import
unpack_archive
from
distutils
import
log
,
dir_util
import
os
,
pkg_resources
import
pkg_resources
class
install_egg_info
(
Command
):
"""Install an .egg-info directory for the package"""
...
...
@@ -16,11 +19,12 @@ class install_egg_info(Command):
self
.
install_dir
=
None
def
finalize_options
(
self
):
self
.
set_undefined_options
(
'install_lib'
,(
'install_dir'
,
'install_dir'
))
self
.
set_undefined_options
(
'install_lib'
,
(
'install_dir'
,
'install_dir'
))
ei_cmd
=
self
.
get_finalized_command
(
"egg_info"
)
basename
=
pkg_resources
.
Distribution
(
None
,
None
,
ei_cmd
.
egg_name
,
ei_cmd
.
egg_version
).
egg_name
()
+
'.egg-info'
).
egg_name
()
+
'.egg-info'
self
.
source
=
ei_cmd
.
egg_info
self
.
target
=
os
.
path
.
join
(
self
.
install_dir
,
basename
)
self
.
outputs
=
[
self
.
target
]
...
...
@@ -31,11 +35,11 @@ class install_egg_info(Command):
if
os
.
path
.
isdir
(
self
.
target
)
and
not
os
.
path
.
islink
(
self
.
target
):
dir_util
.
remove_tree
(
self
.
target
,
dry_run
=
self
.
dry_run
)
elif
os
.
path
.
exists
(
self
.
target
):
self
.
execute
(
os
.
unlink
,
(
self
.
target
,),
"Removing "
+
self
.
target
)
self
.
execute
(
os
.
unlink
,
(
self
.
target
,),
"Removing "
+
self
.
target
)
if
not
self
.
dry_run
:
pkg_resources
.
ensure_directory
(
self
.
target
)
self
.
execute
(
self
.
copytree
,
(),
"Copying %s to %s"
%
(
self
.
source
,
self
.
target
)
self
.
execute
(
self
.
copytree
,
(),
"Copying %s to %s"
%
(
self
.
source
,
self
.
target
)
)
self
.
install_namespaces
()
...
...
@@ -44,50 +48,29 @@ class install_egg_info(Command):
def
copytree
(
self
):
# Copy the .egg-info tree to site-packages
def
skimmer
(
src
,
dst
):
def
skimmer
(
src
,
dst
):
# filter out source-control directories; note that 'src' is always
# a '/'-separated path, regardless of platform. 'dst' is a
# platform-specific path.
for
skip
in
'.svn/'
,
'CVS/'
:
if
src
.
startswith
(
skip
)
or
'/'
+
skip
in
src
:
for
skip
in
'.svn/'
,
'CVS/'
:
if
src
.
startswith
(
skip
)
or
'/'
+
skip
in
src
:
return
None
self
.
outputs
.
append
(
dst
)
log
.
debug
(
"Copying %s to %s"
,
src
,
dst
)
return
dst
unpack_archive
(
self
.
source
,
self
.
target
,
skimmer
)
unpack_archive
(
self
.
source
,
self
.
target
,
skimmer
)
def
install_namespaces
(
self
):
nsp
=
self
.
_get_all_ns_packages
()
if
not
nsp
:
return
filename
,
ext
=
os
.
path
.
splitext
(
self
.
target
)
filename
+=
'-nspkg.pth'
;
self
.
outputs
.
append
(
filename
)
log
.
info
(
"Installing %s"
,
filename
)
if
not
nsp
:
return
filename
,
ext
=
os
.
path
.
splitext
(
self
.
target
)
filename
+=
'-nspkg.pth'
self
.
outputs
.
append
(
filename
)
log
.
info
(
"Installing %s"
,
filename
)
if
not
self
.
dry_run
:
f
=
open
(
filename
,
'wt'
)
f
=
open
(
filename
,
'wt'
)
for
pkg
in
nsp
:
# ensure pkg is not a unicode string under Python 2.7
pkg
=
str
(
pkg
)
...
...
@@ -101,10 +84,11 @@ class install_egg_info(Command):
f
.
write
(
"import sys,types,os; "
"p = os.path.join(sys._getframe(1).f_locals['sitedir'], "
"*%(pth)r); "
"*%(pth)r); "
"ie = os.path.exists(os.path.join(p,'__init__.py')); "
"m = not ie and "
"sys.modules.setdefault(%(pkg)r,types.ModuleType(%(pkg)r)); "
"sys.modules.setdefault(%(pkg)r,types.ModuleType"
"(%(pkg)r)); "
"mp = (m or []) and m.__dict__.setdefault('__path__',[]); "
"(p not in mp) and mp.append(p)%(trailer)s"
%
locals
()
...
...
@@ -118,8 +102,6 @@ class install_egg_info(Command):
while
pkg
:
nsp
[
'.'
.
join
(
pkg
)]
=
1
pkg
.
pop
()
nsp
=
list
(
nsp
)
nsp
=
list
(
nsp
)
nsp
.
sort
()
# set up shorter names first
return
nsp
setuptools/command/install_lib.py
View file @
8e3f9d32
import
distutils.command.install_lib
as
orig
import
os
class
install_lib
(
orig
.
install_lib
):
"""Don't add compiled flags to filenames of non-Python files"""
...
...
@@ -15,20 +16,20 @@ class install_lib(orig.install_lib):
exclude
=
{}
nsp
=
self
.
distribution
.
namespace_packages
svem
=
(
nsp
and
self
.
get_finalized_command
(
'install'
)
.
single_version_externally_managed
)
.
single_version_externally_managed
)
if
svem
:
for
pkg
in
nsp
:
parts
=
pkg
.
split
(
'.'
)
while
parts
:
pkgdir
=
os
.
path
.
join
(
self
.
install_dir
,
*
parts
)
for
f
in
'__init__.py'
,
'__init__.pyc'
,
'__init__.pyo'
:
exclude
[
os
.
path
.
join
(
pkgdir
,
f
)]
=
1
exclude
[
os
.
path
.
join
(
pkgdir
,
f
)]
=
1
parts
.
pop
()
return
exclude
def
copy_tree
(
self
,
infile
,
outfile
,
preserve_mode
=
1
,
preserve_times
=
1
,
preserve_symlinks
=
0
,
level
=
1
self
,
infile
,
outfile
,
preserve_mode
=
1
,
preserve_times
=
1
,
preserve_symlinks
=
0
,
level
=
1
):
assert
preserve_mode
and
preserve_times
and
not
preserve_symlinks
exclude
=
self
.
get_exclusions
()
...
...
@@ -45,7 +46,8 @@ class install_lib(orig.install_lib):
def
pf
(
src
,
dst
):
if
dst
in
exclude
:
log
.
warn
(
"Skipping installation of %s (namespace package)"
,
dst
)
log
.
warn
(
"Skipping installation of %s (namespace package)"
,
dst
)
return
False
log
.
info
(
"copying %s -> %s"
,
src
,
os
.
path
.
dirname
(
dst
))
...
...
setuptools/command/install_scripts.py
View file @
8e3f9d32
from
distutils
import
log
import
distutils.command.install_scripts
as
orig
from
pkg_resources
import
Distribution
,
PathMetadata
,
ensure_directory
import
os
from
distutils
import
log
from
pkg_resources
import
Distribution
,
PathMetadata
,
ensure_directory
class
install_scripts
(
orig
.
install_scripts
):
"""Do normal script install, plus any egg_info wrapper scripts"""
...
...
@@ -29,7 +31,7 @@ class install_scripts(orig.install_scripts):
ei_cmd
.
egg_name
,
ei_cmd
.
egg_version
,
)
bs_cmd
=
self
.
get_finalized_command
(
'build_scripts'
)
executable
=
getattr
(
bs_cmd
,
'executable'
,
sys_executable
)
executable
=
getattr
(
bs_cmd
,
'executable'
,
sys_executable
)
is_wininst
=
getattr
(
self
.
get_finalized_command
(
"bdist_wininst"
),
'_is_running'
,
False
)
...
...
@@ -39,6 +41,7 @@ class install_scripts(orig.install_scripts):
def
write_script
(
self
,
script_name
,
contents
,
mode
=
"t"
,
*
ignored
):
"""Write an executable file to the scripts directory"""
from
setuptools.command.easy_install
import
chmod
,
current_umask
log
.
info
(
"Installing %s script to %s"
,
script_name
,
self
.
install_dir
)
target
=
os
.
path
.
join
(
self
.
install_dir
,
script_name
)
self
.
outfiles
.
append
(
target
)
...
...
@@ -46,7 +49,7 @@ class install_scripts(orig.install_scripts):
mask
=
current_umask
()
if
not
self
.
dry_run
:
ensure_directory
(
target
)
f
=
open
(
target
,
"w"
+
mode
)
f
=
open
(
target
,
"w"
+
mode
)
f
.
write
(
contents
)
f
.
close
()
chmod
(
target
,
0o777
-
mask
)
chmod
(
target
,
0o777
-
mask
)
setuptools/command/launcher manifest.xml
View file @
8e3f9d32
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns=
"urn:schemas-microsoft-com:asm.v1"
manifestVersion=
"1.0"
>
<assemblyIdentity
version=
"1.0.0.0"
processorArchitecture=
"X86"
name=
"%(name)s"
type=
"win32"
/>
<assemblyIdentity
version=
"1.0.0.0"
processorArchitecture=
"X86"
name=
"%(name)s"
type=
"win32"
/>
<!-- Identify the application security requirements. -->
<trustInfo
xmlns=
"urn:schemas-microsoft-com:asm.v3"
>
<security>
<requestedPrivileges>
<requestedExecutionLevel
level=
"asInvoker"
uiAccess=
"false"
/>
</requestedPrivileges>
</security>
<security>
<requestedPrivileges>
<requestedExecutionLevel
level=
"asInvoker"
uiAccess=
"false"
/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
setuptools/command/register.py
View file @
8e3f9d32
import
distutils.command.register
as
orig
class
register
(
orig
.
register
):
__doc__
=
orig
.
register
.
__doc__
...
...
setuptools/command/rotate.py
View file @
8e3f9d32
import
os
from
setuptools
import
Command
from
setuptools.compat
import
basestring
from
distutils.util
import
convert_path
from
distutils
import
log
from
distutils.errors
import
DistutilsOptionError
import
os
from
setuptools
import
Command
from
setuptools.compat
import
basestring
class
rotate
(
Command
):
"""Delete older distributions"""
description
=
"delete older distributions, keeping N newest files"
user_options
=
[
(
'match='
,
'm'
,
"patterns to match (required)"
),
(
'match='
,
'm'
,
"patterns to match (required)"
),
(
'dist-dir='
,
'd'
,
"directory where the distributions are"
),
(
'keep='
,
'k'
,
"number of matching distributions to keep"
),
(
'keep='
,
'k'
,
"number of matching distributions to keep"
),
]
boolean_options
=
[]
...
...
@@ -38,21 +40,22 @@ class rotate(Command):
self
.
match
=
[
convert_path
(
p
.
strip
())
for
p
in
self
.
match
.
split
(
','
)
]
self
.
set_undefined_options
(
'bdist'
,(
'dist_dir'
,
'dist_dir'
))
self
.
set_undefined_options
(
'bdist'
,
(
'dist_dir'
,
'dist_dir'
))
def
run
(
self
):
self
.
run_command
(
"egg_info"
)
from
glob
import
glob
for
pattern
in
self
.
match
:
pattern
=
self
.
distribution
.
get_name
()
+
'*'
+
pattern
files
=
glob
(
os
.
path
.
join
(
self
.
dist_dir
,
pattern
))
files
=
[(
os
.
path
.
getmtime
(
f
),
f
)
for
f
in
files
]
pattern
=
self
.
distribution
.
get_name
()
+
'*'
+
pattern
files
=
glob
(
os
.
path
.
join
(
self
.
dist_dir
,
pattern
))
files
=
[(
os
.
path
.
getmtime
(
f
),
f
)
for
f
in
files
]
files
.
sort
()
files
.
reverse
()
log
.
info
(
"%d file(s) matching %s"
,
len
(
files
),
pattern
)
files
=
files
[
self
.
keep
:]
for
(
t
,
f
)
in
files
:
for
(
t
,
f
)
in
files
:
log
.
info
(
"Deleting %s"
,
f
)
if
not
self
.
dry_run
:
os
.
unlink
(
f
)
setuptools/command/saveopts.py
View file @
8e3f9d32
import
distutils
,
os
from
setuptools
import
Command
from
setuptools.command.setopt
import
edit_config
,
option_base
class
saveopts
(
option_base
):
"""Save command-line options to a file"""
...
...
@@ -13,12 +12,11 @@ class saveopts(option_base):
for
cmd
in
dist
.
command_options
:
if
cmd
==
'saveopts'
:
continue
# don't save our own options!
if
cmd
==
'saveopts'
:
continue
# don't save our own options!
for
opt
,
(
src
,
val
)
in
dist
.
get_option_dict
(
cmd
).
items
():
if
src
==
"command line"
:
settings
.
setdefault
(
cmd
,{})[
opt
]
=
val
for
opt
,
(
src
,
val
)
in
dist
.
get_option_dict
(
cmd
).
items
():
if
src
==
"command line"
:
settings
.
setdefault
(
cmd
,
{})[
opt
]
=
val
edit_config
(
self
.
filename
,
settings
,
self
.
dry_run
)
setuptools/command/sdist.py
View file @
8e3f9d32
from
glob
import
glob
from
distutils.util
import
convert_path
from
distutils
import
log
import
distutils.command.sdist
as
orig
import
os
import
re
import
sys
from
glob
import
glob
import
pkg_resources
import
distutils.command.sdist
as
orig
from
distutils.util
import
convert_path
from
distutils
import
log
from
setuptools
import
svn_utils
from
setuptools.compat
import
PY3
import
pkg_resources
READMES
=
(
'README'
,
'README.rst'
,
'README.txt'
)
...
...
@@ -20,7 +20,7 @@ def walk_revctrl(dirname=''):
yield
item
#TODO will need test case
#
TODO will need test case
class
re_finder
(
object
):
"""
Finder that locates files based on entries in a file matched by a
...
...
@@ -33,7 +33,7 @@ class re_finder(object):
self
.
entries_path
=
convert_path
(
path
)
def
_finder
(
self
,
dirname
,
filename
):
f
=
open
(
filename
,
'rU'
)
f
=
open
(
filename
,
'rU'
)
try
:
data
=
f
.
read
()
finally
:
...
...
@@ -51,12 +51,13 @@ class re_finder(object):
if
not
os
.
path
.
isfile
(
path
):
# entries file doesn't exist
return
for
path
in
self
.
_finder
(
dirname
,
path
):
for
path
in
self
.
_finder
(
dirname
,
path
):
if
os
.
path
.
isfile
(
path
):
yield
path
elif
os
.
path
.
isdir
(
path
):
for
item
in
self
.
find
(
path
):
yield
item
__call__
=
find
...
...
@@ -85,7 +86,7 @@ class sdist(orig.sdist):
('dist-dir=', 'd',
"
directory
to
put
the
source
distribution
archive
(
s
)
in
"
"
[
default
:
dist
]
"),
]
]
negative_opt = {}
...
...
@@ -93,7 +94,7 @@ class sdist(orig.sdist):
self.run_command('egg_info')
ei_cmd = self.get_finalized_command('egg_info')
self.filelist = ei_cmd.filelist
self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt'))
self.filelist.append(os.path.join(ei_cmd.egg_info,
'SOURCES.txt'))
self.check_readme()
# Run sub commands
...
...
@@ -103,12 +104,13 @@ class sdist(orig.sdist):
# Call check_metadata only if no 'check' command
# (distutils <= 2.6)
import distutils.command
if 'check' not in distutils.command.__all__:
self.check_metadata()
self.make_distribution()
dist_files = getattr(self.distribution,
'dist_files',
[])
dist_files = getattr(self.distribution,
'dist_files',
[])
for file in self.archive_files:
data = ('sdist', '', file)
if data not in dist_files:
...
...
@@ -124,13 +126,14 @@ class sdist(orig.sdist):
except:
sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close()
raise
# Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle
# has been fixed, so only override the method if we're using an earlier
# Python.
has_leaky_handle = (
sys.version_info < (2,
7,
2)
or (3,
0) <= sys.version_info < (3,1,
4)
or (3,
2) <= sys.version_info < (3,2,
1)
sys.version_info < (2,
7,
2)
or (3,
0) <= sys.version_info < (3, 1,
4)
or (3,
2) <= sys.version_info < (3, 2,
1)
)
if has_leaky_handle:
read_template = __read_template_hack
...
...
@@ -194,7 +197,8 @@ class sdist(orig.sdist):
return
else:
self.warn(
"
standard
file
not
found
:
should
have
one
of
" +', '.join(READMES)
"
standard
file
not
found
:
should
have
one
of
" +
', '.join(READMES)
)
def make_release_tree(self, base_dir, files):
...
...
@@ -202,7 +206,7 @@ class sdist(orig.sdist):
# Save any egg_info command line options used to create this sdist
dest = os.path.join(base_dir, 'setup.cfg')
if hasattr(os,'link') and os.path.exists(dest):
if hasattr(os,
'link') and os.path.exists(dest):
# unlink and re-copy, since it might be hard-linked, and
# we don't want to change the source version
os.unlink(dest)
...
...
@@ -220,7 +224,8 @@ class sdist(orig.sdist):
first_line = fp.readline()
finally:
fp.close()
return first_line != '# file GENERATED by distutils, do NOT edit
\
n
'.encode()
return (first_line !=
'# file GENERATED by distutils, do NOT edit
\
n
'.encode())
def read_manifest(self):
"""Read the manifest file (named by 'self.manifest') and use it to
...
...
setuptools/command/setopt.py
View file @
8e3f9d32
import
os
import
distutils
from
setuptools
import
Command
from
distutils.util
import
convert_path
from
distutils
import
log
from
distutils.errors
import
DistutilsOptionError
import
distutils
import
os
from
setuptools
import
Command
__all__
=
[
'config_file'
,
'edit_config'
,
'option_base'
,
'setopt'
]
...
...
@@ -13,19 +15,20 @@ def config_file(kind="local"):
`kind` must be one of "local", "global", or "user"
"""
if
kind
==
'local'
:
if
kind
==
'local'
:
return
'setup.cfg'
if
kind
==
'global'
:
if
kind
==
'global'
:
return
os
.
path
.
join
(
os
.
path
.
dirname
(
distutils
.
__file__
),
'distutils.cfg'
os
.
path
.
dirname
(
distutils
.
__file__
),
'distutils.cfg'
)
if
kind
==
'user'
:
dot
=
os
.
name
==
'posix'
and
'.'
or
''
if
kind
==
'user'
:
dot
=
os
.
name
==
'posix'
and
'.'
or
''
return
os
.
path
.
expanduser
(
convert_path
(
"~/%spydistutils.cfg"
%
dot
))
raise
ValueError
(
"config_file() type must be 'local', 'global', or 'user'"
,
kind
)
def
edit_config
(
filename
,
settings
,
dry_run
=
False
):
"""Edit a configuration file to include `settings`
...
...
@@ -35,6 +38,7 @@ def edit_config(filename, settings, dry_run=False):
A setting of ``None`` means to delete that setting.
"""
from
setuptools.compat
import
ConfigParser
log
.
debug
(
"Reading configuration from %s"
,
filename
)
opts
=
ConfigParser
.
RawConfigParser
()
opts
.
read
([
filename
])
...
...
@@ -46,39 +50,40 @@ def edit_config(filename, settings, dry_run=False):
if
not
opts
.
has_section
(
section
):
log
.
debug
(
"Adding new section [%s] to %s"
,
section
,
filename
)
opts
.
add_section
(
section
)
for
option
,
value
in
options
.
items
():
for
option
,
value
in
options
.
items
():
if
value
is
None
:
log
.
debug
(
"Deleting %s.%s from %s"
,
section
,
option
,
filename
)
opts
.
remove_option
(
section
,
option
)
opts
.
remove_option
(
section
,
option
)
if
not
opts
.
options
(
section
):
log
.
info
(
"Deleting empty [%s] section from %s"
,
section
,
filename
)
section
,
filename
)
opts
.
remove_section
(
section
)
else
:
log
.
debug
(
"Setting %s.%s to %r in %s"
,
section
,
option
,
value
,
filename
)
opts
.
set
(
section
,
option
,
value
)
opts
.
set
(
section
,
option
,
value
)
log
.
info
(
"Writing %s"
,
filename
)
if
not
dry_run
:
with
open
(
filename
,
'w'
)
as
f
:
opts
.
write
(
f
)
class
option_base
(
Command
):
"""Abstract base class for commands that mess with config files"""
user_options
=
[
(
'global-config'
,
'g'
,
"save options to the site-wide distutils.cfg file"
),
"save options to the site-wide distutils.cfg file"
),
(
'user-config'
,
'u'
,
"save options to the current user's pydistutils.cfg file"
),
"save options to the current user's pydistutils.cfg file"
),
(
'filename='
,
'f'
,
"configuration file to use (default=setup.cfg)"
),
"configuration file to use (default=setup.cfg)"
),
]
boolean_options
=
[
...
...
@@ -100,7 +105,7 @@ class option_base(Command):
filenames
.
append
(
self
.
filename
)
if
not
filenames
:
filenames
.
append
(
config_file
(
'local'
))
if
len
(
filenames
)
>
1
:
if
len
(
filenames
)
>
1
:
raise
DistutilsOptionError
(
"Must specify only one configuration file option"
,
filenames
...
...
@@ -115,9 +120,9 @@ class setopt(option_base):
user_options
=
[
(
'command='
,
'c'
,
'command to set an option for'
),
(
'option='
,
'o'
,
'option to set'
),
(
'set-value='
,
's'
,
'value of the option'
),
(
'remove'
,
'r'
,
'remove (unset) the value'
),
(
'option='
,
'o'
,
'option to set'
),
(
'set-value='
,
's'
,
'value of the option'
),
(
'remove'
,
'r'
,
'remove (unset) the value'
),
]
+
option_base
.
user_options
boolean_options
=
option_base
.
boolean_options
+
[
'remove'
]
...
...
@@ -139,7 +144,7 @@ class setopt(option_base):
def
run
(
self
):
edit_config
(
self
.
filename
,
{
self
.
command
:
{
self
.
option
.
replace
(
'-'
,
'_'
):
self
.
set_value
}
self
.
command
:
{
self
.
option
.
replace
(
'-'
,
'_'
):
self
.
set_value
}
},
self
.
dry_run
)
setuptools/command/test.py
View file @
8e3f9d32
import
unittest
from
unittest
import
TestLoader
from
setuptools
import
Command
from
distutils.errors
import
DistutilsOptionError
from
unittest
import
TestLoader
import
unittest
import
sys
from
pkg_resources
import
(
resource_listdir
,
resource_exists
,
normalize_path
,
working_set
,
_namespace_packages
,
add_activation_listener
,
require
,
EntryPoint
)
from
pkg_resources
import
(
resource_listdir
,
resource_exists
,
normalize_path
,
working_set
,
_namespace_packages
,
add_activation_listener
,
require
,
EntryPoint
)
from
setuptools
import
Command
from
setuptools.compat
import
PY3
from
setuptools.py31compat
import
unittest_main
class
ScanningLoader
(
TestLoader
):
def
loadTestsFromModule
(
self
,
module
):
"""Return a suite of all tests cases contained in the given module
...
...
@@ -34,7 +32,7 @@ class ScanningLoader(TestLoader):
submodule
=
module
.
__name__
+
'.'
+
file
[:
-
3
]
else
:
if
resource_exists
(
module
.
__name__
,
file
+
'/__init__.py'
):
submodule
=
module
.
__name__
+
'.'
+
file
submodule
=
module
.
__name__
+
'.'
+
file
else
:
continue
tests
.
append
(
self
.
loadTestsFromName
(
submodule
))
...
...
@@ -42,19 +40,18 @@ class ScanningLoader(TestLoader):
if
len
(
tests
)
!=
1
:
return
self
.
suiteClass
(
tests
)
else
:
return
tests
[
0
]
# don't create a nested suite for only one return
return
tests
[
0
]
# don't create a nested suite for only one return
class
test
(
Command
):
"""Command to run unit tests after in-place build"""
description
=
"run unit tests after in-place build"
user_options
=
[
(
'test-module='
,
'm'
,
"Run 'test_suite' in specified module"
),
(
'test-suite='
,
's'
,
"Test suite to run (e.g. 'some_module.test_suite')"
),
(
'test-module='
,
'm'
,
"Run 'test_suite' in specified module"
),
(
'test-suite='
,
's'
,
"Test suite to run (e.g. 'some_module.test_suite')"
),
(
'test-runner='
,
'r'
,
"Test runner to use"
),
]
...
...
@@ -79,7 +76,7 @@ class test(Command):
self
.
test_args
=
[
self
.
test_suite
]
if
self
.
verbose
:
self
.
test_args
.
insert
(
0
,
'--verbose'
)
self
.
test_args
.
insert
(
0
,
'--verbose'
)
if
self
.
test_loader
is
None
:
self
.
test_loader
=
getattr
(
self
.
distribution
,
'test_loader'
,
None
)
if
self
.
test_loader
is
None
:
...
...
@@ -132,7 +129,8 @@ class test(Command):
def
run
(
self
):
if
self
.
distribution
.
install_requires
:
self
.
distribution
.
fetch_build_eggs
(
self
.
distribution
.
install_requires
)
self
.
distribution
.
fetch_build_eggs
(
self
.
distribution
.
install_requires
)
if
self
.
distribution
.
tests_require
:
self
.
distribution
.
fetch_build_eggs
(
self
.
distribution
.
tests_require
)
...
...
@@ -161,7 +159,7 @@ class test(Command):
list
(
map
(
sys
.
modules
.
__delitem__
,
del_modules
))
unittest_main
(
None
,
None
,
[
unittest
.
__file__
]
+
self
.
test_args
,
None
,
None
,
[
unittest
.
__file__
]
+
self
.
test_args
,
testLoader
=
self
.
_resolve_as_ep
(
self
.
test_loader
),
testRunner
=
self
.
_resolve_as_ep
(
self
.
test_runner
),
)
...
...
setuptools/command/upload_docs.py
View file @
8e3f9d32
...
...
@@ -5,6 +5,10 @@ Implements a Distutils 'upload_docs' subcommand (upload documentation to
PyPI's pythonhosted.org).
"""
from
base64
import
standard_b64encode
from
distutils
import
log
from
distutils.errors
import
DistutilsOptionError
from
distutils.command.upload
import
upload
import
os
import
socket
import
zipfile
...
...
@@ -12,14 +16,9 @@ import tempfile
import
sys
import
shutil
from
base64
import
standard_b64encode
from
setuptools.compat
import
httplib
,
urlparse
,
unicode
,
iteritems
,
PY3
from
pkg_resources
import
iter_entry_points
from
distutils
import
log
from
distutils.errors
import
DistutilsOptionError
from
distutils.command.upload
import
upload
from
setuptools.compat
import
httplib
,
urlparse
,
unicode
,
iteritems
,
PY3
errors
=
'surrogateescape'
if
PY3
else
'strict'
...
...
@@ -33,7 +32,6 @@ def b(s, encoding='utf-8'):
class
upload_docs
(
upload
):
description
=
'Upload documentation to PyPI'
user_options
=
[
...
...
@@ -42,7 +40,7 @@ class upload_docs(upload):
(
'show-response'
,
None
,
'display full response text from server'
),
(
'upload-dir='
,
None
,
'directory to upload'
),
]
]
boolean_options
=
upload
.
boolean_options
def
has_sphinx
(
self
):
...
...
@@ -159,7 +157,7 @@ class upload_docs(upload):
elif
schema
==
'https'
:
conn
=
httplib
.
HTTPSConnection
(
netloc
)
else
:
raise
AssertionError
(
"unsupported schema "
+
schema
)
raise
AssertionError
(
"unsupported schema "
+
schema
)
data
=
''
try
:
...
...
@@ -190,4 +188,4 @@ class upload_docs(upload):
self
.
announce
(
'Upload failed (%s): %s'
%
(
r
.
status
,
r
.
reason
),
log
.
ERROR
)
if
self
.
show_response
:
print
(
'-'
*
75
,
r
.
read
(),
'-'
*
75
)
print
(
'-'
*
75
,
r
.
read
(),
'-'
*
75
)
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