[Patches] [ python-Patches-1720897 ] fix 1668596: copy datafiles properly when package_dir is ' '

SourceForge.net noreply at sourceforge.net
Sat Jun 2 20:54:07 CEST 2007


Patches item #1720897, was opened at 2007-05-17 11:13
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1720897&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils and setup.py
Group: Python 2.6
Status: Closed
Resolution: Accepted
Priority: 5
Private: No
Submitted By: Raghuram Devarakonda (draghuram)
Assigned to: Neal Norwitz (nnorwitz)
Summary: fix 1668596: copy datafiles properly when package_dir is ' '

Initial Comment:

This patch fixes http://www.python.org/sf/1668596. If package_dir is '', there is no need to remove package_dir part from data file path names.

I am also attaching 1668596_test.tar.gz. This has the directory I used to test the patch (both on Linux and Windows XP). I will need some more time to come up with a real test case that can be submitted as patch. I am hoping that if there is some one out there who is familiar with distutils test setup, they may be able to come up with a test case quicker than me.

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2007-06-02 11:54

Message:
Logged In: YES 
user_id=33168
Originator: NO

Committed revision 55747. (2.5)


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-06-01 00:29

Message:
Logged In: YES 
user_id=33168
Originator: NO

Test methods shouldn't have docstrings.  They screw up the output when
running regrtest in verbose mode.

Thanks for the patch!

This patch failed when running under regrtest (./python -E -tt
./Lib/test/regrtest.py test_distuils) due to output from the distutils
command.  I just replaced stdout and everything worked.

I modified it a bit (made test method name more descriptive and simplified
logic a bit).  Let me know if I screwed anything up.  This still needs to
be backported.  I'll do it tomorrow unless someone else gets to it first.

Committed revision 55731. (2.6)



----------------------------------------------------------------------

Comment By: Rodrigo Bernardo Pimentel (errebepe)
Date: 2007-05-30 14:10

Message:
Logged In: YES 
user_id=374783
Originator: NO

Looks great!

I don't mean to sound picky, but I think the comment should go inside the
method definition. PEP8 says "Block comments generally apply to some (or
all) code that follows them, and are indented to the same level as that
code."

But, really, now I'm just fine-tuning, the patch is fine as far as I'm
concerned :)

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-30 13:50

Message:
Logged In: YES 
user_id=984087
Originator: YES


errebepe, I added a comment to the test case. I need some more time to
analyze your find command but that is not relevant to this patch :-).
File Added: buildpy_patch.diff

----------------------------------------------------------------------

Comment By: Rodrigo Bernardo Pimentel (errebepe)
Date: 2007-05-30 12:42

Message:
Logged In: YES 
user_id=374783
Originator: NO

True, I couldn't find many tests with docstrings either (though there are
a few: find -name test_\*.py -exec egrep -nHB1 '^\s*"""' {} \; | grep -C1
'def test_' | less). On the other hand, most test names are somewhat
descriptive of what they are testing. I think a brief description, either
in a docstring or in a regular comment (which are common in existing
tests), would be helpful to anyone reading it later.

As for the rest, great! Thanks for the patch and for the quick response :)

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-30 12:01

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: buildpy_patch.diff

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-30 12:00

Message:
Logged In: YES 
user_id=984087
Originator: YES


errebepe, Thanks for the comments. I incorporated your suggestions about
the test case. It will now check explicitly for DistutilsFileError and
calls self.fail() if it gets this exception. I removed parens in "if
(src_dir)" as well.

I considered "plen = len(src_dir)+1 if src_dir else 0" form but I found it
difficult to follow compared to an explicit "if".

As to adding a docstring to the test case, I vaguely remember seeing some
comment about not having docstrings in test functions. I also don't find
docstrings in any of the test functions (found with a quick look at less
test_*.py output).





----------------------------------------------------------------------

Comment By: Rodrigo Bernardo Pimentel (errebepe)
Date: 2007-05-30 10:58

Message:
Logged In: YES 
user_id=374783
Originator: NO

+1 on the fix.

I do have a few minor suggestions, however. In the fix itself, the parens
in "(src_dir)" are still there. If the fix will only be applied in >= 2.5,
you might also use the "plen = len(src_dir)+1 if src_dir else 0" form.

As for the test, since you're testing a very specific error scenario
(Distribution.run_commands raising DistutilsFileError), I'd suggest
catching the exception and using "self.fail", so that testing the unfixed
code fails instead of issues an error. Since you expect the error to occur
inside run_commands, I'd put the try...except block around the
"dist.run_commands()" only, as in:

# Auxiliary variable, since you need cleanup and self.fail exits before
"finally":
error = False
try:
....dist.run_commands()
except DistutilsFileError:
....error = True
finally:
....os.chdir(cwd)
if error:
....self.fail("run_commands fails with no package_dir")

Gustavo Niemeyer also mentioned you should add a dosctring to the test
explaining what exactly it's testing.

To sum it up, I recommend commit of this patch regardless of my comments
above, but I hope they're taken into consideration :)

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-30 10:19

Message:
Logged In: YES 
user_id=984087
Originator: YES

Thanks for reviewing. As for parens, they don't exist in the current
patch. Right? I removed them quite some time back.

----------------------------------------------------------------------

Comment By: Phillip J. Eby (pje)
Date: 2007-05-30 09:31

Message:
Logged In: YES 
user_id=56214
Originator: NO

+1 on this approach; recommend commit of this patch (note, however, that
the parens in "if (src_dir):" are redundant).

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-21 11:24

Message:
Logged In: YES 
user_id=984087
Originator: YES


I managed to create a test case (is part of the patch now). I ran it on
Linux and Windows XP and in both cases, it properly tests the problem. 


----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-21 11:22

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: buildpy_patch.diff

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-17 11:25

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: build_py.diff

----------------------------------------------------------------------

Comment By: Raghuram Devarakonda (draghuram)
Date: 2007-05-17 11:17

Message:
Logged In: YES 
user_id=984087
Originator: YES

File Added: 1668596_test.tar.gz

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1720897&group_id=5470


More information about the Patches mailing list