On 14 September 2011 08:26, Corbin Simpson <span dir="ltr"><<a href="mailto:mostawesomedude@gmail.com">mostawesomedude@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I've talked about it a bit before, but I feel that it's getting out of<br>
hand, so it's time to talk about cleaning up some of the Python that's<br>
used to generate/build Mesa.<br>
<br>
First, the biggest problem is that our Python's completely untested<br>
and unstructured. It's very ad-hoc. This might be alright for some of<br>
the codegen, but the rather extensive total weight of all of these<br>
scripts is over 20 KLOCs, and this is just too much code to be<br>
scattered about with very little organization. There are zero Python<br>
packages (folders with __init__.py) in Mesa.<br>
<br>
Here are a handful of problems exposed by pyflakes, a minimal static<br>
analysis tool which only catches syntax errors, unused names, and<br>
undefined names. This is really only tip-of-the-iceberg stuff, but I<br>
don't feel comfortable sending patches for this stuff without talking<br>
to the people that wrote this code originally.<br>
<br>
* /src/gallium/drivers/llvmpipe/lp_tile_shuffle_mask.py has a syntax<br>
error in global scope; it can't possibly run.<br>
* /scons/wcesdk.py has an undefined name in what appears to be dead<br>
code. This probably isn't a problem because I don't think any of us<br>
care about WinCE. (Which leads to the question: Why is this in the<br>
tree?)<br>
* /src/mapi/glapi/gen/*.py have undefined calls to show_usage(),<br>
which I anticipate should show a usage message and exit. However,<br>
since these are generally only called from Makefiles, they shouldn't<br>
be a problem. Of course, people might have trouble running them<br>
manually...<br>
* /src/mapi/mapi/mapi_abi.py has a couple more undefined names in error paths.<br>
<br>
What are people's opinions on this? Is it worth spending some time to<br>
clean up some of this code?<br></blockquote><div><br>I'm generally in favor of clean-up, especially when it (a) fixes rarely-encountered bugs, (b) improves clarity, or (c) increases the number of people who understand a given piece of code. I'm not sure we'll get too much of (a) in this case (since most of the code is only used at compile time and always acts on the same input, every bug is either common or benign), but we can probably get a lot of benefit in the (b) and (c) departments.<br>
<br>Also, Python 3 is slowly taking hold (it's already the standard Python in archlinux, and I expect others to follow), so some time in the next year or so we might want to upgrade our Python scripts to use Python 3. It would be nice to do a round of clean-up before we attempt that.<br>
<br>I've done professional Python development in the past, so I will try to help with code review.<br><br>Paul<br></div></div>