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

Setuptools Install Produces Syntax Errors on Template Files #633

Open
derks opened this issue Jul 3, 2022 · 1 comment
Open

Setuptools Install Produces Syntax Errors on Template Files #633

derks opened this issue Jul 3, 2022 · 1 comment

Comments

@derks
Copy link
Member

derks commented Jul 3, 2022

System Information

  • Cement Version: main/3.0.7
  • Python Version: 3.10

Steps to Reproduce (Bugs Only)

  • docker run -it -v pwd:/src python:3.10
  • cd /src
  • python setup.py install

Produces:

Extracting cement-3.0.7-py3.10.egg to /usr/local/lib/python3.10/site-packages
  File "/usr/local/lib/python3.10/site-packages/cement-3.0.7-py3.10.egg/cement/cli/templates/generate/extension/ext_{{ label }}.py", line 6
    def {{ label }}_pre_run_hook(app):
        ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.10/site-packages/cement-3.0.7-py3.10.egg/cement/cli/templates/generate/plugin/{{ label }}/__init__.py", line 3
    from .controllers.{{ label }} import {{ class_name }}
                      ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.10/site-packages/cement-3.0.7-py3.10.egg/cement/cli/templates/generate/plugin/{{ label }}/controllers/{{ label }}.py", line 5
    class {{ class_name }}(Controller):
          ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.10/site-packages/cement-3.0.7-py3.10.egg/cement/cli/templates/generate/project/setup.py", line 3
    from {{ label }}.core.version import get_version
         ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.10/site-packages/cement-3.0.7-py3.10.egg/cement/cli/templates/generate/project/tests/test_{{ label }}.py", line 3
    from {{ label }}.main import {{ class_name }}Test
         ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.10/site-packages/cement-3.0.7-py3.10.egg/cement/cli/templates/generate/project/{{ label }}/main.py", line 4
    from .core.exc import {{ class_name }}Error
                          ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.10/site-packages/cement-3.0.7-py3.10.egg/cement/cli/templates/generate/project/{{ label }}/core/exc.py", line 2
    class {{ class_name }}Error(Exception):
          ^
SyntaxError: invalid syntax

I believe this is setuptools attempting to byte-compile all *.py files... which obviously triggers syntax errors for files in cement/cli/templates/*.

@derks
Copy link
Member Author

derks commented Nov 3, 2022

Might be something to try here (defining templates as package data might make setuptools skip them during byte compiling?):

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

No branches or pull requests

1 participant