Eliminado venv y www del repositorio, agrege un requirements igual
This commit is contained in:
@@ -2,8 +2,7 @@ __all__ = [
|
||||
'alias', 'bdist_egg', 'bdist_rpm', 'build_ext', 'build_py', 'develop',
|
||||
'easy_install', 'egg_info', 'install', 'install_lib', 'rotate', 'saveopts',
|
||||
'sdist', 'setopt', 'test', 'install_egg_info', 'install_scripts',
|
||||
'register', 'bdist_wininst', 'upload_docs', 'upload', 'build_clib',
|
||||
'dist_info',
|
||||
'bdist_wininst', 'upload_docs', 'build_clib', 'dist_info',
|
||||
]
|
||||
|
||||
from distutils.command.bdist import bdist
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,13 +11,14 @@ import os
|
||||
import re
|
||||
import textwrap
|
||||
import marshal
|
||||
import warnings
|
||||
|
||||
from setuptools.extern import six
|
||||
|
||||
from pkg_resources import get_build_platform, Distribution, ensure_directory
|
||||
from pkg_resources import EntryPoint
|
||||
from setuptools.extension import Library
|
||||
from setuptools import Command
|
||||
from setuptools import Command, SetuptoolsDeprecationWarning
|
||||
|
||||
try:
|
||||
# Python 2.7 or >=3.2
|
||||
@@ -54,10 +55,11 @@ def write_stub(resource, pyfile):
|
||||
_stub_template = textwrap.dedent("""
|
||||
def __bootstrap__():
|
||||
global __bootstrap__, __loader__, __file__
|
||||
import sys, pkg_resources, imp
|
||||
import sys, pkg_resources
|
||||
from importlib.machinery import ExtensionFileLoader
|
||||
__file__ = pkg_resources.resource_filename(__name__, %r)
|
||||
__loader__ = None; del __bootstrap__, __loader__
|
||||
imp.load_dynamic(__name__,__file__)
|
||||
ExtensionFileLoader(__name__,__file__).load_module()
|
||||
__bootstrap__()
|
||||
""").lstrip()
|
||||
with open(pyfile, 'w') as f:
|
||||
@@ -278,13 +280,19 @@ class bdist_egg(Command):
|
||||
if ep is None:
|
||||
return 'w' # not an eggsecutable, do it the usual way.
|
||||
|
||||
warnings.warn(
|
||||
"Eggsecutables are deprecated and will be removed in a future "
|
||||
"version.",
|
||||
SetuptoolsDeprecationWarning
|
||||
)
|
||||
|
||||
if not ep.attrs or ep.extras:
|
||||
raise DistutilsSetupError(
|
||||
"eggsecutable entry point (%r) cannot have 'extras' "
|
||||
"or refer to a module" % (ep,)
|
||||
)
|
||||
|
||||
pyver = sys.version[:3]
|
||||
pyver = '{}.{}'.format(*sys.version_info)
|
||||
pkg = ep.module_name
|
||||
full = '.'.join(ep.attrs)
|
||||
base = ep.attrs[0]
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import distutils.command.bdist_wininst as orig
|
||||
import warnings
|
||||
|
||||
from setuptools import SetuptoolsDeprecationWarning
|
||||
|
||||
|
||||
class bdist_wininst(orig.bdist_wininst):
|
||||
@@ -14,6 +17,12 @@ class bdist_wininst(orig.bdist_wininst):
|
||||
return cmd
|
||||
|
||||
def run(self):
|
||||
warnings.warn(
|
||||
"bdist_wininst is deprecated and will be removed in a future "
|
||||
"version. Use bdist_wheel (wheel packages) instead.",
|
||||
SetuptoolsDeprecationWarning
|
||||
)
|
||||
|
||||
self._is_running = True
|
||||
try:
|
||||
orig.bdist_wininst.run(self)
|
||||
|
||||
@@ -25,9 +25,9 @@ class build_clib(orig.build_clib):
|
||||
sources = build_info.get('sources')
|
||||
if sources is None or not isinstance(sources, (list, tuple)):
|
||||
raise DistutilsSetupError(
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'sources' must be present and must be "
|
||||
"a list of source filenames" % lib_name)
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'sources' must be present and must be "
|
||||
"a list of source filenames" % lib_name)
|
||||
sources = list(sources)
|
||||
|
||||
log.info("building '%s' library", lib_name)
|
||||
@@ -38,9 +38,9 @@ class build_clib(orig.build_clib):
|
||||
obj_deps = build_info.get('obj_deps', dict())
|
||||
if not isinstance(obj_deps, dict):
|
||||
raise DistutilsSetupError(
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'obj_deps' must be a dictionary of "
|
||||
"type 'source: list'" % lib_name)
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'obj_deps' must be a dictionary of "
|
||||
"type 'source: list'" % lib_name)
|
||||
dependencies = []
|
||||
|
||||
# Get the global dependencies that are specified by the '' key.
|
||||
@@ -48,9 +48,9 @@ class build_clib(orig.build_clib):
|
||||
global_deps = obj_deps.get('', list())
|
||||
if not isinstance(global_deps, (list, tuple)):
|
||||
raise DistutilsSetupError(
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'obj_deps' must be a dictionary of "
|
||||
"type 'source: list'" % lib_name)
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'obj_deps' must be a dictionary of "
|
||||
"type 'source: list'" % lib_name)
|
||||
|
||||
# Build the list to be used by newer_pairwise_group
|
||||
# each source will be auto-added to its dependencies.
|
||||
@@ -60,39 +60,42 @@ class build_clib(orig.build_clib):
|
||||
extra_deps = obj_deps.get(source, list())
|
||||
if not isinstance(extra_deps, (list, tuple)):
|
||||
raise DistutilsSetupError(
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'obj_deps' must be a dictionary of "
|
||||
"type 'source: list'" % lib_name)
|
||||
"in 'libraries' option (library '%s'), "
|
||||
"'obj_deps' must be a dictionary of "
|
||||
"type 'source: list'" % lib_name)
|
||||
src_deps.extend(extra_deps)
|
||||
dependencies.append(src_deps)
|
||||
|
||||
expected_objects = self.compiler.object_filenames(
|
||||
sources,
|
||||
output_dir=self.build_temp
|
||||
)
|
||||
sources,
|
||||
output_dir=self.build_temp,
|
||||
)
|
||||
|
||||
if newer_pairwise_group(dependencies, expected_objects) != ([], []):
|
||||
if (
|
||||
newer_pairwise_group(dependencies, expected_objects)
|
||||
!= ([], [])
|
||||
):
|
||||
# First, compile the source code to object files in the library
|
||||
# directory. (This should probably change to putting object
|
||||
# files in a temporary build directory.)
|
||||
macros = build_info.get('macros')
|
||||
include_dirs = build_info.get('include_dirs')
|
||||
cflags = build_info.get('cflags')
|
||||
objects = self.compiler.compile(
|
||||
sources,
|
||||
output_dir=self.build_temp,
|
||||
macros=macros,
|
||||
include_dirs=include_dirs,
|
||||
extra_postargs=cflags,
|
||||
debug=self.debug
|
||||
)
|
||||
self.compiler.compile(
|
||||
sources,
|
||||
output_dir=self.build_temp,
|
||||
macros=macros,
|
||||
include_dirs=include_dirs,
|
||||
extra_postargs=cflags,
|
||||
debug=self.debug
|
||||
)
|
||||
|
||||
# Now "link" the object files together into a static library.
|
||||
# (On Unix at least, this isn't really linking -- it just
|
||||
# builds an archive. Whatever.)
|
||||
self.compiler.create_static_lib(
|
||||
expected_objects,
|
||||
lib_name,
|
||||
output_dir=self.build_clib,
|
||||
debug=self.debug
|
||||
)
|
||||
expected_objects,
|
||||
lib_name,
|
||||
output_dir=self.build_clib,
|
||||
debug=self.debug
|
||||
)
|
||||
|
||||
@@ -14,7 +14,8 @@ from setuptools.extern import six
|
||||
if six.PY2:
|
||||
import imp
|
||||
|
||||
EXTENSION_SUFFIXES = [s for s, _, tp in imp.get_suffixes() if tp == imp.C_EXTENSION]
|
||||
EXTENSION_SUFFIXES = [
|
||||
s for s, _, tp in imp.get_suffixes() if tp == imp.C_EXTENSION]
|
||||
else:
|
||||
from importlib.machinery import EXTENSION_SUFFIXES
|
||||
|
||||
@@ -29,7 +30,7 @@ except ImportError:
|
||||
|
||||
# make sure _config_vars is initialized
|
||||
get_config_var("LDSHARED")
|
||||
from distutils.sysconfig import _config_vars as _CONFIG_VARS
|
||||
from distutils.sysconfig import _config_vars as _CONFIG_VARS # noqa
|
||||
|
||||
|
||||
def _customize_compiler_for_shlib(compiler):
|
||||
@@ -65,7 +66,9 @@ elif os.name != 'nt':
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if_dl = lambda s: s if have_rtld else ''
|
||||
|
||||
def if_dl(s):
|
||||
return s if have_rtld else ''
|
||||
|
||||
|
||||
def get_abi3_suffix():
|
||||
@@ -113,7 +116,7 @@ class build_ext(_build_ext):
|
||||
if fullname in self.ext_map:
|
||||
ext = self.ext_map[fullname]
|
||||
use_abi3 = (
|
||||
six.PY3
|
||||
not six.PY2
|
||||
and getattr(ext, 'py_limited_api')
|
||||
and get_abi3_suffix()
|
||||
)
|
||||
@@ -251,7 +254,8 @@ class build_ext(_build_ext):
|
||||
'\n'.join([
|
||||
"def __bootstrap__():",
|
||||
" global __bootstrap__, __file__, __loader__",
|
||||
" import sys, os, pkg_resources, imp" + if_dl(", dl"),
|
||||
" import sys, os, pkg_resources" + if_dl(", dl"),
|
||||
" from importlib.machinery import ExtensionFileLoader",
|
||||
" __file__ = pkg_resources.resource_filename"
|
||||
"(__name__,%r)"
|
||||
% os.path.basename(ext._file_name),
|
||||
@@ -263,7 +267,8 @@ class build_ext(_build_ext):
|
||||
" try:",
|
||||
" os.chdir(os.path.dirname(__file__))",
|
||||
if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"),
|
||||
" imp.load_dynamic(__name__,__file__)",
|
||||
" ExtensionFileLoader(__name__,",
|
||||
" __file__).load_module()",
|
||||
" finally:",
|
||||
if_dl(" sys.setdlopenflags(old_flags)"),
|
||||
" os.chdir(old_dir)",
|
||||
|
||||
@@ -7,6 +7,7 @@ import textwrap
|
||||
import io
|
||||
import distutils.errors
|
||||
import itertools
|
||||
import stat
|
||||
|
||||
from setuptools.extern import six
|
||||
from setuptools.extern.six.moves import map, filter, filterfalse
|
||||
@@ -20,6 +21,10 @@ except ImportError:
|
||||
"do nothing"
|
||||
|
||||
|
||||
def make_writable(target):
|
||||
os.chmod(target, os.stat(target).st_mode | stat.S_IWRITE)
|
||||
|
||||
|
||||
class build_py(orig.build_py, Mixin2to3):
|
||||
"""Enhanced 'build_py' command that includes data files with packages
|
||||
|
||||
@@ -121,6 +126,7 @@ class build_py(orig.build_py, Mixin2to3):
|
||||
self.mkpath(os.path.dirname(target))
|
||||
srcfile = os.path.join(src_dir, filename)
|
||||
outf, copied = self.copy_file(srcfile, target)
|
||||
make_writable(target)
|
||||
srcfile = os.path.abspath(srcfile)
|
||||
if (copied and
|
||||
srcfile in self.distribution.convert_2to3_doctests):
|
||||
|
||||
@@ -108,7 +108,7 @@ class develop(namespaces.DevelopInstaller, easy_install):
|
||||
return path_to_setup
|
||||
|
||||
def install_for_development(self):
|
||||
if six.PY3 and getattr(self.distribution, 'use_2to3', False):
|
||||
if not six.PY2 and getattr(self.distribution, 'use_2to3', False):
|
||||
# If we run 2to3 we can not do this inplace:
|
||||
|
||||
# Ensure metadata is up-to-date
|
||||
@@ -139,7 +139,6 @@ class develop(namespaces.DevelopInstaller, easy_install):
|
||||
self.reinitialize_command('build_ext', inplace=1)
|
||||
self.run_command('build_ext')
|
||||
|
||||
self.install_site_py() # ensure that target dir is site-safe
|
||||
if setuptools.bootstrap_install_from:
|
||||
self.easy_install(setuptools.bootstrap_install_from)
|
||||
setuptools.bootstrap_install_from = None
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Easy Install
|
||||
------------
|
||||
@@ -64,7 +63,7 @@ from pkg_resources import (
|
||||
Distribution, PathMetadata, EggMetadata, WorkingSet, DistributionNotFound,
|
||||
VersionConflict, DEVELOP_DIST,
|
||||
)
|
||||
import pkg_resources.py31compat
|
||||
import pkg_resources
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
@@ -121,7 +120,8 @@ else:
|
||||
return False
|
||||
|
||||
|
||||
_one_liner = lambda text: textwrap.dedent(text).strip().replace('\n', '; ')
|
||||
def _one_liner(text):
|
||||
return textwrap.dedent(text).strip().replace('\n', '; ')
|
||||
|
||||
|
||||
class easy_install(Command):
|
||||
@@ -156,19 +156,16 @@ class easy_install(Command):
|
||||
"allow building eggs from local checkouts"),
|
||||
('version', None, "print version information and exit"),
|
||||
('no-find-links', None,
|
||||
"Don't load find-links defined in packages being installed")
|
||||
"Don't load find-links defined in packages being installed"),
|
||||
('user', None, "install in user site-package '%s'" % site.USER_SITE)
|
||||
]
|
||||
boolean_options = [
|
||||
'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy',
|
||||
'editable',
|
||||
'no-deps', 'local-snapshots-ok', 'version'
|
||||
'no-deps', 'local-snapshots-ok', 'version',
|
||||
'user'
|
||||
]
|
||||
|
||||
if site.ENABLE_USER_SITE:
|
||||
help_msg = "install in user site-package '%s'" % site.USER_SITE
|
||||
user_options.append(('user', None, help_msg))
|
||||
boolean_options.append('user')
|
||||
|
||||
negative_opt = {'always-unzip': 'zip-ok'}
|
||||
create_index = PackageIndex
|
||||
|
||||
@@ -208,7 +205,6 @@ class easy_install(Command):
|
||||
self.pth_file = self.always_copy_from = None
|
||||
self.site_dirs = None
|
||||
self.installed_projects = {}
|
||||
self.sitepy_installed = False
|
||||
# Always read easy_install options, even if we are subclassed, or have
|
||||
# an independent instance created. This ensures that defaults will
|
||||
# always come from the standard configuration file(s)' "easy_install"
|
||||
@@ -241,7 +237,7 @@ class easy_install(Command):
|
||||
"""
|
||||
Render the Setuptools version and installation details, then exit.
|
||||
"""
|
||||
ver = sys.version[:3]
|
||||
ver = '{}.{}'.format(*sys.version_info)
|
||||
dist = get_distribution('setuptools')
|
||||
tmpl = 'setuptools {dist.version} from {dist.location} (Python {ver})'
|
||||
print(tmpl.format(**locals()))
|
||||
@@ -272,6 +268,9 @@ class easy_install(Command):
|
||||
self.config_vars['userbase'] = self.install_userbase
|
||||
self.config_vars['usersite'] = self.install_usersite
|
||||
|
||||
elif self.user:
|
||||
log.warn("WARNING: The user site-packages directory is disabled.")
|
||||
|
||||
self._fix_install_dir_for_user_site()
|
||||
|
||||
self.expand_basedirs()
|
||||
@@ -356,8 +355,10 @@ class easy_install(Command):
|
||||
self.optimize = int(self.optimize)
|
||||
if not (0 <= self.optimize <= 2):
|
||||
raise ValueError
|
||||
except ValueError:
|
||||
raise DistutilsOptionError("--optimize must be 0, 1, or 2")
|
||||
except ValueError as e:
|
||||
raise DistutilsOptionError(
|
||||
"--optimize must be 0, 1, or 2"
|
||||
) from e
|
||||
|
||||
if self.editable and not self.build_directory:
|
||||
raise DistutilsArgError(
|
||||
@@ -410,7 +411,13 @@ class easy_install(Command):
|
||||
]
|
||||
self._expand_attrs(dirs)
|
||||
|
||||
def run(self):
|
||||
def run(self, show_deprecation=True):
|
||||
if show_deprecation:
|
||||
self.announce(
|
||||
"WARNING: The easy_install command is deprecated "
|
||||
"and will be removed in a future version.",
|
||||
log.WARN,
|
||||
)
|
||||
if self.verbose != self.distribution.verbose:
|
||||
log.set_verbosity(self.verbose)
|
||||
try:
|
||||
@@ -453,6 +460,12 @@ class easy_install(Command):
|
||||
instdir = normalize_path(self.install_dir)
|
||||
pth_file = os.path.join(instdir, 'easy-install.pth')
|
||||
|
||||
if not os.path.exists(instdir):
|
||||
try:
|
||||
os.makedirs(instdir)
|
||||
except (OSError, IOError):
|
||||
self.cant_write_to_target()
|
||||
|
||||
# Is it a configured, PYTHONPATH, implicit, or explicit site dir?
|
||||
is_site_dir = instdir in self.all_site_dirs
|
||||
|
||||
@@ -472,8 +485,9 @@ class easy_install(Command):
|
||||
self.cant_write_to_target()
|
||||
|
||||
if not is_site_dir and not self.multi_version:
|
||||
# Can't install non-multi to non-site dir
|
||||
raise DistutilsError(self.no_default_version_msg())
|
||||
# Can't install non-multi to non-site dir with easy_install
|
||||
pythonpath = os.environ.get('PYTHONPATH', '')
|
||||
log.warn(self.__no_default_msg, self.install_dir, pythonpath)
|
||||
|
||||
if is_site_dir:
|
||||
if self.pth_file is None:
|
||||
@@ -481,12 +495,8 @@ class easy_install(Command):
|
||||
else:
|
||||
self.pth_file = None
|
||||
|
||||
if instdir not in map(normalize_path, _pythonpath()):
|
||||
# only PYTHONPATH dirs need a site.py, so pretend it's there
|
||||
self.sitepy_installed = True
|
||||
elif self.multi_version and not os.path.exists(pth_file):
|
||||
self.sitepy_installed = True # don't need site.py in this case
|
||||
self.pth_file = None # and don't create a .pth file
|
||||
if self.multi_version and not os.path.exists(pth_file):
|
||||
self.pth_file = None # don't create a .pth file
|
||||
self.install_dir = instdir
|
||||
|
||||
__cant_write_msg = textwrap.dedent("""
|
||||
@@ -501,13 +511,13 @@ class easy_install(Command):
|
||||
the distutils default setting) was:
|
||||
|
||||
%s
|
||||
""").lstrip()
|
||||
""").lstrip() # noqa
|
||||
|
||||
__not_exists_id = textwrap.dedent("""
|
||||
This directory does not currently exist. Please create it and try again, or
|
||||
choose a different installation directory (using the -d or --install-dir
|
||||
option).
|
||||
""").lstrip()
|
||||
""").lstrip() # noqa
|
||||
|
||||
__access_msg = textwrap.dedent("""
|
||||
Perhaps your account does not have write access to this directory? If the
|
||||
@@ -523,7 +533,7 @@ class easy_install(Command):
|
||||
https://setuptools.readthedocs.io/en/latest/easy_install.html
|
||||
|
||||
Please make the appropriate changes for your system and try again.
|
||||
""").lstrip()
|
||||
""").lstrip() # noqa
|
||||
|
||||
def cant_write_to_target(self):
|
||||
msg = self.__cant_write_msg % (sys.exc_info()[1], self.install_dir,)
|
||||
@@ -551,7 +561,7 @@ class easy_install(Command):
|
||||
if ok_exists:
|
||||
os.unlink(ok_file)
|
||||
dirname = os.path.dirname(ok_file)
|
||||
pkg_resources.py31compat.makedirs(dirname, exist_ok=True)
|
||||
os.makedirs(dirname, exist_ok=True)
|
||||
f = open(pth_file, 'w')
|
||||
except (OSError, IOError):
|
||||
self.cant_write_to_target()
|
||||
@@ -643,9 +653,6 @@ class easy_install(Command):
|
||||
os.path.exists(tmpdir) and rmtree(rmtree_safe(tmpdir))
|
||||
|
||||
def easy_install(self, spec, deps=False):
|
||||
if not self.editable:
|
||||
self.install_site_py()
|
||||
|
||||
with self._tmpdir() as tmpdir:
|
||||
if not isinstance(spec, Requirement):
|
||||
if URL_SCHEME(spec):
|
||||
@@ -752,9 +759,9 @@ class easy_install(Command):
|
||||
[requirement], self.local_index, self.easy_install
|
||||
)
|
||||
except DistributionNotFound as e:
|
||||
raise DistutilsError(str(e))
|
||||
raise DistutilsError(str(e)) from e
|
||||
except VersionConflict as e:
|
||||
raise DistutilsError(e.report())
|
||||
raise DistutilsError(e.report()) from e
|
||||
if self.always_copy or self.always_copy_from:
|
||||
# Force all the relevant distros to be copied or activated
|
||||
for dist in distros:
|
||||
@@ -1087,13 +1094,13 @@ class easy_install(Command):
|
||||
pkg_resources.require("%(name)s") # latest installed version
|
||||
pkg_resources.require("%(name)s==%(version)s") # this exact version
|
||||
pkg_resources.require("%(name)s>=%(version)s") # this version or higher
|
||||
""").lstrip()
|
||||
""").lstrip() # noqa
|
||||
|
||||
__id_warning = textwrap.dedent("""
|
||||
Note also that the installation directory must be on sys.path at runtime for
|
||||
this to work. (e.g. by being the application's script directory, by being on
|
||||
PYTHONPATH, or by being added to sys.path by your code.)
|
||||
""")
|
||||
""") # noqa
|
||||
|
||||
def installation_report(self, req, dist, what="Installed"):
|
||||
"""Helpful installation message for display to package users"""
|
||||
@@ -1118,7 +1125,7 @@ class easy_install(Command):
|
||||
%(python)s setup.py develop
|
||||
|
||||
See the setuptools documentation for the "develop" command for more info.
|
||||
""").lstrip()
|
||||
""").lstrip() # noqa
|
||||
|
||||
def report_editable(self, spec, setup_script):
|
||||
dirname = os.path.dirname(setup_script)
|
||||
@@ -1143,7 +1150,9 @@ class easy_install(Command):
|
||||
try:
|
||||
run_setup(setup_script, args)
|
||||
except SystemExit as v:
|
||||
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
|
||||
raise DistutilsError(
|
||||
"Setup script exited with %s" % (v.args[0],)
|
||||
) from v
|
||||
|
||||
def build_and_install(self, setup_script, setup_base):
|
||||
args = ['bdist_egg', '--dist-dir']
|
||||
@@ -1180,8 +1189,7 @@ class easy_install(Command):
|
||||
# to the setup.cfg file.
|
||||
ei_opts = self.distribution.get_option_dict('easy_install').copy()
|
||||
fetch_directives = (
|
||||
'find_links', 'site_dirs', 'index_url', 'optimize',
|
||||
'site_dirs', 'allow_hosts',
|
||||
'find_links', 'site_dirs', 'index_url', 'optimize', 'allow_hosts',
|
||||
)
|
||||
fetch_options = {}
|
||||
for key, val in ei_opts.items():
|
||||
@@ -1302,43 +1310,8 @@ class easy_install(Command):
|
||||
https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations
|
||||
|
||||
|
||||
Please make the appropriate changes for your system and try again.""").lstrip()
|
||||
|
||||
def no_default_version_msg(self):
|
||||
template = self.__no_default_msg
|
||||
return template % (self.install_dir, os.environ.get('PYTHONPATH', ''))
|
||||
|
||||
def install_site_py(self):
|
||||
"""Make sure there's a site.py in the target dir, if needed"""
|
||||
|
||||
if self.sitepy_installed:
|
||||
return # already did it, or don't need to
|
||||
|
||||
sitepy = os.path.join(self.install_dir, "site.py")
|
||||
source = resource_string("setuptools", "site-patch.py")
|
||||
source = source.decode('utf-8')
|
||||
current = ""
|
||||
|
||||
if os.path.exists(sitepy):
|
||||
log.debug("Checking existing site.py in %s", self.install_dir)
|
||||
with io.open(sitepy) as strm:
|
||||
current = strm.read()
|
||||
|
||||
if not current.startswith('def __boot():'):
|
||||
raise DistutilsError(
|
||||
"%s is not a setuptools-generated site.py; please"
|
||||
" remove it." % sitepy
|
||||
)
|
||||
|
||||
if current != source:
|
||||
log.info("Creating %s", sitepy)
|
||||
if not self.dry_run:
|
||||
ensure_directory(sitepy)
|
||||
with io.open(sitepy, 'w', encoding='utf-8') as strm:
|
||||
strm.write(source)
|
||||
self.byte_compile([sitepy])
|
||||
|
||||
self.sitepy_installed = True
|
||||
Please make the appropriate changes for your system and try again.
|
||||
""").strip()
|
||||
|
||||
def create_home_path(self):
|
||||
"""Create directories under ~."""
|
||||
@@ -1412,7 +1385,7 @@ def get_site_dirs():
|
||||
os.path.join(
|
||||
prefix,
|
||||
"lib",
|
||||
"python" + sys.version[:3],
|
||||
"python{}.{}".format(*sys.version_info),
|
||||
"site-packages",
|
||||
),
|
||||
os.path.join(prefix, "lib", "site-python"),
|
||||
@@ -1433,7 +1406,7 @@ def get_site_dirs():
|
||||
home,
|
||||
'Library',
|
||||
'Python',
|
||||
sys.version[:3],
|
||||
'{}.{}'.format(*sys.version_info),
|
||||
'site-packages',
|
||||
)
|
||||
sitedirs.append(home_sp)
|
||||
@@ -1562,7 +1535,7 @@ def get_exe_prefixes(exe_filename):
|
||||
continue
|
||||
if parts[0].upper() in ('PURELIB', 'PLATLIB'):
|
||||
contents = z.read(name)
|
||||
if six.PY3:
|
||||
if not six.PY2:
|
||||
contents = contents.decode()
|
||||
for pth in yield_lines(contents):
|
||||
pth = pth.strip().replace('\\', '/')
|
||||
@@ -2063,17 +2036,38 @@ class ScriptWriter:
|
||||
|
||||
template = textwrap.dedent(r"""
|
||||
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
|
||||
__requires__ = %(spec)r
|
||||
import re
|
||||
import sys
|
||||
from pkg_resources import load_entry_point
|
||||
|
||||
# for compatibility with easy_install; see #2198
|
||||
__requires__ = %(spec)r
|
||||
|
||||
try:
|
||||
from importlib.metadata import distribution
|
||||
except ImportError:
|
||||
try:
|
||||
from importlib_metadata import distribution
|
||||
except ImportError:
|
||||
from pkg_resources import load_entry_point
|
||||
|
||||
|
||||
def importlib_load_entry_point(spec, group, name):
|
||||
dist_name, _, _ = spec.partition('==')
|
||||
matches = (
|
||||
entry_point
|
||||
for entry_point in distribution(dist_name).entry_points
|
||||
if entry_point.group == group and entry_point.name == name
|
||||
)
|
||||
return next(matches).load()
|
||||
|
||||
|
||||
globals().setdefault('load_entry_point', importlib_load_entry_point)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(
|
||||
load_entry_point(%(spec)r, %(group)r, %(name)r)()
|
||||
)
|
||||
""").lstrip()
|
||||
sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())
|
||||
""").lstrip()
|
||||
|
||||
command_spec_class = CommandSpec
|
||||
|
||||
@@ -2088,7 +2082,8 @@ class ScriptWriter:
|
||||
@classmethod
|
||||
def get_script_header(cls, script_text, executable=None, wininst=False):
|
||||
# for backward compatibility
|
||||
warnings.warn("Use get_header", EasyInstallDeprecationWarning, stacklevel=2)
|
||||
warnings.warn(
|
||||
"Use get_header", EasyInstallDeprecationWarning, stacklevel=2)
|
||||
if wininst:
|
||||
executable = "python.exe"
|
||||
return cls.get_header(script_text, executable)
|
||||
@@ -2337,6 +2332,8 @@ def _patch_usage():
|
||||
finally:
|
||||
distutils.core.gen_usage = saved
|
||||
|
||||
|
||||
class EasyInstallDeprecationWarning(SetuptoolsDeprecationWarning):
|
||||
"""Class for warning about deprecations in EasyInstall in SetupTools. Not ignored by default, unlike DeprecationWarning."""
|
||||
|
||||
"""
|
||||
Warning for EasyInstall deprecations, bypassing suppression.
|
||||
"""
|
||||
|
||||
@@ -33,6 +33,7 @@ from setuptools.glob import glob
|
||||
from setuptools.extern import packaging
|
||||
from setuptools import SetuptoolsDeprecationWarning
|
||||
|
||||
|
||||
def translate_pattern(glob):
|
||||
"""
|
||||
Translate a file path glob like '*.txt' in to a regular expression.
|
||||
@@ -113,7 +114,7 @@ def translate_pattern(glob):
|
||||
pat += sep
|
||||
|
||||
pat += r'\Z'
|
||||
return re.compile(pat, flags=re.MULTILINE|re.DOTALL)
|
||||
return re.compile(pat, flags=re.MULTILINE | re.DOTALL)
|
||||
|
||||
|
||||
class InfoCommon:
|
||||
@@ -207,11 +208,11 @@ class egg_info(InfoCommon, Command):
|
||||
list(
|
||||
parse_requirements(spec % (self.egg_name, self.egg_version))
|
||||
)
|
||||
except ValueError:
|
||||
except ValueError as e:
|
||||
raise distutils.errors.DistutilsOptionError(
|
||||
"Invalid distribution name or version syntax: %s-%s" %
|
||||
(self.egg_name, self.egg_version)
|
||||
)
|
||||
) from e
|
||||
|
||||
if self.egg_base is None:
|
||||
dirs = self.distribution.package_dir
|
||||
@@ -266,7 +267,7 @@ class egg_info(InfoCommon, Command):
|
||||
to the file.
|
||||
"""
|
||||
log.info("writing %s to %s", what, filename)
|
||||
if six.PY3:
|
||||
if not six.PY2:
|
||||
data = data.encode("utf-8")
|
||||
if not self.dry_run:
|
||||
f = open(filename, 'wb')
|
||||
@@ -637,7 +638,9 @@ def warn_depends_obsolete(cmd, basename, filename):
|
||||
|
||||
def _write_requirements(stream, reqs):
|
||||
lines = yield_lines(reqs or ())
|
||||
append_cr = lambda line: line + '\n'
|
||||
|
||||
def append_cr(line):
|
||||
return line + '\n'
|
||||
lines = map(append_cr, lines)
|
||||
stream.writelines(lines)
|
||||
|
||||
@@ -703,7 +706,8 @@ def get_pkg_info_revision():
|
||||
Get a -r### off of PKG-INFO Version in case this is an sdist of
|
||||
a subversion revision.
|
||||
"""
|
||||
warnings.warn("get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning)
|
||||
warnings.warn(
|
||||
"get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning)
|
||||
if os.path.exists('PKG-INFO'):
|
||||
with io.open('PKG-INFO') as f:
|
||||
for line in f:
|
||||
@@ -714,4 +718,4 @@ def get_pkg_info_revision():
|
||||
|
||||
|
||||
class EggInfoDeprecationWarning(SetuptoolsDeprecationWarning):
|
||||
"""Class for warning about deprecations in eggInfo in setupTools. Not ignored by default, unlike DeprecationWarning."""
|
||||
"""Deprecated behavior warning for EggInfo, bypassing suppression."""
|
||||
|
||||
@@ -114,7 +114,7 @@ class install(orig.install):
|
||||
args.insert(0, setuptools.bootstrap_install_from)
|
||||
|
||||
cmd.args = args
|
||||
cmd.run()
|
||||
cmd.run(show_deprecation=False)
|
||||
setuptools.bootstrap_install_from = None
|
||||
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ class install_lib(orig.install_lib):
|
||||
if not hasattr(sys, 'implementation'):
|
||||
return
|
||||
|
||||
base = os.path.join('__pycache__', '__init__.' + sys.implementation.cache_tag)
|
||||
base = os.path.join(
|
||||
'__pycache__', '__init__.' + sys.implementation.cache_tag)
|
||||
yield base + '.pyc'
|
||||
yield base + '.pyo'
|
||||
yield base + '.opt-1.pyc'
|
||||
|
||||
@@ -32,8 +32,11 @@ class install_scripts(orig.install_scripts):
|
||||
)
|
||||
bs_cmd = self.get_finalized_command('build_scripts')
|
||||
exec_param = getattr(bs_cmd, 'executable', None)
|
||||
bw_cmd = self.get_finalized_command("bdist_wininst")
|
||||
is_wininst = getattr(bw_cmd, '_is_running', False)
|
||||
try:
|
||||
bw_cmd = self.get_finalized_command("bdist_wininst")
|
||||
is_wininst = getattr(bw_cmd, '_is_running', False)
|
||||
except ImportError:
|
||||
is_wininst = False
|
||||
writer = ei.ScriptWriter
|
||||
if is_wininst:
|
||||
exec_param = "python.exe"
|
||||
|
||||
@@ -132,5 +132,5 @@ class sdist_add_defaults:
|
||||
|
||||
if hasattr(sdist.sdist, '_add_defaults_standards'):
|
||||
# disable the functionality already available upstream
|
||||
class sdist_add_defaults:
|
||||
class sdist_add_defaults: # noqa
|
||||
pass
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
from distutils import log
|
||||
import distutils.command.register as orig
|
||||
|
||||
from setuptools.errors import RemovedCommandError
|
||||
|
||||
|
||||
class register(orig.register):
|
||||
__doc__ = orig.register.__doc__
|
||||
"""Formerly used to register packages on PyPI."""
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
# Make sure that we are using valid current name/version info
|
||||
self.run_command('egg_info')
|
||||
orig.register.run(self)
|
||||
finally:
|
||||
self.announce(
|
||||
"WARNING: Registering is deprecated, use twine to "
|
||||
"upload instead (https://pypi.org/p/twine/)",
|
||||
log.WARN
|
||||
)
|
||||
msg = (
|
||||
"The register command has been removed, use twine to upload "
|
||||
+ "instead (https://pypi.org/p/twine)"
|
||||
)
|
||||
|
||||
self.announce("ERROR: " + msg, log.ERROR)
|
||||
|
||||
raise RemovedCommandError(msg)
|
||||
|
||||
@@ -36,8 +36,8 @@ class rotate(Command):
|
||||
raise DistutilsOptionError("Must specify number of files to keep")
|
||||
try:
|
||||
self.keep = int(self.keep)
|
||||
except ValueError:
|
||||
raise DistutilsOptionError("--keep must be an integer")
|
||||
except ValueError as e:
|
||||
raise DistutilsOptionError("--keep must be an integer") from e
|
||||
if isinstance(self.match, six.string_types):
|
||||
self.match = [
|
||||
convert_path(p.strip()) for p in self.match.split(',')
|
||||
|
||||
@@ -5,7 +5,7 @@ import sys
|
||||
import io
|
||||
import contextlib
|
||||
|
||||
from setuptools.extern import six
|
||||
from setuptools.extern import six, ordered_set
|
||||
|
||||
from .py36compat import sdist_add_defaults
|
||||
|
||||
@@ -121,19 +121,40 @@ class sdist(sdist_add_defaults, orig.sdist):
|
||||
if has_leaky_handle:
|
||||
read_template = __read_template_hack
|
||||
|
||||
def _add_defaults_optional(self):
|
||||
if six.PY2:
|
||||
sdist_add_defaults._add_defaults_optional(self)
|
||||
else:
|
||||
super()._add_defaults_optional()
|
||||
if os.path.isfile('pyproject.toml'):
|
||||
self.filelist.append('pyproject.toml')
|
||||
|
||||
def _add_defaults_python(self):
|
||||
"""getting python files"""
|
||||
if self.distribution.has_pure_modules():
|
||||
build_py = self.get_finalized_command('build_py')
|
||||
self.filelist.extend(build_py.get_source_files())
|
||||
# This functionality is incompatible with include_package_data, and
|
||||
# will in fact create an infinite recursion if include_package_data
|
||||
# is True. Use of include_package_data will imply that
|
||||
# distutils-style automatic handling of package_data is disabled
|
||||
if not self.distribution.include_package_data:
|
||||
for _, src_dir, _, filenames in build_py.data_files:
|
||||
self.filelist.extend([os.path.join(src_dir, filename)
|
||||
for filename in filenames])
|
||||
self._add_data_files(self._safe_data_files(build_py))
|
||||
|
||||
def _safe_data_files(self, build_py):
|
||||
"""
|
||||
Extracting data_files from build_py is known to cause
|
||||
infinite recursion errors when `include_package_data`
|
||||
is enabled, so suppress it in that case.
|
||||
"""
|
||||
if self.distribution.include_package_data:
|
||||
return ()
|
||||
return build_py.data_files
|
||||
|
||||
def _add_data_files(self, data_files):
|
||||
"""
|
||||
Add data files as found in build_py.data_files.
|
||||
"""
|
||||
self.filelist.extend(
|
||||
os.path.join(src_dir, name)
|
||||
for _, src_dir, _, filenames in data_files
|
||||
for name in filenames
|
||||
)
|
||||
|
||||
def _add_defaults_data_files(self):
|
||||
try:
|
||||
@@ -186,7 +207,7 @@ class sdist(sdist_add_defaults, orig.sdist):
|
||||
manifest = open(self.manifest, 'rb')
|
||||
for line in manifest:
|
||||
# The manifest must contain UTF-8. See #303.
|
||||
if six.PY3:
|
||||
if not six.PY2:
|
||||
try:
|
||||
line = line.decode('UTF-8')
|
||||
except UnicodeDecodeError:
|
||||
@@ -200,10 +221,12 @@ class sdist(sdist_add_defaults, orig.sdist):
|
||||
manifest.close()
|
||||
|
||||
def check_license(self):
|
||||
"""Checks if license_file' is configured and adds it to
|
||||
'self.filelist' if the value contains a valid path.
|
||||
"""Checks if license_file' or 'license_files' is configured and adds any
|
||||
valid paths to 'self.filelist'.
|
||||
"""
|
||||
|
||||
files = ordered_set.OrderedSet()
|
||||
|
||||
opts = self.distribution.get_option_dict('metadata')
|
||||
|
||||
# ignore the source of the value
|
||||
@@ -211,11 +234,19 @@ class sdist(sdist_add_defaults, orig.sdist):
|
||||
|
||||
if license_file is None:
|
||||
log.debug("'license_file' option was not specified")
|
||||
return
|
||||
else:
|
||||
files.add(license_file)
|
||||
|
||||
if not os.path.exists(license_file):
|
||||
log.warn("warning: Failed to find the configured license file '%s'",
|
||||
license_file)
|
||||
return
|
||||
try:
|
||||
files.update(self.distribution.metadata.license_files)
|
||||
except TypeError:
|
||||
log.warn("warning: 'license_files' option is malformed")
|
||||
|
||||
self.filelist.append(license_file)
|
||||
for f in files:
|
||||
if not os.path.exists(f):
|
||||
log.warn(
|
||||
"warning: Failed to find the configured license file '%s'",
|
||||
f)
|
||||
files.remove(f)
|
||||
|
||||
self.filelist.extend(files)
|
||||
|
||||
@@ -74,7 +74,7 @@ class NonDataProperty:
|
||||
class test(Command):
|
||||
"""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 (deprecated)"
|
||||
|
||||
user_options = [
|
||||
('test-module=', 'm', "Run 'test_suite' in specified module"),
|
||||
@@ -129,7 +129,8 @@ class test(Command):
|
||||
|
||||
@contextlib.contextmanager
|
||||
def project_on_sys_path(self, include_dists=[]):
|
||||
with_2to3 = six.PY3 and getattr(self.distribution, 'use_2to3', False)
|
||||
with_2to3 = not six.PY2 and getattr(
|
||||
self.distribution, 'use_2to3', False)
|
||||
|
||||
if with_2to3:
|
||||
# If we run 2to3 we can not do this inplace:
|
||||
@@ -214,6 +215,14 @@ class test(Command):
|
||||
return itertools.chain(ir_d, tr_d, er_d)
|
||||
|
||||
def run(self):
|
||||
self.announce(
|
||||
"WARNING: Testing via this command is deprecated and will be "
|
||||
"removed in a future version. Users looking for a generic test "
|
||||
"entry point independent of test runner are encouraged to use "
|
||||
"tox.",
|
||||
log.WARN,
|
||||
)
|
||||
|
||||
installed_dists = self.install_dists(self.distribution)
|
||||
|
||||
cmd = ' '.join(self._argv)
|
||||
@@ -232,7 +241,7 @@ class test(Command):
|
||||
# Purge modules under test from sys.modules. The test loader will
|
||||
# re-import them from the build location. Required when 2to3 is used
|
||||
# with namespace packages.
|
||||
if six.PY3 and getattr(self.distribution, 'use_2to3', False):
|
||||
if not six.PY2 and getattr(self.distribution, 'use_2to3', False):
|
||||
module = self.test_suite.split('.')[0]
|
||||
if module in _namespace_packages:
|
||||
del_modules = []
|
||||
|
||||
@@ -1,196 +1,17 @@
|
||||
import io
|
||||
import os
|
||||
import hashlib
|
||||
import getpass
|
||||
|
||||
from base64 import standard_b64encode
|
||||
|
||||
from distutils import log
|
||||
from distutils.command import upload as orig
|
||||
from distutils.spawn import spawn
|
||||
|
||||
from distutils.errors import DistutilsError
|
||||
|
||||
from setuptools.extern.six.moves.urllib.request import urlopen, Request
|
||||
from setuptools.extern.six.moves.urllib.error import HTTPError
|
||||
from setuptools.extern.six.moves.urllib.parse import urlparse
|
||||
from setuptools.errors import RemovedCommandError
|
||||
|
||||
|
||||
class upload(orig.upload):
|
||||
"""
|
||||
Override default upload behavior to obtain password
|
||||
in a variety of different ways.
|
||||
"""
|
||||
"""Formerly used to upload packages to PyPI."""
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
orig.upload.run(self)
|
||||
finally:
|
||||
self.announce(
|
||||
"WARNING: Uploading via this command is deprecated, use twine "
|
||||
"to upload instead (https://pypi.org/p/twine/)",
|
||||
log.WARN
|
||||
)
|
||||
|
||||
def finalize_options(self):
|
||||
orig.upload.finalize_options(self)
|
||||
self.username = (
|
||||
self.username or
|
||||
getpass.getuser()
|
||||
)
|
||||
# Attempt to obtain password. Short circuit evaluation at the first
|
||||
# sign of success.
|
||||
self.password = (
|
||||
self.password or
|
||||
self._load_password_from_keyring() or
|
||||
self._prompt_for_password()
|
||||
msg = (
|
||||
"The upload command has been removed, use twine to upload "
|
||||
+ "instead (https://pypi.org/p/twine)"
|
||||
)
|
||||
|
||||
def upload_file(self, command, pyversion, filename):
|
||||
# Makes sure the repository URL is compliant
|
||||
schema, netloc, url, params, query, fragments = \
|
||||
urlparse(self.repository)
|
||||
if params or query or fragments:
|
||||
raise AssertionError("Incompatible url %s" % self.repository)
|
||||
|
||||
if schema not in ('http', 'https'):
|
||||
raise AssertionError("unsupported schema " + schema)
|
||||
|
||||
# Sign if requested
|
||||
if self.sign:
|
||||
gpg_args = ["gpg", "--detach-sign", "-a", filename]
|
||||
if self.identity:
|
||||
gpg_args[2:2] = ["--local-user", self.identity]
|
||||
spawn(gpg_args,
|
||||
dry_run=self.dry_run)
|
||||
|
||||
# Fill in the data - send all the meta-data in case we need to
|
||||
# register a new release
|
||||
with open(filename, 'rb') as f:
|
||||
content = f.read()
|
||||
|
||||
meta = self.distribution.metadata
|
||||
|
||||
data = {
|
||||
# action
|
||||
':action': 'file_upload',
|
||||
'protocol_version': '1',
|
||||
|
||||
# identify release
|
||||
'name': meta.get_name(),
|
||||
'version': meta.get_version(),
|
||||
|
||||
# file content
|
||||
'content': (os.path.basename(filename), content),
|
||||
'filetype': command,
|
||||
'pyversion': pyversion,
|
||||
'md5_digest': hashlib.md5(content).hexdigest(),
|
||||
|
||||
# additional meta-data
|
||||
'metadata_version': str(meta.get_metadata_version()),
|
||||
'summary': meta.get_description(),
|
||||
'home_page': meta.get_url(),
|
||||
'author': meta.get_contact(),
|
||||
'author_email': meta.get_contact_email(),
|
||||
'license': meta.get_licence(),
|
||||
'description': meta.get_long_description(),
|
||||
'keywords': meta.get_keywords(),
|
||||
'platform': meta.get_platforms(),
|
||||
'classifiers': meta.get_classifiers(),
|
||||
'download_url': meta.get_download_url(),
|
||||
# PEP 314
|
||||
'provides': meta.get_provides(),
|
||||
'requires': meta.get_requires(),
|
||||
'obsoletes': meta.get_obsoletes(),
|
||||
}
|
||||
|
||||
data['comment'] = ''
|
||||
|
||||
if self.sign:
|
||||
data['gpg_signature'] = (os.path.basename(filename) + ".asc",
|
||||
open(filename+".asc", "rb").read())
|
||||
|
||||
# set up the authentication
|
||||
user_pass = (self.username + ":" + self.password).encode('ascii')
|
||||
# The exact encoding of the authentication string is debated.
|
||||
# Anyway PyPI only accepts ascii for both username or password.
|
||||
auth = "Basic " + standard_b64encode(user_pass).decode('ascii')
|
||||
|
||||
# Build up the MIME payload for the POST data
|
||||
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
|
||||
sep_boundary = b'\r\n--' + boundary.encode('ascii')
|
||||
end_boundary = sep_boundary + b'--\r\n'
|
||||
body = io.BytesIO()
|
||||
for key, value in data.items():
|
||||
title = '\r\nContent-Disposition: form-data; name="%s"' % key
|
||||
# handle multiple entries for the same name
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
for value in value:
|
||||
if type(value) is tuple:
|
||||
title += '; filename="%s"' % value[0]
|
||||
value = value[1]
|
||||
else:
|
||||
value = str(value).encode('utf-8')
|
||||
body.write(sep_boundary)
|
||||
body.write(title.encode('utf-8'))
|
||||
body.write(b"\r\n\r\n")
|
||||
body.write(value)
|
||||
body.write(end_boundary)
|
||||
body = body.getvalue()
|
||||
|
||||
msg = "Submitting %s to %s" % (filename, self.repository)
|
||||
self.announce(msg, log.INFO)
|
||||
|
||||
# build the Request
|
||||
headers = {
|
||||
'Content-type': 'multipart/form-data; boundary=%s' % boundary,
|
||||
'Content-length': str(len(body)),
|
||||
'Authorization': auth,
|
||||
}
|
||||
|
||||
request = Request(self.repository, data=body,
|
||||
headers=headers)
|
||||
# send the data
|
||||
try:
|
||||
result = urlopen(request)
|
||||
status = result.getcode()
|
||||
reason = result.msg
|
||||
except HTTPError as e:
|
||||
status = e.code
|
||||
reason = e.msg
|
||||
except OSError as e:
|
||||
self.announce(str(e), log.ERROR)
|
||||
raise
|
||||
|
||||
if status == 200:
|
||||
self.announce('Server response (%s): %s' % (status, reason),
|
||||
log.INFO)
|
||||
if self.show_response:
|
||||
text = getattr(self, '_read_pypi_response',
|
||||
lambda x: None)(result)
|
||||
if text is not None:
|
||||
msg = '\n'.join(('-' * 75, text, '-' * 75))
|
||||
self.announce(msg, log.INFO)
|
||||
else:
|
||||
msg = 'Upload failed (%s): %s' % (status, reason)
|
||||
self.announce(msg, log.ERROR)
|
||||
raise DistutilsError(msg)
|
||||
|
||||
def _load_password_from_keyring(self):
|
||||
"""
|
||||
Attempt to load password from keyring. Suppress Exceptions.
|
||||
"""
|
||||
try:
|
||||
keyring = __import__('keyring')
|
||||
return keyring.get_password(self.repository, self.username)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _prompt_for_password(self):
|
||||
"""
|
||||
Prompt for a password on the tty. Suppress Exceptions.
|
||||
"""
|
||||
try:
|
||||
return getpass.getpass()
|
||||
except (Exception, KeyboardInterrupt):
|
||||
pass
|
||||
self.announce("ERROR: " + msg, log.ERROR)
|
||||
raise RemovedCommandError(msg)
|
||||
|
||||
@@ -24,7 +24,7 @@ from .upload import upload
|
||||
|
||||
|
||||
def _encode(s):
|
||||
errors = 'surrogateescape' if six.PY3 else 'strict'
|
||||
errors = 'strict' if six.PY2 else 'surrogateescape'
|
||||
return s.encode('utf-8', errors)
|
||||
|
||||
|
||||
@@ -127,8 +127,8 @@ class upload_docs(upload):
|
||||
"""
|
||||
Build up the MIME payload for the POST data
|
||||
"""
|
||||
boundary = b'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
|
||||
sep_boundary = b'\n--' + boundary
|
||||
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
|
||||
sep_boundary = b'\n--' + boundary.encode('ascii')
|
||||
end_boundary = sep_boundary + b'--'
|
||||
end_items = end_boundary, b"\n",
|
||||
builder = functools.partial(
|
||||
@@ -138,7 +138,7 @@ class upload_docs(upload):
|
||||
part_groups = map(builder, data.items())
|
||||
parts = itertools.chain.from_iterable(part_groups)
|
||||
body_items = itertools.chain(parts, end_items)
|
||||
content_type = 'multipart/form-data; boundary=%s' % boundary.decode('ascii')
|
||||
content_type = 'multipart/form-data; boundary=%s' % boundary
|
||||
return b''.join(body_items), content_type
|
||||
|
||||
def upload_file(self, filename):
|
||||
@@ -153,7 +153,7 @@ class upload_docs(upload):
|
||||
# set up the authentication
|
||||
credentials = _encode(self.username + ':' + self.password)
|
||||
credentials = standard_b64encode(credentials)
|
||||
if six.PY3:
|
||||
if not six.PY2:
|
||||
credentials = credentials.decode('ascii')
|
||||
auth = "Basic " + credentials
|
||||
|
||||
|
||||
Reference in New Issue
Block a user