[Distutils] setuptools problem?

Phillip J. Eby pje at telecommunity.com
Thu Feb 1 21:04:29 CET 2007


At 08:22 PM 2/1/2007 +0100, Thomas Heller wrote:
>Phillip J. Eby schrieb:
> > At 07:37 PM 2/1/2007 +0100, Thomas Heller wrote:
> >>Philip,
> >>
> >>I was trying to install yolk with
> >>
> >>c:\python25\python -m easy_install yolk
> >>
> >>(on Windows, as you can see).
> >>
> >>A yolk.py script is installed in c:\Python25\Scripts, but between each
> >>source line
> >>there is an empty line.  In other words, line feeds are doubled each time.
> >>This leads to syntax errors because continuation lines don't work any 
> longer.
> >>
> >>It seems easy_install gets the newlines wrong.
> >
> > Yep, the problem was exclusive to "old-style" scripts, which yolk is using
> > for some reason.  (It could just move yolk's main() function to yolklib 
> and
> > list in the the setup script's entry points.)
> >
> > It's fixed it now in SVN.
> >
>
>and it works for me, now.  Boy, are you quick!

And just as quick to create new bugs...  see below.  :(


>For my education: what are "old-style" scripts?

A script specified in the 'scripts' option to setup(), as opposed to via 
entry_points.

Now, what I just realized when I typed that answer above, is that normally 
Python scripts specified in setup() would be installed using a wrapper that 
handles require()-ing the package's dependencies.

So, the real problem turned out to be that the 'yolk.py' script was not 
being detected as being a *Python* script, if the build_scripts command was 
run on Windows.  This would put a #! line in place with 'python.exe' 
instead of 'python', which distutils' "first_line_re" pattern would not 
match at install time.

So, when I fixed the broken line endings, I missed the fact that the broken 
code should never have been running at all.  In effect, only non-Python 
scripts should've had their contents messed up!  (Well, they shouldn't be 
messed up, but the point is that there were *two* bugs here, and I missed 
one of them.)

So, now I've fixed the script language detection to be more lenient 
regarding #! lines, and in fact it will only bother with the #! line if the 
script filename is not .py/.pyw and the content isn't syntactically valid 
Python.

(By the way, you might want to mention to the yolk author that his/her 
package depends on ElementTree, but it's not listed in the project's 
install_requires.  So, when I tried running the 'yolk' script it failed 
because I didn't have ElementTree installed.)



More information about the Distutils-SIG mailing list