Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError with Python 3.x #181

Open
FRidh opened this issue Jan 23, 2016 · 10 comments
Open

SyntaxError with Python 3.x #181

FRidh opened this issue Jan 23, 2016 · 10 comments

Comments

@FRidh
Copy link

FRidh commented Jan 23, 2016

Tested with python 3.4 and 3.5

Traceback (most recent call last):
  File "/nix/store/4fr5rgsizd5q72fr8lsixvb274awg6nk-python3-3.4.4/lib/python3.4/unittest/loader.py", line 323, in _find_tests
    module = self._get_module_from_name(name)
  File "/nix/store/4fr5rgsizd5q72fr8lsixvb274awg6nk-python3-3.4.4/lib/python3.4/unittest/loader.py", line 301, in _get_module_from_name
    __import__(name)
  File "/tmp/nix-build-python3.4-pystache-0.5.4.drv-0/pystache-0.5.4/test_pystache.py", line 20, in <module>
    from pystache.commands import test
  File "/tmp/nix-build-python3.4-pystache-0.5.4.drv-0/pystache-0.5.4/pystache/__init__.py", line 9, in <module>
    from pystache.init import parse, render, Renderer, TemplateSpec
  File "/tmp/nix-build-python3.4-pystache-0.5.4.drv-0/pystache-0.5.4/pystache/init.py", line 8, in <module>
    from pystache.parser import parse
  File "/tmp/nix-build-python3.4-pystache-0.5.4.drv-0/pystache-0.5.4/pystache/parser.py", line 15
    NON_BLANK_RE = re.compile(ur'^(.)', re.M)
                                     ^
SyntaxError: invalid syntax

@jstasiak
Copy link

I can't reproduce this, I have pystache 0.5.4 installed on Python 3.5.1 and it works.

@ch3sn3k
Copy link

ch3sn3k commented Jul 28, 2016

I have the same issue. I am using Python '3.3.5 (default, Jun 15 2016, 19:45:40) [MSC v.1800 32 bit (Intel)]' installed in LibreOffice installation 5.1.4.2 (32bit) on Windows 7 (64bit).
I just installed pip 6.1.1. and install pystache 0.5.4.
After executionf the import pystache a get the same error.

@JaviBecerra
Copy link

Found the same issue with Python 3.6.3.
Apparently pip did not update pystache code from Python 2 to Python 3 during installation (the SyntaxError initially reported stems from the invalid ur string specifier in Python 3).
Solved running manually 2to3 on the pystache installation folder as per the installation instructions:

2to3 --write --nobackups --no-diffs site-packages\pystache

@jgstew
Copy link

jgstew commented Mar 10, 2020

I'm getting this same issue in Python 3.7.6

@nicktalb
Copy link

nicktalb commented Apr 6, 2020

Same issue with Python 3.6.10, pip (both 18.1 and latest 20.0.2) and pystache 0.5.4. Didn't have the issue with 3.6.1.

@nicktalb
Copy link

nicktalb commented Apr 9, 2020

This seems to be a problem with 2to3. When I run "python -m lib2to3" with Python 3.6.1 on the pystache site-packages directory I get a list of changes that would be made. When I run with Python 3.6.10 I simply get:
RefactoringTool: No files need to be modified.

@nicktalb
Copy link

Problem went away when I removed this post-build step from our Python build:

# Pre-compile all .py files to .pyc and delete .py files
./bin/python3 -m compileall -bf .
find . -name "__pycache__" -type d -print0 | xargs -0 /bin/rm -rf
find . -name "*.py" -type f -print0 | xargs -0 /bin/rm -rf

I've not investigated why this caused the issue.

@c00kiemon5ter
Copy link

c00kiemon5ter commented Sep 6, 2021

From the readme

Pystache is written in Python 2 and must be converted to Python 3 prior to using it with Python 3. The installation process (and tox) do this automatically.

It seems that the last working build is with pip 20.3.3. After that, the build step that compiles python2 code to python3 seems to be skipped. (see below, the real issue is setuptools)

From nicolargo/glances#1793 (comment)

it looks like it relies on lib2to3 to work in Python 3 and there are issues with 2to3 which is noted to be unstable with Python 3.9 and deprecated in 3.10

I am sorry to say that this signals that the project is indeed abandoned and people should look elsewhere - #213

@c00kiemon5ter
Copy link

Scratch the above message. The actual reason the build is failing is not pip but setuptools.

From https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v5800

v58.0.0

Breaking Changes

#2086: Removed support for 2to3 during builds. Projects should port to a unified codebase or pin to an older version of Setuptools using PEP 518 build-requires.

So, starting today, environments that pull in the new release of setuptools (v58 or later) will fail to build pystache.

@bakert
Copy link

bakert commented Sep 19, 2021

I have forked pystache and dropped support for python2 in order to avoid this issue here – https://github.com/PennyDreadfulMTG/pystache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants