[Distutils] Re: [Python-Help] help with distutils (fwd)

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Mon Mar 12 10:23:05 2001


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--545289610-825307379-984410576=:16386
Content-Type: TEXT/PLAIN; charset=US-ASCII

I'm forwarding this message to the distutils people; apparently, someone
wants to allow spaces within recursive-include pathnames.  To allow this,
I've written a small "splitWithQuotes()" function that handles this sort
of weird string splitting.

There's probably a much better way to write this mini-parser (can we
employ Python's line parser?), but in any case, I had fun writing this.  
If we replace the call to spring.split() in _parse_template_line
(filelist.py):


###
   def _parse_template_line (self, line):
        words = string.split(line)
###

with

    words = splitwithquotes(line)

this should allow Dmitry's recursive-include to work, if everything else
holds together (which it might not.  *grin*)

Is this feasible?


---------- Forwarded message ----------
Date: Mon, 12 Mar 2001 06:27:32 -0800 (PST)
From: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>
To: Balabanov Dmitry <dimonb@beep.ru>
Cc: help@python.org
Subject: Re: [Python-Help] help with distutils

On Sat, 10 Mar 2001, Balabanov Dmitry wrote:

>    Hi!!
> Problem is very simple but i can't solve it...
> I  have such string in MANIFEST.in:
> 	recursive-include 'Max Fray' *.txt
> But `python setup.py sdist --manifest-only` spawns:
> 	running sdist
> 	warning: sdist: missing required meta-data: url
> 	reading manifest template 'MANIFEST.in'
> 	warning: no files found matching 'Fray'' under directory ''Max'
> 	warning: no files found matching '*.txt' under directory ''Max'
> 	writing manifest file 'MANIFEST'

First of all, apologies for the very late response.  It's been a long
week.

Hmmm.. the problem is that the DistUtils assume that the directories don't
have a space in them.  That's why it's parsing the directories
incorrectly.

Specifically, the problem lies in the function _parse_template_line() in
filelist.py of the Python Distutils, around line 111 --- they use a simple
string.split(), which doesn't look at quoted directories.  That's why
we're getting those weird error messages.

Given this, I'm not quite sure what the elegant solution to this would be.  
Is it possible to rename the directory "Max Fray" to Max_Fray without too
much pain?  Also, please contact the DistUtils SIG at:

    http://mail.python.org/mailman/listinfo/distutils-sig

The best way to solve this is to get the distutils to be a little smarter
when it comes to reading in those manifest lines; I'll see if I have time
to provide a patch to this later.


_______________________________________________
Python-Help maillist  -  Python-Help@python.org
http://mail.python.org/mailman/listinfo/python-help

--545289610-825307379-984410576=:16386
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="splitwithquotes.py"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.21.0103120722560.16386@hkn.eecs.berkeley.edu>
Content-Description: 
Content-Disposition: attachment; filename="splitwithquotes.py"

IiIiVGhpcyBwYXJzZXIgYWN0cyBsaWtlIHN0cmluZy5zcGxpdCgpLCBidXQg
d2l0aCB0aGUgYWRkaXRpb25hbA0KYmVoYXZpb3IgdGhhdCBzdHVmZiBpbiBx
dW90ZXMgd29ya3MuDQoNCkZvciBmdW4sIEknbGwgc2VlIGlmIEkgY2FuIGRv
IHRoaXMgd2l0aG91dCByZWd1bGFyIGV4cHJlc3Npb25zLiAgSQ0Ka25vdyB0
aGF0IHVzaW5nIHJlZ3VsYXIgZXhwcmVzc2lvbnMgd2lsbCBiZSBhIGxvdCBt
b3JlIGNvbXBhY3QsIGJ1dCBJDQpuZWVkIG1vcmUgZXhwZXJpZW5jZSB3aXRo
IHBhcnNpbmcgcHJvZ3JhbXMgKGZvciBhIHBlcnNvbmFsIHByb2plY3QpLg0K
IiIiDQoNCmZyb20gc3RyaW5nIGltcG9ydCB3aGl0ZXNwYWNlDQoNClNQQUNF
UyA9IHdoaXRlc3BhY2UNClFVT1RFUyA9ICdcJyInDQoNCmRlZiBzcGxpdFdp
dGhRdW90ZXMobGluZSk6DQogICAgcCA9IF9QYXJzZXIoKQ0KICAgIHJldHVy
biBwKGxpbmUpDQoNCmNsYXNzIF9QYXJzZXI6DQogICAgZGVmIF9faW5pdF9f
KHNlbGYpOg0KICAgICAgICBzZWxmLml0ZW1zID0gW10NCiAgICAgICAgc2Vs
Zi50b2tl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825307379-984410576=:16386--