cy99 / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

Block comments, makefile name and distutils. #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is a great project!  I have a few suggestions I would like to see in
your project which I've included in the attached patch file.

1) Block comments which can be used to exclude code from the shedskin
compilation process.  I've chosen #{ and #} in the attached patch.

2) An option to specify an alternate Makefile name.  I've chosen '-n
--name' in the attached patch.  Personally, I would make the default
something other than 'Makefile', perhaps 'shedskin.mak'.  I would sure hate
to type in the shedskin command and have it blow away a perfectly good
Makefile.

3) Use distutils in the setup.py program.  I'm no expert in this area and
I've attached my attempt at a setup file in the patch.  The tricky part
involves getting the FLAGS file into the expected directory.

I've tested the patch using Slackware 12.1.0, Linux kernel 2.6.24.5-smp,
Python 2.5.2, and GCC 4.2.3.

Thanks.

P.S. I hope I don't get into too much trouble for entering three
suggestions under one issue ;-)

Original issue reported on code.google.com by schric...@gmail.com on 9 Jan 2010 at 7:21

Attachments:

GoogleCodeExporter commented 9 years ago
thanks for the patch! I won't hold it against you that you lumped everything 
together. 

I like your suggestions, and committed the first two, only after changing -n and
--name into -m and --makefile (is there a reason you didn't use -m?). but
unfortunately, in a cruel twist of fate, I just merged a distutils-based 
setup.py
this morning.. (after 5 years without a distutils script, I receive two on the 
same
day!?) but please let me know if you think some part of your solution is better.

your changes will be released as part of shedskin 0.3, within a few days:

http://code.google.com/p/shedskin/wiki/ReleaseNotes?ts=1263068276&updated=Releas
eNotes

thanks a lot!

Original comment by mark.duf...@gmail.com on 9 Jan 2010 at 8:19

GoogleCodeExporter commented 9 years ago
oh, let me know if you'd like me to change your name in the release notes.

Original comment by mark.duf...@gmail.com on 9 Jan 2010 at 8:20

GoogleCodeExporter commented 9 years ago
btw, note that this doesn't work:

#{
''' oink '''
print 'from python'
#}

perhaps you'd like to fix this, using a simple state machine or something?

Original comment by mark.duf...@gmail.com on 9 Jan 2010 at 8:58

GoogleCodeExporter commented 9 years ago
Wow, you're quick, I guess I should have checked on this yesterday.

I think that '-m --makefile' is an excellent choice.

Use mike.schrick in the release notes.

I realize that ''' can not be used inside the block comments as I have 
implemented
it.  I suppose I was a bit lazy, but you can still use """.  A simple state 
machine
which really comments out the block would be a better implementation, but this 
at
least is a start.

Thanks again for a great project!

Mike

Original comment by schric...@gmail.com on 10 Jan 2010 at 2:29

GoogleCodeExporter commented 9 years ago
thanks for the help! I will leave the issue open until there is an improved
implementation for ignoring the block comments (thinking about it again, can't 
we
just improve the regular expression to match both begin and end markers at the 
same
time..?)

Original comment by mark.duf...@gmail.com on 10 Jan 2010 at 3:15

GoogleCodeExporter commented 9 years ago
how about the following? 

pat = re.compile(r"#{.*?#}", re.MULTILINE | re.DOTALL)
filebuf = re.sub(pat, '', open(name).read())

as this seems at least an improvement, I commited it to SVN.

Original comment by mark.duf...@gmail.com on 10 Jan 2010 at 6:00

GoogleCodeExporter commented 9 years ago
I think you're solution to block comments is much better.

thanks,

Mike

Original comment by schric...@gmail.com on 10 Jan 2010 at 7:54

GoogleCodeExporter commented 9 years ago
alright, we'll keep this one for now then. thanks again. closing the issue..

Original comment by mark.duf...@gmail.com on 10 Jan 2010 at 8:40

GoogleCodeExporter commented 9 years ago
reopening, read() and then parse() doesn't work with DOS text files under UNIX 
(and
possibly the other way around..). 

Original comment by mark.duf...@gmail.com on 11 Jan 2010 at 12:29

GoogleCodeExporter commented 9 years ago

Original comment by mark.duf...@gmail.com on 11 Jan 2010 at 12:29

GoogleCodeExporter commented 9 years ago
thanks to jeremie, this works from UNIX at least (haven't tested windows yet):

filebuf = re.sub(pat, '', ''.join(open(name, 'U').readlines()))

Original comment by mark.duf...@gmail.com on 11 Jan 2010 at 3:05

GoogleCodeExporter commented 9 years ago
works on under windows too, closing the issue again.. :P

Original comment by mark.duf...@gmail.com on 11 Jan 2010 at 7:05