[Distutils] setuptools: mishandles install of non-python scripts

Ned Deily nad at acm.org
Sat Jun 10 02:22:15 CEST 2006

easy_install doesn't properly handle non-python scripts in a 

The problem shows up when using easy_install to install mercurial:

The mercurial distribution includes two scripts, one a python script, 
the other a shell script:
hg - #!/usr/bin/env python
hgmerge - #!/bin/sh

Using easy_install, both scripts get installed with a python wrapper 
script. Execution of hgmerge fails when the wrapper tries to run the 
shell script under python:

$ hgmerge
Traceback (most recent call last):
  File "/usr/local/python/bin/hgmerge", line 5, in ?
    pkg_resources.run_script('mercurial==dbeaa4369121', 'hgmerge')
kages/setuptools-0.6b3-py2.4.egg/pkg_resources.py", line 407, in 
    self.require(requires)[0].run_script(script_name, ns)
kages/setuptools-0.6b3-py2.4.egg/pkg_resources.py", line 1084, in 
    execfile(script_filename, namespace, namespace)
gmerge", line 20
    if [ -z "$EDITOR" ]; then
SyntaxError: invalid syntax

If mercurial is installed using distutils directly;
   python setup.py install
both scripts work properly.

In build_scripts.py in distutils.command, distuitils uses the results of 
first_line_re to decide whether to adjust the python value in the shbang 
line of the script: if no "python" is found, distutils installs the 
script without modification.  easy_install.py uses the first_line_re 
test from distutils but seems to unconditionally add a wrapper to the 
script during installation regardless of the script's type.
 Ned Deily,
 nad at acm.org

More information about the Distutils-SIG mailing list