crazy2be / wfdr

Simple web framework for go, still quite beta at this point
23 stars 3 forks source link

compile fails #10

Closed ghost closed 12 years ago

ghost commented 13 years ago

I've attempted to build (compile) on Snow Leopard with the following result (using Python 2.6):

rnm-macpro(809)wfdr: ./compile 
Traceback (most recent call last):
  File "./compile", line 5, in <module>
    import argparse
ImportError: No module named argparse

And also on CentOS 5.5 (using Python 2.4.3):

v04(1006)wfdr: ./compile 
  File "./compile", line 34
    extrapad = " " if paddinglen % 2 else ""
                    ^
SyntaxError: invalid syntax
crazy2be commented 13 years ago

Thanks for your error report, I don't have a mac so I was unaware of any issues.

Doing some investigation into the issue, it looks like argparse requires at least python 2.7. This should be backwards-compatible with earlier python 2.xxx versions, so I would encourage you to upgrade. My system has 2.6.6 and it seems to have argparse, but it's not in the python docs until version 2.7 (http://docs.python.org/release/2.7/library/argparse.html works, http://docs.python.org/release/2.6/library/argparse.html doesn't). If you don't wish to upgrade your python, you can also install argparse from http://code.google.com/p/argparse/ (versions for older python available). Is there another argument parsing library you know of that is better supported? I just used argparse because it was the first thing I spotted.

The invalid syntax error arises from my use of the ternary operator, which is not supported until python 2.5. I can fix this part fairly easily, at some loss of clarity, but why is it that you use such an old version of python, out of curiosity?

ghost commented 13 years ago

Hi, Thanks for the info. I'll look into upgrading Python.

I don't program in Python so it has been my practice to use whatever version comes with the OS build. The versions I quoted on Snow Leopard and CentOS 5.5 are the default versions on those releases. Since some systems software relies on the installed version, upgrading means I have to make sure I don't step on the toes of the existing install. So I guess the answer to the question why not upgrade is a combination of laziness and path of least resistance ;)

On 2011-07-04, at 7:17 PM, crazy2be wrote:

Thanks for your error report, I don't have a mac so I was unaware of any issues.

Doing some investigation into the issue, it looks like argparse requires at least python 2.7. This should be backwards-compatible with earlier python 2.xxx versions, so I would encourage you to upgrade. My system has 2.6.6 and it seems to have argparse, but it's not in the python docs until version 2.7 (http://docs.python.org/release/2.7/library/argparse.html works, http://docs.python.org/release/2.6/library/argparse.html doesn't). If you don't wish to upgrade your python, you can also install argparse from http://code.google.com/p/argparse/ (versions for older python available). Is there another argument parsing library you know of that is better supported? I just used argparse because it was the first thing I spotted.

The invalid syntax error arises from my use of the ternary operator, which is not supported until python 2.5. I can fix this part fairly easily, at some loss of clarity, but why is it that you use such an old version of python, out of curiosity?

Reply to this email directly or view it on GitHub: https://github.com/crazy2be/wfdr/issues/10#issuecomment-1501096

crazy2be commented 13 years ago

I can remove the ternary operator fairly easily, and it might be possible to bundle argparse with the framework (depending on how large of a library it is). Not sure the minimum version of python required to use argparse, but it's likely to be the bigger issue as far as backwards compatibility goes.

Do you know what version of python OSX comes with (python --version)? I think that the framework should certainly work with a default install of OSX (and it is likely realistic to get it to work with OSX), not so sure about CentOS with it's significantly outdated python.

crazy2be commented 13 years ago

Oh, sorry, I missed that you said python 2.6 in your issue. Argparse should work with python >= 2.3 according to it's documentation, so I should be able to correct the issue on both platforms. Leaving this issue open, as the issue is not yet fixed, but should be within a couple days (have to figure out how to best bundle argparse, just copying the files into the repository seems like not the best way to do it).

ghost commented 13 years ago

Say - I've been wondering if there are native Go alternatives to doing the build with the Python script.

On 2011-07-04, at 10:18 PM, crazy2be wrote:

Oh, sorry, I missed that you said python 2.6 in your issue. Argparse should work with python >= 2.3 according to it's documentation, so I should be able to correct the issue on both platforms. Leaving this issue open, as the issue is not yet fixed, but should be within a couple days (have to figure out how to best bundle argparse, just copying the files into the repository seems like not the best way to do it).

Reply to this email directly or view it on GitHub: https://github.com/crazy2be/wfdr/issues/10#issuecomment-1501593

crazy2be commented 13 years ago

I'm not sure what a "native go" solution for this problem is. The compile script is really just runs a bunch of other commands (goinstall for each package in framework/src/goinstalls, gomake in framework/src, wfdr compile all at root). It'd be quite possible to convert it to a shell script, but I've no idea how to parse commandline arguments or withhold a commands output unless it exits nonzero with a shell script (i.e. fails). Making an actual "go" program to do the compiling would be overkill, as it's only 106 lines, most of which are help messages and such (not to mention the difficulty in compiling the compilation script).

I've fixed the ternary operator, and i'm eager to use some other solution for the argument parsing- it need only parse two flags (true/false), no values required. Argparse is some 2363 lines, and seems to be way overkill for simple argument parsing like this.

crazy2be commented 13 years ago

Sorry it took me so long to get to this. I've been busy working, packing, and still trying to have a life :P.

This issue should hopefully be fixed, I wrote a simple argument parsing library in around 20 lines of code that will work for this program's uses. Please let me know if you encounter any further difficulties.