fusionbox / django-pyscss

Makes it easier to use PyScss in Django
https://pypi.python.org/pypi/django-pyscss
BSD 2-Clause "Simplified" License
19 stars 13 forks source link

Python3 support #1

Closed rockymeza closed 9 years ago

rockymeza commented 10 years ago

Hypothetically the codebase already supports Python3, but I can't get the Travis tests to pass. You can see the error here. The problem is that while django-compressor portends to support Python3, I can't manage to install it from pip, which definitely causes problems for running the tests that depend on compressor existing.

Apparently, django-compressor has fixed this in https://github.com/django-compressor/django-compressor/commit/0e3eeab29c7ba3afc4ec77233dd7d4ab1c6705fa. When that fix is released, then we can support Python3.

wojas commented 10 years ago

I'm trying to make Widgy work with Python 3, but now I encountered a problem. SCSS files are fed to the parser as bytes, but it expects text (unicode) strings.

  File "/Users/wojas/dev/django-widgy/widgy/contrib/page_builder/forms/__init__.py", line 80, in CKEditorWidget
    'contentsCss': scss_compile('/widgy/page_builder/html.scss'),
  File "/Users/wojas/dev/django-widgy/widgy/contrib/page_builder/forms/__init__.py", line 22, in scss_compile
    css_content = scss.compile(scss_file=scss_filename)
  File "/Users/wojas/dev/django3/src/pyscss/scss/__init__.py", line 471, in compile
    return self.Compilation(*args, **kwargs)
  File "/Users/wojas/dev/django3/lib/python3.4/site-packages/django_pyscss/scss.py", line 174, in Compilation
    source_file = self._find_source_file(scss_file)
  File "/Users/wojas/dev/django3/lib/python3.4/site-packages/django_pyscss/scss.py", line 94, in _find_source_file
    source,
  File "/Users/wojas/dev/django3/src/pyscss/scss/__init__.py", line 145, in __init__
    self.contents = self.prepare_source(contents)
  File "/Users/wojas/dev/django3/src/pyscss/scss/__init__.py", line 298, in prepare_source
    codestr += parse_line(line_no, line, state)
  File "/Users/wojas/dev/django3/src/pyscss/scss/__init__.py", line 208, in parse_scss_line
    line = state['line_buffer'] + line.rstrip()  # remove EOL character
TypeError: Can't convert 'bytes' object to str implicitly
wojas commented 10 years ago

This resolved the issue for me:

--- scss.py.orig    2014-05-14 00:19:30.000000000 +0800
+++ scss.py 2014-05-14 00:19:35.000000000 +0800
@@ -87,7 +87,7 @@
             if full_filename:
                 if full_filename not in self.source_file_index:
                     with storage.open(full_filename) as f:
-                        source = f.read()
+                        source = f.read().decode('utf-8')

                     source_file = SourceFile(
                         full_filename,
gavinwahl commented 10 years ago

@wojas did you install compressor from source to get a version supporting python 3?

rockymeza commented 10 years ago

@wojas, could you submit a pull request? You could change the .travis.yml to include the Python 3 run.

Thanks, -Rocky Meza 2014年5月14日 上午2:09于 "Gavin Wahl" notifications@github.com写道:

@wojas https://github.com/wojas did you install compressor from source to get a version supporting python 3?

— Reply to this email directly or view it on GitHubhttps://github.com/fusionbox/django-pyscss/issues/1#issuecomment-42991065 .

wojas commented 10 years ago

I just submitted a pull request which also includes another fix. Please not that the two sprite sprite tests do not pass for me on neither Python 2.7 nor Python 3.4 (OS X). Python 3 support also depends on a fix in pyScss, for which I sent a pull request to the author: https://github.com/wojas/pyScss/commit/e4cf419509f3c568c108c3196e2fda50bcc37536

wojas commented 10 years ago

Here's a project I created to test Widgy and dependencies with Python 3.4: https://github.com/wojas/django-widgy-website-py3

It uses bleeding edge version of a few dependencies, see requirements.txt

rockymeza commented 10 years ago

closed in favor of #7.

Thanks @wojas.

rockymeza commented 9 years ago

resolved by #31