File: _fix_jython_setuptools_osx.py

package info (click to toggle)
jython 2.7.2%2Brepack1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 62,676 kB
  • sloc: python: 640,908; java: 306,458; xml: 1,984; sh: 522; ansic: 126; makefile: 76
file content (33 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'''
Import of this module is triggered by org.python.core.imp.import_next
on first import of setuptools.command. It essentially restores a
Jython specific fix for OSX shebang line via monkeypatching.

See http://bugs.jython.org/issue2570
Related: http://bugs.jython.org/issue1112
'''

from setuptools.command import easy_install as ez

_as_header = ez.CommandSpec.as_header

def _jython_as_header(self):
    '''Workaround Jython's sys.executable being a .sh (an invalid
    shebang line interpreter)
    '''
    if not ez.is_sh(self[0]):
        return _as_header(self)

    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 _as_header(self)

    items = ['/usr/bin/env'] + self + list(self.options)
    return self._render(items)

ez.CommandSpec.as_header = _jython_as_header