From 2b3cf9b12b23ac6beca6808c4c7620aa77f168e3 Mon Sep 17 00:00:00 2001 From: Darjus Loktevic Date: Mon, 11 Jan 2016 23:23:36 +1100 Subject: Remove JythonCommandSpec as it's not required on Jython 2.7 and setuptools no longer supports anything 2.5, but had to test for 'Jython on Windows' in two other places --- setuptools/command/easy_install.py | 48 ++++---------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index a11618d1..fccfade2 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1876,17 +1876,6 @@ def chmod(path, mode): log.debug("chmod failed: %s", e) -def fix_jython_executable(executable, options): - warnings.warn("Use JythonCommandSpec", DeprecationWarning, stacklevel=2) - - if not JythonCommandSpec.relevant(): - return executable - - cmd = CommandSpec.best().from_param(executable) - cmd.install_options(options) - return cmd.as_header().lstrip('#!').rstrip('\n') - - class CommandSpec(list): """ A command spec for a #! header, specified as a list of arguments akin to @@ -1901,7 +1890,7 @@ class CommandSpec(list): """ Choose the best CommandSpec class based on environmental conditions. """ - return cls if not JythonCommandSpec.relevant() else JythonCommandSpec + return cls @classmethod def _sys_executable(cls): @@ -1968,36 +1957,6 @@ class WindowsCommandSpec(CommandSpec): split_args = dict(posix=False) -class JythonCommandSpec(CommandSpec): - @classmethod - def relevant(cls): - return ( - sys.platform.startswith('java') - and - __import__('java').lang.System.getProperty('os.name') != 'Linux' - ) - - def as_header(self): - """ - Workaround Jython's sys.executable being a .sh (an invalid - shebang line interpreter) - """ - if not is_sh(self[0]): - return super(JythonCommandSpec, self).as_header() - - if self.options: - # Can't apply the workaround, leave it broken - log.warn( - "WARNING: Unable to adapt shebang line for Jython," - " the following script is NOT executable\n" - " see http://bugs.jython.org/issue1112 for" - " more information.") - return super(JythonCommandSpec, self).as_header() - - items = ['/usr/bin/env'] + self + list(self.options) - return self._render(items) - - class ScriptWriter(object): """ Encapsulates behavior around writing entry point scripts for console and @@ -2074,7 +2033,10 @@ class ScriptWriter(object): """ Select the best ScriptWriter for this environment. """ - return WindowsScriptWriter.best() if sys.platform == 'win32' else cls + if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): + return WindowsScriptWriter.best() + else: + return cls @classmethod def _get_script_args(cls, type_, name, header, script_text): -- cgit v1.2.1 From 434aef220e6ec7cfc609bce631ef8528c930c20c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:11:13 -0500 Subject: Move trailing comment to docstring --- setuptools/command/build_py.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 8a50f032..32e37e52 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -59,7 +59,8 @@ class build_py(orig.build_py, Mixin2to3): self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0)) def __getattr__(self, attr): - if attr == 'data_files': # lazily compute data files + "lazily compute data files" + if attr == 'data_files': self.data_files = files = self._get_data_files() return files return orig.build_py.__getattr__(self, attr) -- cgit v1.2.1 From f55db00043f3f47b7121c42d54433bc80a01c243 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:11:54 -0500 Subject: Remove superfluous local variable --- setuptools/command/build_py.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 32e37e52..c24646c3 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -61,8 +61,8 @@ class build_py(orig.build_py, Mixin2to3): def __getattr__(self, attr): "lazily compute data files" if attr == 'data_files': - self.data_files = files = self._get_data_files() - return files + self.data_files = self._get_data_files() + return self.data_files return orig.build_py.__getattr__(self, attr) def build_module(self, module, module_file, package): -- cgit v1.2.1 From 775cb73ed72e87951254bbbe373951be9caac4df Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:16:11 -0500 Subject: Extract function for getting data files for package. --- setuptools/command/build_py.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index c24646c3..3ddc7673 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -75,8 +75,9 @@ class build_py(orig.build_py, Mixin2to3): def _get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" self.analyze_manifest() - data = [] - for package in self.packages or (): + return list(map(self._get_pkg_data_files, self.packages or ())) + + def _get_pkg_data_files(self, package): # Locate package source directory src_dir = self.get_package_dir(package) @@ -90,8 +91,7 @@ class build_py(orig.build_py, Mixin2to3): filenames = [ file[plen:] for file in self.find_data_files(package, src_dir) ] - data.append((package, src_dir, build_dir, filenames)) - return data + return package, src_dir, build_dir, filenames def find_data_files(self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" -- cgit v1.2.1 From ddfbfa731e2cf73dc03b5a3345996afac843441e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:16:39 -0500 Subject: Reindent --- setuptools/command/build_py.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 3ddc7673..5021bd1f 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -78,20 +78,20 @@ class build_py(orig.build_py, Mixin2to3): return list(map(self._get_pkg_data_files, self.packages or ())) def _get_pkg_data_files(self, package): - # Locate package source directory - src_dir = self.get_package_dir(package) + # Locate package source directory + src_dir = self.get_package_dir(package) - # Compute package build directory - build_dir = os.path.join(*([self.build_lib] + package.split('.'))) + # Compute package build directory + build_dir = os.path.join(*([self.build_lib] + package.split('.'))) - # Length of path to strip from found files - plen = len(src_dir) + 1 + # Length of path to strip from found files + plen = len(src_dir) + 1 - # Strip directory from globbed filenames - filenames = [ - file[plen:] for file in self.find_data_files(package, src_dir) - ] - return package, src_dir, build_dir, filenames + # Strip directory from globbed filenames + filenames = [ + file[plen:] for file in self.find_data_files(package, src_dir) + ] + return package, src_dir, build_dir, filenames def find_data_files(self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" -- cgit v1.2.1 From 0f590c0d72709128f32c23437fe0183386c69d1c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:33:04 -0500 Subject: Prefer relpath to string slicing for computing a path relative to a base. Fixes #341. --- setuptools/command/build_py.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 5021bd1f..0c1026aa 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -84,12 +84,10 @@ class build_py(orig.build_py, Mixin2to3): # Compute package build directory build_dir = os.path.join(*([self.build_lib] + package.split('.'))) - # Length of path to strip from found files - plen = len(src_dir) + 1 - # Strip directory from globbed filenames filenames = [ - file[plen:] for file in self.find_data_files(package, src_dir) + os.path.relpath(file, src_dir) + for file in self.find_data_files(package, src_dir) ] return package, src_dir, build_dir, filenames -- cgit v1.2.1 From 8af3b6ef5b4173a0d0d6735147c98c882ae98344 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:54:00 -0500 Subject: Always use Python 3 version of map --- setuptools/command/alias.py | 2 ++ setuptools/command/build_py.py | 1 + setuptools/command/easy_install.py | 2 +- setuptools/command/egg_info.py | 1 + setuptools/command/install_egg_info.py | 2 ++ setuptools/command/test.py | 1 + 6 files changed, 8 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/alias.py b/setuptools/command/alias.py index 452a9244..4532b1cc 100755 --- a/setuptools/command/alias.py +++ b/setuptools/command/alias.py @@ -1,5 +1,7 @@ from distutils.errors import DistutilsOptionError +from setuptools.extern.six.moves import map + from setuptools.command.setopt import edit_config, option_base, config_file diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 0c1026aa..8623c777 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -9,6 +9,7 @@ import distutils.errors import collections import itertools +from setuptools.extern.six.moves import map try: from setuptools.lib2to3_ex import Mixin2to3 diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index a11618d1..d3c0acfb 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -41,7 +41,7 @@ import shlex import io from setuptools.extern import six -from setuptools.extern.six.moves import configparser +from setuptools.extern.six.moves import configparser, map from setuptools import Command from setuptools.sandbox import run_setup diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 18a3105f..d1bd9b04 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -15,6 +15,7 @@ import warnings import time from setuptools.extern import six +from setuptools.extern.six.moves import map from setuptools import Command from setuptools.command.sdist import sdist diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index fd0f118b..f777538f 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -1,6 +1,8 @@ from distutils import log, dir_util import os +from setuptools.extern.six.moves import map + from setuptools import Command from setuptools.archive_util import unpack_archive import pkg_resources diff --git a/setuptools/command/test.py b/setuptools/command/test.py index 3a2a9b93..371e913b 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -3,6 +3,7 @@ from unittest import TestLoader import sys from setuptools.extern import six +from setuptools.extern.six.moves import map from pkg_resources import (resource_listdir, resource_exists, normalize_path, working_set, _namespace_packages, -- cgit v1.2.1 From 0e689bb35e8af9f079f6985a11c80268575f786e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 7 Feb 2016 09:25:06 -0500 Subject: Backout changeset 1ae2a75724bbba56373784f185a7f235ed0f24a4 --- setuptools/command/install_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index fd0f118b..992709f1 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -27,7 +27,7 @@ class install_egg_info(Command): ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) - self.outputs = [self.target] + self.outputs = [] def run(self): self.run_command('egg_info') -- cgit v1.2.1 From 5367a7399762a9098ea689c7cdcb54fb9748dd66 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 11 Feb 2016 23:47:28 -0500 Subject: Override upload command to load passwords from keyring when available and not otherwise specified. --- setuptools/command/__init__.py | 2 +- setuptools/command/upload.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 setuptools/command/upload.py (limited to 'setuptools/command') diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py index f6dbc39c..3fb2f6df 100644 --- a/setuptools/command/__init__.py +++ b/setuptools/command/__init__.py @@ -2,7 +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', + 'register', 'bdist_wininst', 'upload_docs', 'upload', ] from distutils.command.bdist import bdist diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py new file mode 100644 index 00000000..08c20ba8 --- /dev/null +++ b/setuptools/command/upload.py @@ -0,0 +1,23 @@ +from distutils.command import upload as orig + + +class upload(orig.upload): + """ + Override default upload behavior to look up password + in the keyring if available. + """ + + def finalize_options(self): + orig.upload.finalize_options(self) + self.password or self._load_password_from_keyring() + + def _load_password_from_keyring(self): + """ + Attempt to load password from keyring. Suppress Exceptions. + """ + try: + keyring = __import__('keyring') + self.password = keyring.get_password(self.repository, + self.username) + except Exception: + pass -- cgit v1.2.1 From 1e0ecae918c4c43f29b139b0dffa9d73b208e13b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 12 Feb 2016 11:07:19 -0500 Subject: Remove unused import --- setuptools/command/upload_docs.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index ca35a3ce..0a57d5d3 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -13,7 +13,6 @@ import os import socket import zipfile import tempfile -import sys import shutil from setuptools.extern import six -- cgit v1.2.1 From 076e6b32c38a5bd6141bf533ff87eb23e54eca67 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 12 Feb 2016 11:10:53 -0500 Subject: Upload_docs should also resolve passwords from keyring same as upload command. --- setuptools/command/upload_docs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index 0a57d5d3..f887b47e 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -8,7 +8,6 @@ PyPI's pythonhosted.org). from base64 import standard_b64encode from distutils import log from distutils.errors import DistutilsOptionError -from distutils.command.upload import upload import os import socket import zipfile @@ -19,6 +18,7 @@ from setuptools.extern import six from setuptools.extern.six.moves import http_client, urllib from pkg_resources import iter_entry_points +from .upload import upload errors = 'surrogateescape' if six.PY3 else 'strict' -- cgit v1.2.1