code-guide icon indicating copy to clipboard operation
code-guide copied to clipboard

Setup.py does not specify a platform dependency on Python 2.7

Open DivineDominion opened this issue 12 years ago • 2 comments

When I try to convert the example file test.py

#|| Hello World
#|| ===========
#||
#|| Hello world is traditionally used to illustrate to beginners 
#|| the most basic syntax of a programming language, or to verify 
#|| that a language or system is operating correctly.

#| This is all that is required in Python
print "hello, world"
#|.

... on a fresh install of Python 3.3.1 via Homebrew on a Mac, the conversion stops when the actual code markup should begin. The generated HTML console output of code-guide test.py is:

<html><head><title>Hello World</title><link rel="stylesheet" type="text/css" href="code_guide/bootstrap/css/bootstrap.min.css"></link><link rel="stylesheet" type="text/css" href="code_guide/bootstro.min.css"></link><link rel="stylesheet" type="text/css" href="code_guide/pygments.css"></link><link rel="stylesheet" type="text/css" href="code_guide/code-guide.css"></link><script type="text/javascript" src="code_guide/jquery-1.9.1.min.js"></script><script type="text/javascript" src="code_guide/bootstrap/js/bootstrap.min.js"></script><script type="text/javascript" src="code_guide/bootstro.min.js"></script><script type="text/javascript" src="code_guide/code-guide.js"></script></head><body><div class="code-guide-intro"><h1>Hello World</h1>

Hello world is traditionally used to illustrate to beginners the most basic syntax of a programming language, or to verify that a language or system is operating correctly.

... and is followed by this runtime error:

  File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 346, in cli
    out=XMLGenerator(sys.stdout if use_stdio(args.output) else open(args.output, "w")))
  File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 258, in to_html
    _code_tree_to_html(out, e, code_lexer, md)
  File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 142, in _code_tree_to_html
    stream_html(out, pygments.highlight(" " if e.text == "" else e.text, code_lexer, HtmlFormatter(cssclass="", classprefix="code-guide-syntax-")))
  File "/usr/local/lib/python3.3/site-packages/code_guide/__init__.py", line 125, in stream_html
    xml.sax.parseString(html_str, filter)
  File "/usr/local/Cellar/python3/3.3.1/Frameworks/Python.framework/Versions/3.3/lib/python3.3/xml/sax/__init__.py", line 45, in parseString
    inpsrc.setByteStream(BytesIO(string))
TypeError: 'str' does not support the buffer interface

Interestingly, after I re-installed Python and Pip and wanted to install code_guide again, I got this on the console:

$ pip3 install code_guide
Downloading/unpacking code-guide
  Running setup.py egg_info for package code-guide

Requirement already satisfied (use --upgrade to upgrade): markdown==2.3.1 in /usr/local/lib/python3.3/site-packages (from code-guide)
Requirement already satisfied (use --upgrade to upgrade): pygments==1.6 in /usr/local/lib/python3.3/site-packages (from code-guide)
Installing collected packages: code-guide
  Running setup.py install for code-guide
      File "/usr/local/lib/python3.3/site-packages/code_guide/test_code_guide.py", line 223
        print e
              ^
    SyntaxError: invalid syntax


    changing mode of /usr/local/share/python3/code-guide to 755
Successfully installed code-guide
Cleaning up...

-- but only once.

DivineDominion avatar Jun 06 '13 11:06 DivineDominion

It requires Python 2.7, not Python 3.3.1 (Python 3.3 is a different, incompatible, language from Python 2.7). I've updated the title to reflect that the setup.py installer should have failed with a platform incompatability error.

npryce avatar Jun 06 '13 20:06 npryce

That's weird, because I can't even get this far with Python 2.7.

$ pip-2.7 install code-guide
Downloading/unpacking code-guide
  Running setup.py egg_info for package code-guide

Downloading/unpacking markdown==2.3.1 (from code-guide)
  Running setup.py egg_info for package markdown

Downloading/unpacking pygments==1.6 (from code-guide)
  Running setup.py egg_info for package pygments

Installing collected packages: code-guide, markdown, pygments
  Running setup.py install for code-guide

    changing mode of /usr/local/bin/code-guide to 755
  Running setup.py install for markdown

    changing mode of /usr/local/bin/markdown_py to 755
  Running setup.py install for pygments
      File "/usr/local/lib/python2.7/site-packages/pygments/cmdline.py", line 133
        print("%s not found!" % what, file=sys.stderr)
                                          ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python2.7/site-packages/pygments/formatters/html.py", line 509
        'using current directory as base for the CSS file name', file=sys.stderr)
                                                                     ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python2.7/site-packages/pygments/lexer.py", line 46
        class Lexer(object, metaclass=LexerMeta):
                                     ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python2.7/site-packages/pygments/style.py", line 107
        class Style(object, metaclass=StyleMeta):
                                     ^
    SyntaxError: invalid syntax


    Installing pygmentize script to /usr/local/bin
Successfully installed code-guide markdown pygments
Cleaning up...

Looks like something is wrong with either my setup or pygments.

DivineDominion avatar Jun 07 '13 12:06 DivineDominion