summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/command')
-rw-r--r--setuptools/command/__init__.py2
-rwxr-xr-xsetuptools/command/alias.py2
-rw-r--r--setuptools/command/build_py.py34
-rwxr-xr-xsetuptools/command/easy_install.py50
-rwxr-xr-xsetuptools/command/egg_info.py1
-rwxr-xr-xsetuptools/command/install_egg_info.py4
-rw-r--r--setuptools/command/test.py1
-rw-r--r--setuptools/command/upload.py23
-rw-r--r--setuptools/command/upload_docs.py3
9 files changed, 55 insertions, 65 deletions
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/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 8a50f032..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
@@ -59,9 +60,10 @@ 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
- self.data_files = files = self._get_data_files()
- return files
+ "lazily compute data files"
+ if attr == 'data_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):
@@ -74,23 +76,21 @@ 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 ():
- # Locate package source directory
- src_dir = self.get_package_dir(package)
+ return list(map(self._get_pkg_data_files, self.packages or ()))
- # Compute package build directory
- build_dir = os.path.join(*([self.build_lib] + package.split('.')))
+ def _get_pkg_data_files(self, package):
+ # Locate package source directory
+ src_dir = self.get_package_dir(package)
- # Length of path to strip from found files
- plen = len(src_dir) + 1
+ # Compute package build directory
+ build_dir = os.path.join(*([self.build_lib] + package.split('.')))
- # Strip directory from globbed filenames
- filenames = [
- file[plen:] for file in self.find_data_files(package, src_dir)
- ]
- data.append((package, src_dir, build_dir, filenames))
- return data
+ # Strip directory from globbed filenames
+ filenames = [
+ os.path.relpath(file, src_dir)
+ 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'"""
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index a11618d1..46056173 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
@@ -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):
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..60b615d2 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
@@ -27,7 +29,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')
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,
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
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py
index ca35a3ce..f887b47e 100644
--- a/setuptools/command/upload_docs.py
+++ b/setuptools/command/upload_docs.py
@@ -8,18 +8,17 @@ 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
import tempfile
-import sys
import shutil
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'