Commit f6b5e292 authored by Jason R. Coombs's avatar Jason R. Coombs

Merge Pull Request 67 from bb://agronholm/bitbucket

parents 97fbee72 8e3f9d32
...@@ -5,10 +5,11 @@ __all__ = [ ...@@ -5,10 +5,11 @@ __all__ = [
'register', 'bdist_wininst', 'upload_docs', 'register', 'bdist_wininst', 'upload_docs',
] ]
from setuptools.command import install_scripts from distutils.command.bdist import bdist
import sys import sys
from distutils.command.bdist import bdist from setuptools.command import install_scripts
if 'egg' not in bdist.format_commands: if 'egg' not in bdist.format_commands:
bdist.format_command['egg'] = ('bdist_egg', "Python .egg file") bdist.format_command['egg'] = ('bdist_egg', "Python .egg file")
......
...@@ -2,10 +2,12 @@ from distutils.errors import DistutilsOptionError ...@@ -2,10 +2,12 @@ from distutils.errors import DistutilsOptionError
from setuptools.command.setopt import edit_config, option_base, config_file from setuptools.command.setopt import edit_config, option_base, config_file
def shquote(arg): def shquote(arg):
"""Quote an argument for later parsing by shlex.split()""" """Quote an argument for later parsing by shlex.split()"""
for c in '"', "'", "\\", "#": for c in '"', "'", "\\", "#":
if c in arg: return repr(arg) if c in arg:
return repr(arg)
if arg.split() != [arg]: if arg.split() != [arg]:
return repr(arg) return repr(arg)
return arg return arg
...@@ -18,7 +20,7 @@ class alias(option_base): ...@@ -18,7 +20,7 @@ class alias(option_base):
command_consumes_arguments = True command_consumes_arguments = True
user_options = [ user_options = [
('remove', 'r', 'remove (unset) the alias'), ('remove', 'r', 'remove (unset) the alias'),
] + option_base.user_options ] + option_base.user_options
boolean_options = option_base.boolean_options + ['remove'] boolean_options = option_base.boolean_options + ['remove']
...@@ -46,7 +48,7 @@ class alias(option_base): ...@@ -46,7 +48,7 @@ class alias(option_base):
print("setup.py alias", format_alias(alias, aliases)) print("setup.py alias", format_alias(alias, aliases))
return return
elif len(self.args)==1: elif len(self.args) == 1:
alias, = self.args alias, = self.args
if self.remove: if self.remove:
command = None command = None
...@@ -58,9 +60,9 @@ class alias(option_base): ...@@ -58,9 +60,9 @@ class alias(option_base):
return return
else: else:
alias = self.args[0] 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): def format_alias(name, aliases):
...@@ -73,4 +75,4 @@ def format_alias(name, aliases): ...@@ -73,4 +75,4 @@ def format_alias(name, aliases):
source = '' source = ''
else: else:
source = '--filename=%r' % source source = '--filename=%r' % source
return source+name+' '+command return source + name + ' ' + command
This diff is collapsed.
import distutils.command.bdist_rpm as orig import distutils.command.bdist_rpm as orig
class bdist_rpm(orig.bdist_rpm): class bdist_rpm(orig.bdist_rpm):
""" """
Override the default bdist_rpm behavior to do the following: Override the default bdist_rpm behavior to do the following:
...@@ -19,7 +20,7 @@ class bdist_rpm(orig.bdist_rpm): ...@@ -19,7 +20,7 @@ class bdist_rpm(orig.bdist_rpm):
def _make_spec_file(self): def _make_spec_file(self):
version = self.distribution.get_version() version = self.distribution.get_version()
rpmversion = version.replace('-','_') rpmversion = version.replace('-', '_')
spec = orig.bdist_rpm._make_spec_file(self) spec = orig.bdist_rpm._make_spec_file(self)
line23 = '%define version ' + version line23 = '%define version ' + version
line24 = '%define version ' + rpmversion line24 = '%define version ' + rpmversion
......
import distutils.command.bdist_wininst as orig import distutils.command.bdist_wininst as orig
class bdist_wininst(orig.bdist_wininst): class bdist_wininst(orig.bdist_wininst):
def reinitialize_command(self, command, reinit_subcommands=0): def reinitialize_command(self, command, reinit_subcommands=0):
""" """
......
This diff is collapsed.
from glob import glob
from distutils.util import convert_path
import distutils.command.build_py as orig
import os import os
import sys import sys
import fnmatch import fnmatch
import textwrap import textwrap
import distutils.command.build_py as orig
from distutils.util import convert_path
from glob import glob
try: try:
from setuptools.lib2to3_ex import Mixin2to3 from setuptools.lib2to3_ex import Mixin2to3
...@@ -13,6 +13,7 @@ except ImportError: ...@@ -13,6 +13,7 @@ except ImportError:
def run_2to3(self, files, doctests=True): def run_2to3(self, files, doctests=True):
"do nothing" "do nothing"
class build_py(orig.build_py, Mixin2to3): class build_py(orig.build_py, Mixin2to3):
"""Enhanced 'build_py' command that includes data files with packages """Enhanced 'build_py' command that includes data files with packages
...@@ -22,11 +23,14 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -22,11 +23,14 @@ class build_py(orig.build_py, Mixin2to3):
Also, this version of the 'build_py' command allows you to specify both Also, this version of the 'build_py' command allows you to specify both
'py_modules' and 'packages' in the same setup operation. 'py_modules' and 'packages' in the same setup operation.
""" """
def finalize_options(self): def finalize_options(self):
orig.build_py.finalize_options(self) orig.build_py.finalize_options(self)
self.package_data = self.distribution.package_data self.package_data = self.distribution.package_data
self.exclude_package_data = self.distribution.exclude_package_data or {} self.exclude_package_data = (self.distribution.exclude_package_data or
if 'data_files' in self.__dict__: del self.__dict__['data_files'] {})
if 'data_files' in self.__dict__:
del self.__dict__['data_files']
self.__updated_files = [] self.__updated_files = []
self.__doctests_2to3 = [] self.__doctests_2to3 = []
...@@ -51,13 +55,14 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -51,13 +55,14 @@ class build_py(orig.build_py, Mixin2to3):
self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0)) self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0))
def __getattr__(self, attr): 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() self.data_files = files = self._get_data_files()
return 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): 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: if copied:
self.__updated_files.append(outfile) self.__updated_files.append(outfile)
return outfile, copied return outfile, copied
...@@ -74,12 +79,12 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -74,12 +79,12 @@ class build_py(orig.build_py, Mixin2to3):
build_dir = os.path.join(*([self.build_lib] + package.split('.'))) build_dir = os.path.join(*([self.build_lib] + package.split('.')))
# Length of path to strip from found files # Length of path to strip from found files
plen = len(src_dir)+1 plen = len(src_dir) + 1
# Strip directory from globbed filenames # Strip directory from globbed filenames
filenames = [ filenames = [
file[plen:] for file in self.find_data_files(package, src_dir) file[plen:] for file in self.find_data_files(package, src_dir)
] ]
data.append((package, src_dir, build_dir, filenames)) data.append((package, src_dir, build_dir, filenames))
return data return data
...@@ -102,7 +107,8 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -102,7 +107,8 @@ class build_py(orig.build_py, Mixin2to3):
srcfile = os.path.join(src_dir, filename) srcfile = os.path.join(src_dir, filename)
outf, copied = self.copy_file(srcfile, target) outf, copied = self.copy_file(srcfile, target)
srcfile = os.path.abspath(srcfile) 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) self.__doctests_2to3.append(outf)
def analyze_manifest(self): def analyze_manifest(self):
...@@ -117,21 +123,22 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -117,21 +123,22 @@ class build_py(orig.build_py, Mixin2to3):
self.run_command('egg_info') self.run_command('egg_info')
ei_cmd = self.get_finalized_command('egg_info') ei_cmd = self.get_finalized_command('egg_info')
for path in ei_cmd.filelist.files: 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 prev = None
oldf = f 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 prev = d
d, df = os.path.split(d) d, df = os.path.split(d)
f = os.path.join(df, f) f = os.path.join(df, f)
if d in src_dirs: if d in src_dirs:
if path.endswith('.py') and f==oldf: if path.endswith('.py') and f == oldf:
continue # it's a module, not data continue # it's a module, not data
mf.setdefault(src_dirs[d],[]).append(path) 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): def get_outputs(self, include_bytecode=1):
"""Return complete list of files copied to the build directory """Return complete list of files copied to the build directory
...@@ -142,9 +149,9 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -142,9 +149,9 @@ class build_py(orig.build_py, Mixin2to3):
""" """
return orig.build_py.get_outputs(self, include_bytecode) + [ return orig.build_py.get_outputs(self, include_bytecode) + [
os.path.join(build_dir, filename) 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 for filename in filenames
] ]
def check_package(self, package, package_dir): def check_package(self, package, package_dir):
"""Check namespace packages' __init__ for declare_namespace""" """Check namespace packages' __init__ for declare_namespace"""
...@@ -160,25 +167,26 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -160,25 +167,26 @@ class build_py(orig.build_py, Mixin2to3):
return init_py return init_py
for pkg in self.distribution.namespace_packages: for pkg in self.distribution.namespace_packages:
if pkg==package or pkg.startswith(package+'.'): if pkg == package or pkg.startswith(package + '.'):
break break
else: else:
return init_py return init_py
f = open(init_py,'rbU') f = open(init_py, 'rbU')
if 'declare_namespace'.encode() not in f.read(): if 'declare_namespace'.encode() not in f.read():
from distutils.errors import DistutilsError from distutils.errors import DistutilsError
raise DistutilsError( raise DistutilsError(
"Namespace package problem: %s is a namespace package, but its\n" "Namespace package problem: %s is a namespace package, but "
"__init__.py does not call declare_namespace()! Please fix it.\n" "its\n__init__.py does not call declare_namespace()! Please "
'(See the setuptools manual under "Namespace Packages" for ' 'fix it.\n(See the setuptools manual under '
"details.)\n" % (package,) '"Namespace Packages" for details.)\n"' % (package,)
) )
f.close() f.close()
return init_py return init_py
def initialize_options(self): def initialize_options(self):
self.packages_checked={} self.packages_checked = {}
orig.build_py.initialize_options(self) orig.build_py.initialize_options(self)
def get_package_dir(self, package): def get_package_dir(self, package):
...@@ -202,7 +210,7 @@ class build_py(orig.build_py, Mixin2to3): ...@@ -202,7 +210,7 @@ class build_py(orig.build_py, Mixin2to3):
seen = {} seen = {}
return [ return [
f for f in files if f not in bad 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): ...@@ -210,6 +218,7 @@ def assert_relative(path):
if not os.path.isabs(path): if not os.path.isabs(path):
return path return path
from distutils.errors import DistutilsSetupError from distutils.errors import DistutilsSetupError
msg = textwrap.dedent(""" msg = textwrap.dedent("""
Error: setup script specifies an absolute path: Error: setup script specifies an absolute path:
......
import os
import glob
from distutils.util import convert_path from distutils.util import convert_path
from distutils import log from distutils import log
from distutils.errors import DistutilsError, DistutilsOptionError from distutils.errors import DistutilsError, DistutilsOptionError
import os
import glob
import setuptools
from pkg_resources import Distribution, PathMetadata, normalize_path from pkg_resources import Distribution, PathMetadata, normalize_path
from setuptools.command.easy_install import easy_install from setuptools.command.easy_install import easy_install
from setuptools.compat import PY3 from setuptools.compat import PY3
import setuptools
class develop(easy_install): class develop(easy_install):
"""Set up package for development""" """Set up package for development"""
...@@ -36,7 +37,7 @@ class develop(easy_install): ...@@ -36,7 +37,7 @@ class develop(easy_install):
self.egg_path = None self.egg_path = None
easy_install.initialize_options(self) easy_install.initialize_options(self)
self.setup_path = None 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): def finalize_options(self):
ei = self.get_finalized_command("egg_info") ei = self.get_finalized_command("egg_info")
...@@ -52,29 +53,31 @@ class develop(easy_install): ...@@ -52,29 +53,31 @@ class develop(easy_install):
# pick up setup-dir .egg files only: no .egg-info # pick up setup-dir .egg files only: no .egg-info
self.package_index.scan(glob.glob('*.egg')) 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 self.egg_base = ei.egg_base
if self.egg_path is None: if self.egg_path is None:
self.egg_path = os.path.abspath(ei.egg_base) self.egg_path = os.path.abspath(ei.egg_base)
target = normalize_path(self.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: if egg_path != target:
raise DistutilsOptionError( raise DistutilsOptionError(
"--egg-path must be a relative path from the install" "--egg-path must be a relative path from the install"
" directory to "+target " directory to " + target
) )
# Make a distribution for the package's source # Make a distribution for the package's source
self.dist = Distribution( self.dist = Distribution(
target, target,
PathMetadata(target, os.path.abspath(ei.egg_info)), 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,'/') p = self.egg_base.replace(os.sep, '/')
if p!= os.curdir: if p != os.curdir:
p = '../' * (p.count('/')+1) p = '../' * (p.count('/') + 1)
self.setup_path = p self.setup_path = p
p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) p = normalize_path(os.path.join(self.install_dir, self.egg_path, p))
if p != normalize_path(os.curdir): if p != normalize_path(os.curdir):
...@@ -103,7 +106,8 @@ class develop(easy_install): ...@@ -103,7 +106,8 @@ class develop(easy_install):
ei_cmd = self.get_finalized_command("egg_info") ei_cmd = self.get_finalized_command("egg_info")
self.egg_path = build_path self.egg_path = build_path
self.dist.location = 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: else:
# Without 2to3 inplace works fine: # Without 2to3 inplace works fine:
self.run_command('egg_info') self.run_command('egg_info')
...@@ -120,7 +124,7 @@ class develop(easy_install): ...@@ -120,7 +124,7 @@ class develop(easy_install):
# create an .egg-link in the installation dir, pointing to our egg # 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) log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
if not self.dry_run: 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.write(self.egg_path + "\n" + self.setup_path)
f.close() f.close()
# postprocess the installed distro, fixing up .pth, installing scripts, # postprocess the installed distro, fixing up .pth, installing scripts,
...@@ -133,7 +137,8 @@ class develop(easy_install): ...@@ -133,7 +137,8 @@ class develop(easy_install):
egg_link_file = open(self.egg_link) egg_link_file = open(self.egg_link)
contents = [line.rstrip() for line in egg_link_file] contents = [line.rstrip() for line in egg_link_file]
egg_link_file.close() 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) log.warn("Link points to %s: uninstall aborted", contents)
return return
if not self.dry_run: if not self.dry_run:
...@@ -147,7 +152,7 @@ class develop(easy_install): ...@@ -147,7 +152,7 @@ class develop(easy_install):
def install_egg_scripts(self, dist): def install_egg_scripts(self, dist):
if dist is not self.dist: if dist is not self.dist:
# Installing a dependency, so fall back to normal behavior # 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 # create wrapper scripts in the script dir, pointing to dist.scripts
...@@ -158,7 +163,7 @@ class develop(easy_install): ...@@ -158,7 +163,7 @@ class develop(easy_install):
for script_name in self.distribution.scripts or []: for script_name in self.distribution.scripts or []:
script_path = os.path.abspath(convert_path(script_name)) script_path = os.path.abspath(convert_path(script_name))
script_name = os.path.basename(script_path) script_name = os.path.basename(script_path)
f = open(script_path,'rU') f = open(script_path, 'rU')
script_text = f.read() script_text = f.read()
f.close() f.close()
self.install_script(dist, script_name, script_text, script_path) self.install_script(dist, script_name, script_text, script_path)
This diff is collapsed.
This diff is collapsed.
import setuptools from distutils.errors import DistutilsArgError
import inspect import inspect
import glob import glob
import warnings import warnings
import platform import platform
import distutils.command.install as orig 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 # 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 _install = orig.install
class install(orig.install): class install(orig.install):
"""Use easy_install to install the package, w/dependencies""" """Use easy_install to install the package, w/dependencies"""
user_options = orig.install.user_options + [ user_options = orig.install.user_options + [
('old-and-unmanageable', None, "Try not to use this!"), ('old-and-unmanageable', None, "Try not to use this!"),
('single-version-externally-managed', None, ('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 + [ boolean_options = orig.install.boolean_options + [
'old-and-unmanageable', 'single-version-externally-managed', 'old-and-unmanageable', 'single-version-externally-managed',
...@@ -115,7 +117,9 @@ class install(orig.install): ...@@ -115,7 +117,9 @@ class install(orig.install):
cmd.run() cmd.run()
setuptools.bootstrap_install_from = None setuptools.bootstrap_install_from = None
# XXX Python 3.1 doesn't see _nc if this is inside the class # XXX Python 3.1 doesn't see _nc if this is inside the class
install.sub_commands = [ install.sub_commands = (
cmd for cmd in orig.install.sub_commands if cmd[0] not in install._nc [cmd for cmd in orig.install.sub_commands if cmd[0] not in install._nc] +
] + install.new_commands install.new_commands
)
from distutils import log, dir_util
import os import os
import pkg_resources
from setuptools import Command from setuptools import Command
from setuptools.archive_util import unpack_archive from setuptools.archive_util import unpack_archive
from distutils import log, dir_util import pkg_resources
class install_egg_info(Command): class install_egg_info(Command):
...@@ -24,7 +24,7 @@ class install_egg_info(Command): ...@@ -24,7 +24,7 @@ class install_egg_info(Command):
ei_cmd = self.get_finalized_command("egg_info") ei_cmd = self.get_finalized_command("egg_info")
basename = pkg_resources.Distribution( basename = pkg_resources.Distribution(
None, None, ei_cmd.egg_name, ei_cmd.egg_version 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.source = ei_cmd.egg_info
self.target = os.path.join(self.install_dir, basename) self.target = os.path.join(self.install_dir, basename)
self.outputs = [self.target] self.outputs = [self.target]
...@@ -34,12 +34,11 @@ class install_egg_info(Command): ...@@ -34,12 +34,11 @@ class install_egg_info(Command):
if os.path.isdir(self.target) and not os.path.islink(self.target): if os.path.isdir(self.target) and not os.path.islink(self.target):
dir_util.remove_tree(self.target, dry_run=self.dry_run) dir_util.remove_tree(self.target, dry_run=self.dry_run)
elif os.path.exists(self.target): 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: if not self.dry_run:
pkg_resources.ensure_directory(self.target) pkg_resources.ensure_directory(self.target)
self.execute( self.execute(
self.copytree, (), self.copytree, (), "Copying %s to %s" % (self.source, self.target)
"Copying %s to %s" % (self.source, self.target)
) )
self.install_namespaces() self.install_namespaces()
...@@ -58,6 +57,7 @@ class install_egg_info(Command): ...@@ -58,6 +57,7 @@ class install_egg_info(Command):
self.outputs.append(dst) self.outputs.append(dst)
log.debug("Copying %s to %s", src, dst) log.debug("Copying %s to %s", src, dst)
return dst return dst
unpack_archive(self.source, self.target, skimmer) unpack_archive(self.source, self.target, skimmer)
def install_namespaces(self): def install_namespaces(self):
...@@ -103,3 +103,4 @@ class install_egg_info(Command): ...@@ -103,3 +103,4 @@ class install_egg_info(Command):
nsp.add('.'.join(pkg)) nsp.add('.'.join(pkg))
pkg.pop() pkg.pop()
return sorted(nsp) return sorted(nsp)
import distutils.command.install_lib as orig import distutils.command.install_lib as orig
import os import os
class install_lib(orig.install_lib): class install_lib(orig.install_lib):
"""Don't add compiled flags to filenames of non-Python files""" """Don't add compiled flags to filenames of non-Python files"""
...@@ -15,20 +16,20 @@ class install_lib(orig.install_lib): ...@@ -15,20 +16,20 @@ class install_lib(orig.install_lib):
exclude = {} exclude = {}
nsp = self.distribution.namespace_packages nsp = self.distribution.namespace_packages
svem = (nsp and self.get_finalized_command('install') svem = (nsp and self.get_finalized_command('install')
.single_version_externally_managed) .single_version_externally_managed)
if svem: if svem:
for pkg in nsp: for pkg in nsp:
parts = pkg.split('.') parts = pkg.split('.')
while parts: while parts:
pkgdir = os.path.join(self.install_dir, *parts) pkgdir = os.path.join(self.install_dir, *parts)
for f in '__init__.py', '__init__.pyc', '__init__.pyo': 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() parts.pop()
return exclude return exclude
def copy_tree( def copy_tree(
self, infile, outfile, self, infile, outfile,
preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1 preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1
): ):
assert preserve_mode and preserve_times and not preserve_symlinks assert preserve_mode and preserve_times and not preserve_symlinks
exclude = self.get_exclusions() exclude = self.get_exclusions()
...@@ -45,7 +46,8 @@ class install_lib(orig.install_lib): ...@@ -45,7 +46,8 @@ class install_lib(orig.install_lib):
def pf(src, dst): def pf(src, dst):
if dst in exclude: if dst in exclude:
log.warn("Skipping installation of %s (namespace package)",dst) log.warn("Skipping installation of %s (namespace package)",
dst)
return False return False
log.info("copying %s -> %s", src, os.path.dirname(dst)) log.info("copying %s -> %s", src, os.path.dirname(dst))
......
from distutils import log
import distutils.command.install_scripts as orig import distutils.command.install_scripts as orig
from pkg_resources import Distribution, PathMetadata, ensure_directory
import os import os
from distutils import log
from pkg_resources import Distribution, PathMetadata, ensure_directory
class install_scripts(orig.install_scripts): class install_scripts(orig.install_scripts):
"""Do normal script install, plus any egg_info wrapper scripts""" """Do normal script install, plus any egg_info wrapper scripts"""
...@@ -29,7 +31,7 @@ class install_scripts(orig.install_scripts): ...@@ -29,7 +31,7 @@ class install_scripts(orig.install_scripts):
ei_cmd.egg_name, ei_cmd.egg_version, ei_cmd.egg_name, ei_cmd.egg_version,
) )
bs_cmd = self.get_finalized_command('build_scripts') 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( is_wininst = getattr(
self.get_finalized_command("bdist_wininst"), '_is_running', False self.get_finalized_command("bdist_wininst"), '_is_running', False
) )
...@@ -39,6 +41,7 @@ class install_scripts(orig.install_scripts): ...@@ -39,6 +41,7 @@ class install_scripts(orig.install_scripts):
def write_script(self, script_name, contents, mode="t", *ignored): def write_script(self, script_name, contents, mode="t", *ignored):
"""Write an executable file to the scripts directory""" """Write an executable file to the scripts directory"""
from setuptools.command.easy_install import chmod, current_umask from setuptools.command.easy_install import chmod, current_umask
log.info("Installing %s script to %s", script_name, self.install_dir) log.info("Installing %s script to %s", script_name, self.install_dir)
target = os.path.join(self.install_dir, script_name) target = os.path.join(self.install_dir, script_name)
self.outfiles.append(target) self.outfiles.append(target)
...@@ -46,7 +49,7 @@ class install_scripts(orig.install_scripts): ...@@ -46,7 +49,7 @@ class install_scripts(orig.install_scripts):
mask = current_umask() mask = current_umask()
if not self.dry_run: if not self.dry_run:
ensure_directory(target) ensure_directory(target)
f = open(target,"w"+mode) f = open(target, "w" + mode)
f.write(contents) f.write(contents)
f.close() f.close()
chmod(target, 0o777-mask) chmod(target, 0o777 - mask)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" <assemblyIdentity version="1.0.0.0"
processorArchitecture="X86" processorArchitecture="X86"
name="%(name)s" name="%(name)s"
type="win32"/> type="win32"/>
<!-- Identify the application security requirements. --> <!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security> <security>
<requestedPrivileges> <requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/> <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges> </requestedPrivileges>
</security> </security>
</trustInfo> </trustInfo>
</assembly> </assembly>
import distutils.command.register as orig import distutils.command.register as orig
class register(orig.register): class register(orig.register):
__doc__ = orig.register.__doc__ __doc__ = orig.register.__doc__
......
import os
from setuptools import Command
from setuptools.compat import basestring
from distutils.util import convert_path from distutils.util import convert_path
from distutils import log from distutils import log
from distutils.errors import DistutilsOptionError from distutils.errors import DistutilsOptionError
import os
from setuptools import Command
from setuptools.compat import basestring
class rotate(Command): class rotate(Command):
"""Delete older distributions""" """Delete older distributions"""
description = "delete older distributions, keeping N newest files" description = "delete older distributions, keeping N newest files"
user_options = [ user_options = [
('match=', 'm', "patterns to match (required)"), ('match=', 'm', "patterns to match (required)"),
('dist-dir=', 'd', "directory where the distributions are"), ('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 = [] boolean_options = []
...@@ -38,21 +40,22 @@ class rotate(Command): ...@@ -38,21 +40,22 @@ class rotate(Command):
self.match = [ self.match = [
convert_path(p.strip()) for p in self.match.split(',') 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): def run(self):
self.run_command("egg_info") self.run_command("egg_info")
from glob import glob from glob import glob
for pattern in self.match: for pattern in self.match:
pattern = self.distribution.get_name()+'*'+pattern pattern = self.distribution.get_name() + '*' + pattern
files = glob(os.path.join(self.dist_dir,pattern)) files = glob(os.path.join(self.dist_dir, pattern))
files = [(os.path.getmtime(f),f) for f in files] files = [(os.path.getmtime(f), f) for f in files]
files.sort() files.sort()
files.reverse() files.reverse()
log.info("%d file(s) matching %s", len(files), pattern) log.info("%d file(s) matching %s", len(files), pattern)
files = files[self.keep:] files = files[self.keep:]
for (t,f) in files: for (t, f) in files:
log.info("Deleting %s", f) log.info("Deleting %s", f)
if not self.dry_run: if not self.dry_run:
os.unlink(f) os.unlink(f)
import distutils, os
from setuptools import Command
from setuptools.command.setopt import edit_config, option_base from setuptools.command.setopt import edit_config, option_base
class saveopts(option_base): class saveopts(option_base):
"""Save command-line options to a file""" """Save command-line options to a file"""
...@@ -13,12 +12,11 @@ class saveopts(option_base): ...@@ -13,12 +12,11 @@ class saveopts(option_base):
for cmd in dist.command_options: for cmd in dist.command_options:
if cmd=='saveopts': if cmd == 'saveopts':
continue # don't save our own options! continue # don't save our own options!
for opt,(src,val) in dist.get_option_dict(cmd).items(): for opt, (src, val) in dist.get_option_dict(cmd).items():
if src=="command line": if src == "command line":
settings.setdefault(cmd,{})[opt] = val settings.setdefault(cmd, {})[opt] = val
edit_config(self.filename, settings, self.dry_run) edit_config(self.filename, settings, self.dry_run)
from glob import glob
from distutils.util import convert_path
from distutils import log
import distutils.command.sdist as orig
import os import os
import re import re
import sys 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 import svn_utils
from setuptools.compat import PY3 from setuptools.compat import PY3
import pkg_resources
READMES = ('README', 'README.rst', 'README.txt') READMES = ('README', 'README.rst', 'README.txt')
...@@ -20,7 +20,7 @@ def walk_revctrl(dirname=''): ...@@ -20,7 +20,7 @@ def walk_revctrl(dirname=''):
yield item yield item
#TODO will need test case # TODO will need test case
class re_finder(object): class re_finder(object):
""" """
Finder that locates files based on entries in a file matched by a Finder that locates files based on entries in a file matched by a
...@@ -33,7 +33,7 @@ class re_finder(object): ...@@ -33,7 +33,7 @@ class re_finder(object):
self.entries_path = convert_path(path) self.entries_path = convert_path(path)
def _finder(self, dirname, filename): def _finder(self, dirname, filename):
f = open(filename,'rU') f = open(filename, 'rU')
try: try:
data = f.read() data = f.read()
finally: finally:
...@@ -51,12 +51,13 @@ class re_finder(object): ...@@ -51,12 +51,13 @@ class re_finder(object):
if not os.path.isfile(path): if not os.path.isfile(path):
# entries file doesn't exist # entries file doesn't exist
return return
for path in self._finder(dirname,path): for path in self._finder(dirname, path):
if os.path.isfile(path): if os.path.isfile(path):
yield path yield path
elif os.path.isdir(path): elif os.path.isdir(path):
for item in self.find(path): for item in self.find(path):
yield item yield item
__call__ = find __call__ = find
...@@ -85,7 +86,7 @@ class sdist(orig.sdist): ...@@ -85,7 +86,7 @@ class sdist(orig.sdist):
('dist-dir=', 'd', ('dist-dir=', 'd',
"directory to put the source distribution archive(s) in " "directory to put the source distribution archive(s) in "
"[default: dist]"), "[default: dist]"),
] ]
negative_opt = {} negative_opt = {}
...@@ -93,7 +94,7 @@ class sdist(orig.sdist): ...@@ -93,7 +94,7 @@ class sdist(orig.sdist):
self.run_command('egg_info') self.run_command('egg_info')
ei_cmd = self.get_finalized_command('egg_info') ei_cmd = self.get_finalized_command('egg_info')
self.filelist = ei_cmd.filelist 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() self.check_readme()
# Run sub commands # Run sub commands
...@@ -103,12 +104,13 @@ class sdist(orig.sdist): ...@@ -103,12 +104,13 @@ class sdist(orig.sdist):
# Call check_metadata only if no 'check' command # Call check_metadata only if no 'check' command
# (distutils <= 2.6) # (distutils <= 2.6)
import distutils.command import distutils.command
if 'check' not in distutils.command.__all__: if 'check' not in distutils.command.__all__:
self.check_metadata() self.check_metadata()
self.make_distribution() self.make_distribution()
dist_files = getattr(self.distribution,'dist_files',[]) dist_files = getattr(self.distribution, 'dist_files', [])
for file in self.archive_files: for file in self.archive_files:
data = ('sdist', '', file) data = ('sdist', '', file)
if data not in dist_files: if data not in dist_files:
...@@ -124,13 +126,14 @@ class sdist(orig.sdist): ...@@ -124,13 +126,14 @@ class sdist(orig.sdist):
except: except:
sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close()
raise raise
# Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle # 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 # has been fixed, so only override the method if we're using an earlier
# Python. # Python.
has_leaky_handle = ( has_leaky_handle = (
sys.version_info < (2,7,2) sys.version_info < (2, 7, 2)
or (3,0) <= sys.version_info < (3,1,4) or (3, 0) <= sys.version_info < (3, 1, 4)
or (3,2) <= sys.version_info < (3,2,1) or (3, 2) <= sys.version_info < (3, 2, 1)
) )
if has_leaky_handle: if has_leaky_handle:
read_template = __read_template_hack read_template = __read_template_hack
...@@ -194,7 +197,8 @@ class sdist(orig.sdist): ...@@ -194,7 +197,8 @@ class sdist(orig.sdist):
return return
else: else:
self.warn( 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): def make_release_tree(self, base_dir, files):
...@@ -202,7 +206,7 @@ class sdist(orig.sdist): ...@@ -202,7 +206,7 @@ class sdist(orig.sdist):
# Save any egg_info command line options used to create this sdist # Save any egg_info command line options used to create this sdist
dest = os.path.join(base_dir, 'setup.cfg') 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 # unlink and re-copy, since it might be hard-linked, and
# we don't want to change the source version # we don't want to change the source version
os.unlink(dest) os.unlink(dest)
...@@ -220,7 +224,8 @@ class sdist(orig.sdist): ...@@ -220,7 +224,8 @@ class sdist(orig.sdist):
first_line = fp.readline() first_line = fp.readline()
finally: finally:
fp.close() 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): def read_manifest(self):
"""Read the manifest file (named by 'self.manifest') and use it to """Read the manifest file (named by 'self.manifest') and use it to
......
import os
import distutils
from setuptools import Command
from distutils.util import convert_path from distutils.util import convert_path
from distutils import log from distutils import log
from distutils.errors import DistutilsOptionError from distutils.errors import DistutilsOptionError
import distutils
import os
from setuptools import Command
__all__ = ['config_file', 'edit_config', 'option_base', 'setopt'] __all__ = ['config_file', 'edit_config', 'option_base', 'setopt']
...@@ -13,19 +15,20 @@ def config_file(kind="local"): ...@@ -13,19 +15,20 @@ def config_file(kind="local"):
`kind` must be one of "local", "global", or "user" `kind` must be one of "local", "global", or "user"
""" """
if kind=='local': if kind == 'local':
return 'setup.cfg' return 'setup.cfg'
if kind=='global': if kind == 'global':
return os.path.join( return os.path.join(
os.path.dirname(distutils.__file__),'distutils.cfg' os.path.dirname(distutils.__file__), 'distutils.cfg'
) )
if kind=='user': if kind == 'user':
dot = os.name=='posix' and '.' or '' dot = os.name == 'posix' and '.' or ''
return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot)) return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot))
raise ValueError( raise ValueError(
"config_file() type must be 'local', 'global', or 'user'", kind "config_file() type must be 'local', 'global', or 'user'", kind
) )
def edit_config(filename, settings, dry_run=False): def edit_config(filename, settings, dry_run=False):
"""Edit a configuration file to include `settings` """Edit a configuration file to include `settings`
...@@ -35,6 +38,7 @@ def edit_config(filename, settings, dry_run=False): ...@@ -35,6 +38,7 @@ def edit_config(filename, settings, dry_run=False):
A setting of ``None`` means to delete that setting. A setting of ``None`` means to delete that setting.
""" """
from setuptools.compat import ConfigParser from setuptools.compat import ConfigParser
log.debug("Reading configuration from %s", filename) log.debug("Reading configuration from %s", filename)
opts = ConfigParser.RawConfigParser() opts = ConfigParser.RawConfigParser()
opts.read([filename]) opts.read([filename])
...@@ -46,39 +50,40 @@ def edit_config(filename, settings, dry_run=False): ...@@ -46,39 +50,40 @@ def edit_config(filename, settings, dry_run=False):
if not opts.has_section(section): if not opts.has_section(section):
log.debug("Adding new section [%s] to %s", section, filename) log.debug("Adding new section [%s] to %s", section, filename)
opts.add_section(section) opts.add_section(section)
for option,value in options.items(): for option, value in options.items():
if value is None: if value is None:
log.debug( log.debug(
"Deleting %s.%s from %s", "Deleting %s.%s from %s",
section, option, filename section, option, filename
) )
opts.remove_option(section,option) opts.remove_option(section, option)
if not opts.options(section): if not opts.options(section):
log.info("Deleting empty [%s] section from %s", log.info("Deleting empty [%s] section from %s",
section, filename) section, filename)
opts.remove_section(section) opts.remove_section(section)
else: else:
log.debug( log.debug(
"Setting %s.%s to %r in %s", "Setting %s.%s to %r in %s",
section, option, value, filename section, option, value, filename
) )
opts.set(section,option,value) opts.set(section, option, value)
log.info("Writing %s", filename) log.info("Writing %s", filename)
if not dry_run: if not dry_run:
with open(filename, 'w') as f: with open(filename, 'w') as f:
opts.write(f) opts.write(f)
class option_base(Command): class option_base(Command):
"""Abstract base class for commands that mess with config files""" """Abstract base class for commands that mess with config files"""
user_options = [ user_options = [
('global-config', 'g', ('global-config', 'g',
"save options to the site-wide distutils.cfg file"), "save options to the site-wide distutils.cfg file"),
('user-config', 'u', ('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', ('filename=', 'f',
"configuration file to use (default=setup.cfg)"), "configuration file to use (default=setup.cfg)"),
] ]
boolean_options = [ boolean_options = [
...@@ -100,7 +105,7 @@ class option_base(Command): ...@@ -100,7 +105,7 @@ class option_base(Command):
filenames.append(self.filename) filenames.append(self.filename)
if not filenames: if not filenames:
filenames.append(config_file('local')) filenames.append(config_file('local'))
if len(filenames)>1: if len(filenames) > 1:
raise DistutilsOptionError( raise DistutilsOptionError(
"Must specify only one configuration file option", "Must specify only one configuration file option",
filenames filenames
...@@ -115,9 +120,9 @@ class setopt(option_base): ...@@ -115,9 +120,9 @@ class setopt(option_base):
user_options = [ user_options = [
('command=', 'c', 'command to set an option for'), ('command=', 'c', 'command to set an option for'),
('option=', 'o', 'option to set'), ('option=', 'o', 'option to set'),
('set-value=', 's', 'value of the option'), ('set-value=', 's', 'value of the option'),
('remove', 'r', 'remove (unset) the value'), ('remove', 'r', 'remove (unset) the value'),
] + option_base.user_options ] + option_base.user_options
boolean_options = option_base.boolean_options + ['remove'] boolean_options = option_base.boolean_options + ['remove']
...@@ -139,7 +144,7 @@ class setopt(option_base): ...@@ -139,7 +144,7 @@ class setopt(option_base):
def run(self): def run(self):
edit_config( edit_config(
self.filename, { self.filename, {
self.command: {self.option.replace('-','_'):self.set_value} self.command: {self.option.replace('-', '_'): self.set_value}
}, },
self.dry_run self.dry_run
) )
import unittest
from unittest import TestLoader
from setuptools import Command
from distutils.errors import DistutilsOptionError from distutils.errors import DistutilsOptionError
from unittest import TestLoader
import unittest
import sys 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.compat import PY3
from setuptools.py31compat import unittest_main from setuptools.py31compat import unittest_main
class ScanningLoader(TestLoader): class ScanningLoader(TestLoader):
def loadTestsFromModule(self, module): def loadTestsFromModule(self, module):
"""Return a suite of all tests cases contained in the given module """Return a suite of all tests cases contained in the given module
...@@ -34,7 +32,7 @@ class ScanningLoader(TestLoader): ...@@ -34,7 +32,7 @@ class ScanningLoader(TestLoader):
submodule = module.__name__ + '.' + file[:-3] submodule = module.__name__ + '.' + file[:-3]
else: else:
if resource_exists(module.__name__, file + '/__init__.py'): if resource_exists(module.__name__, file + '/__init__.py'):
submodule = module.__name__+'.'+file submodule = module.__name__ + '.' + file
else: else:
continue continue
tests.append(self.loadTestsFromName(submodule)) tests.append(self.loadTestsFromName(submodule))
...@@ -42,19 +40,18 @@ class ScanningLoader(TestLoader): ...@@ -42,19 +40,18 @@ class ScanningLoader(TestLoader):
if len(tests) != 1: if len(tests) != 1:
return self.suiteClass(tests) return self.suiteClass(tests)
else: 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): class test(Command):
"""Command to run unit tests after in-place build""" """Command to run unit tests after in-place build"""
description = "run unit tests after in-place build" description = "run unit tests after in-place build"
user_options = [ user_options = [
('test-module=','m', "Run 'test_suite' in specified module"), ('test-module=', 'm', "Run 'test_suite' in specified module"),
('test-suite=','s', ('test-suite=', 's',
"Test suite to run (e.g. 'some_module.test_suite')"), "Test suite to run (e.g. 'some_module.test_suite')"),
('test-runner=', 'r', "Test runner to use"), ('test-runner=', 'r', "Test runner to use"),
] ]
...@@ -79,7 +76,7 @@ class test(Command): ...@@ -79,7 +76,7 @@ class test(Command):
self.test_args = [self.test_suite] self.test_args = [self.test_suite]
if self.verbose: if self.verbose:
self.test_args.insert(0,'--verbose') self.test_args.insert(0, '--verbose')
if self.test_loader is None: if self.test_loader is None:
self.test_loader = getattr(self.distribution, 'test_loader', None) self.test_loader = getattr(self.distribution, 'test_loader', None)
if self.test_loader is None: if self.test_loader is None:
...@@ -132,7 +129,8 @@ class test(Command): ...@@ -132,7 +129,8 @@ class test(Command):
def run(self): def run(self):
if self.distribution.install_requires: 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: if self.distribution.tests_require:
self.distribution.fetch_build_eggs(self.distribution.tests_require) self.distribution.fetch_build_eggs(self.distribution.tests_require)
...@@ -161,7 +159,7 @@ class test(Command): ...@@ -161,7 +159,7 @@ class test(Command):
list(map(sys.modules.__delitem__, del_modules)) list(map(sys.modules.__delitem__, del_modules))
unittest_main( unittest_main(
None, None, [unittest.__file__]+self.test_args, None, None, [unittest.__file__] + self.test_args,
testLoader=self._resolve_as_ep(self.test_loader), testLoader=self._resolve_as_ep(self.test_loader),
testRunner=self._resolve_as_ep(self.test_runner), testRunner=self._resolve_as_ep(self.test_runner),
) )
......
...@@ -5,6 +5,10 @@ Implements a Distutils 'upload_docs' subcommand (upload documentation to ...@@ -5,6 +5,10 @@ Implements a Distutils 'upload_docs' subcommand (upload documentation to
PyPI's pythonhosted.org). 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 os
import socket import socket
import zipfile import zipfile
...@@ -12,14 +16,9 @@ import tempfile ...@@ -12,14 +16,9 @@ import tempfile
import sys import sys
import shutil import shutil
from base64 import standard_b64encode from setuptools.compat import httplib, urlparse, unicode, iteritems, PY3
from pkg_resources import iter_entry_points 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' errors = 'surrogateescape' if PY3 else 'strict'
...@@ -33,7 +32,6 @@ def b(s, encoding='utf-8'): ...@@ -33,7 +32,6 @@ def b(s, encoding='utf-8'):
class upload_docs(upload): class upload_docs(upload):
description = 'Upload documentation to PyPI' description = 'Upload documentation to PyPI'
user_options = [ user_options = [
...@@ -42,7 +40,7 @@ class upload_docs(upload): ...@@ -42,7 +40,7 @@ class upload_docs(upload):
('show-response', None, ('show-response', None,
'display full response text from server'), 'display full response text from server'),
('upload-dir=', None, 'directory to upload'), ('upload-dir=', None, 'directory to upload'),
] ]
boolean_options = upload.boolean_options boolean_options = upload.boolean_options
def has_sphinx(self): def has_sphinx(self):
...@@ -159,7 +157,7 @@ class upload_docs(upload): ...@@ -159,7 +157,7 @@ class upload_docs(upload):
elif schema == 'https': elif schema == 'https':
conn = httplib.HTTPSConnection(netloc) conn = httplib.HTTPSConnection(netloc)
else: else:
raise AssertionError("unsupported schema "+schema) raise AssertionError("unsupported schema " + schema)
data = '' data = ''
try: try:
...@@ -190,4 +188,4 @@ class upload_docs(upload): ...@@ -190,4 +188,4 @@ class upload_docs(upload):
self.announce('Upload failed (%s): %s' % (r.status, r.reason), self.announce('Upload failed (%s): %s' % (r.status, r.reason),
log.ERROR) log.ERROR)
if self.show_response: if self.show_response:
print('-'*75, r.read(), '-'*75) print('-' * 75, r.read(), '-' * 75)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment