diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-23 21:22:16 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-01-23 21:22:16 -0500 |
commit | 619367262942fcc478d4a8c7c9449da346605ac0 (patch) | |
tree | d729f4ffaf887247ed53798ddd2e79a672762a76 | |
parent | 589a2c0c319ba39ebcce7a64c36dc11aefd0ebc0 (diff) | |
parent | 2b3cf9b12b23ac6beca6808c4c7620aa77f168e3 (diff) | |
download | external_python_setuptools-619367262942fcc478d4a8c7c9449da346605ac0.tar.gz external_python_setuptools-619367262942fcc478d4a8c7c9449da346605ac0.tar.bz2 external_python_setuptools-619367262942fcc478d4a8c7c9449da346605ac0.zip |
Merged in darjus/setuptools (pull request #169)
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
-rwxr-xr-x | setup.py | 3 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 48 | ||||
-rw-r--r-- | setuptools/tests/test_easy_install.py | 45 |
3 files changed, 7 insertions, 89 deletions
@@ -59,7 +59,8 @@ force_windows_specific_files = ( os.environ.get("SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES") not in (None, "", "0") ) -if sys.platform == 'win32' or force_windows_specific_files: +if (sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt')) \ + or force_windows_specific_files: package_data.setdefault('setuptools', []).extend(['*.exe']) package_data.setdefault('setuptools.command', []).extend(['*.xml']) diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index d3c0acfb..46056173 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): diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 99ac7317..07d8a3c5 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -548,51 +548,6 @@ class TestScriptHeader: expected = '#!"%s"\n' % self.exe_with_spaces assert actual == expected - @pytest.mark.xfail( - six.PY3 and is_ascii, - reason="Test fails in this locale on Python 3" - ) - @mock.patch.dict(sys.modules, java=mock.Mock(lang=mock.Mock(System= - mock.Mock(getProperty=mock.Mock(return_value=""))))) - @mock.patch('sys.platform', 'java1.5.0_13') - def test_get_script_header_jython_workaround(self, tmpdir): - # Create a mock sys.executable that uses a shebang line - header = DALS(""" - #!/usr/bin/python - # -*- coding: utf-8 -*- - """) - exe = tmpdir / 'exe.py' - with exe.open('w') as f: - f.write(header) - - exe = ei.nt_quote_arg(os.path.normpath(str(exe))) - - # Make sure Windows paths are quoted properly before they're sent - # through shlex.split by get_script_header - executable = '"%s"' % exe if os.path.splitdrive(exe)[0] else exe - - header = ei.ScriptWriter.get_script_header('#!/usr/local/bin/python', - executable=executable) - assert header == '#!/usr/bin/env %s\n' % exe - - expect_out = 'stdout' if sys.version_info < (2,7) else 'stderr' - - with contexts.quiet() as (stdout, stderr): - # When options are included, generate a broken shebang line - # with a warning emitted - candidate = ei.ScriptWriter.get_script_header('#!/usr/bin/python -x', - executable=executable) - assert candidate == '#!%s -x\n' % exe - output = locals()[expect_out] - assert 'Unable to adapt shebang line' in output.getvalue() - - with contexts.quiet() as (stdout, stderr): - candidate = ei.ScriptWriter.get_script_header('#!/usr/bin/python', - executable=self.non_ascii_exe) - assert candidate == '#!%s -x\n' % self.non_ascii_exe - output = locals()[expect_out] - assert 'Unable to adapt shebang line' in output.getvalue() - class TestCommandSpec: def test_custom_launch_command(self): |