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

PR: Make project pip installable and add @import support #2

Merged
merged 21 commits into from
May 2, 2018

Conversation

danbradham
Copy link
Collaborator

@danbradham danbradham commented May 1, 2018

Fixes #3
Fixes #4
Fixes #8
Fixes #9


Hello, great project!

Found this while attempting to use libsass for a qt project and ran into a couple of issues.

First, I couldn't pip install qtsass. This fork has a standard setup.py that does not use cx_freeze. This makes it easier for me to install on windows/linux. I'm not sure if qtsass requires cx_freeze for spyder, but, for me it makes more sense to have a standard setup.py.

This fork also introduces an importer callback passed to libsass.compile that conforms scss imported using @import statements.

Finally, I introduced an abstraction around conforming css to qss and qss to css. This should make it easier to support more qss specific syntax in the future. For example, there could be a Conformer for qlineargradient that transforms the qss syntax:

qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.1 blue, stop: 0.8 green)

to your libsass qlineargradient function syntax:

qlineargradient(0, 0, 0, 1, (0.1 blue, 0.8 green))

Removed NestedSelectorConformer
    - this was introduced based on a red herring
    - real issue was imported qss not being conformed
    - Conformer abstraction still valid
@goanpeca
Copy link
Member

goanpeca commented May 2, 2018

Hey @danbradham thanks for the help, we took ownership of this project since we want to start styling Spyder using QSS, but have not gotten around to it yet for lack of time. Let me get back to you by the end of this week. Ok ?

Sorry but I cannot make this sooner

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments mostly related to adherence to standards, conventions and style guides.

qtsass/qtsass.py Outdated
@@ -10,12 +13,107 @@
logger = logging.getLogger(__name__)


class Conformer(object):
'''Base class for all Text transformations'''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With regard to all your docstrings, thanks for including such detailed documentation. Per PEP 257 (the docstring standard), docstrings are required to use double quotes """ , not single, which is adhered to elsewhere in the codebase. Also per PEP 257, all docstrings should end with a period, and at least according to that (I'm not sure its strictly followed, either here or in the rest of the world) there should be a space both before and after a class docstring, for symmetry.

qtsass/qtsass.py Outdated


def css_conform(input_str):
'''Conform qss to valid scss.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat a matter of taste, but the Spyder dev generally seems to agree that putting a linebreak before the summary line of a multi-line docstring is preferable as it is clearer and looks cleaner, and that seems to be the convention used elsewhere in the codebase. E.g.

"""
Conform qss to valid scss.

Blah blah blah
"""

qtsass/qtsass.py Outdated
if event.is_directory and os.path.samefile(event.src_path, self._watched_dir) or (
os.path.splitext(event.src_path)[1] == self._watched_extension):
# On Windows, only recompile if event's file has
# the same extension as the input file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather strange indentation here...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

qtsass/qtsass.py Outdated
'--watch',
action='store_true',
help=(
"Whether to watch source file "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, I find it better to be explicit with boolean flags and the like, to avoid any ambiguity, especially given our highly international audience. I.e. "If set, will watch the source file and automatically recompile if it changes."

setup.py Outdated
name=qtsass.__title__,
version='0.1.0',
description=qtsass.__description__,
long_description=open('README.md', 'r').read(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth passing encoding="utf-8" here? On Windows, it defaults to something stupid instead, so if non-ASCII chars are present now or in the future on the machine reading the file, mojibake will likely result.

- Use io.open with utf-8 encoding in setup.py
- Use qtsass.__version__ in setup.py
Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good; a few minor followup comments.

setup.py Outdated
packages=find_packages(),
entry_points={
'console_scripts': [
'qtsass = qtsass.qtsass:main'
"console_scripts": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, the double-quotes requirement only refers to docstrings—Python has no general/accepted preference for single or double quotes for string literals. My personal convention is to use double in my own work, but most Spyder projects seem to prefer single as a rough convention except for specific circumstances. Not sure it matters hugely, but just wanted to make sure my earlier statement was clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you were clear previously, I was just falling in line with the rest of this project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we took ownership of this project (we did not start this) that is why we have difference @CAM-Gerlach . But I think is good to homogenize :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, indeed. For clarity's sake, homogenize to " as used in this repo, or homogenize to ' as is de-facto "Spyder-style"?

qtsass/qtsass.py Outdated
Runs the to_css method of all Conformer subclasses on the input_str.
Conformers are run in order of definition.
"""
Conform qss to valid scss. Runs the to_css method of all Conformer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The summary line should still be on its own line, separated by a blank like from the extended summary/description. See my comment on my first round of review for an example.

@ccordoba12 ccordoba12 changed the title pip installable - @import support PR: Make project pip installable and add @import support May 2, 2018
@goanpeca
Copy link
Member

goanpeca commented May 2, 2018

Hi @danbradham, just sent you an email...

screen shot 2018-05-02 at 09 35 21

setup.py Outdated
from cx_Freeze import setup, Executable
from setuptools import setup, find_packages
from io import open
import qtsass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid having to import things, lets use
https://github.com/spyder-ide/loghub/blob/master/setup.py#L21

The idea is avoid having to import the package itself when running the installer

setup.py Outdated
name=qtsass.__title__,
version=qtsass.__version__,
description=qtsass.__description__,
long_description=open("README.md", "r", encoding="utf-8").read(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can clean this up a bit by moving out to a helper function.

https://github.com/spyder-ide/loghub/blob/master/setup.py#L34

setup.py Outdated
executables=[Executable("qtsass/qtsass.py")],
options={'build_exe': build_exe_options},
requires=['libsass', 'cx_Freeze', 'watchdog'],
name=qtsass.__title__,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be potentially problematic (having to import the package itself)

So I would prefer we just left the version on __init__.py and the rest here

setup.py Outdated
description=qtsass.__description__,
long_description=open("README.md", "r", encoding="utf-8").read(),
author=qtsass.__author__,
author_email="N/A",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author :-) https://github.com/yann-lty

@yann-lty do you want as to include your email?


@danbradham lets add maintainer section and include your details

Copy link
Member

@goanpeca goanpeca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some additional comments :-)

setup.py Outdated
]
},
classifiers=(
"Development Status :: 3 - Alpha",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can remove Alpha and go to official stable release?

test_qtsass.py Outdated
from __future__ import absolute_import
import unittest
from textwrap import dedent
from qtsass.qtsass import NotConformer, QLinearGradientConformer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_qtsass.py Outdated
self.assertEqual(c.to_css(self.qss_singleline_str), self.css_str)

def test_conform_multiline_str(self):
"""QLinearGradientConformer multiline qss to css"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstrings are sentences so they should be finished with a dot .

@goanpeca goanpeca added this to the v0.1.0 milestone May 2, 2018
- Move most metadata into setup.py
- Add VERSION_INFO to __init__.py
- Use setup.py utility functions from loghub project
@CAM-Gerlach
Copy link
Member

As I understand it, its a best practice to keep PRs narrow in scope and try to keep to one issue a PR, unless they are intertwined/related. Not that it matters much at this stage, but just wanted to put that out there.

LICENSE.txt Outdated
@@ -0,0 +1,21 @@
MIT License

Copyright (c) The Spyder Development Team
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment on #9 Also needs an AUTHORS.txt file.

@danbradham
Copy link
Collaborator Author

I agree with 1 issue per pull request, this one just got out of hand as it was kind of off the cuff. I'm going to stop after AUTHORS.txt

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor things

AUTHORS.txt Outdated

The Spyder Project Contributors are composed of:

* Pierre Raybaut <pierre.raybaut@gmail.com> (Original Spyder author).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove as requested

AUTHORS.txt Outdated
The Spyder Project Contributors are composed of:

* Pierre Raybaut <pierre.raybaut@gmail.com> (Original Spyder author).
* Carlos Cordoba <ccordoba12@gmail.com> (Current maintainer).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove as requested

AUTHORS.txt Outdated
@@ -0,0 +1,9 @@
* Yann Lanthony <N/A> (Original qtsass author).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put his Github link here if he doesn't want his email out there. Just tag him in the issue thread to get his permission and ask him.

@CAM-Gerlach
Copy link
Member

Happens to all of us, heh...

AUTHORS.txt Outdated
@@ -0,0 +1,6 @@
The Spyder Project Contributors are composed of:

* Yann Lanthony <https://github.com/yann-lty> (Original qtsass author).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He should be listed separately above, just as you had it before, following the same convention as the boilerplate and LICENSE file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woof

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meow

qtsass/qtsass.py Outdated
import time
import sass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sass is a third party import, no?

@goanpeca
Copy link
Member

goanpeca commented May 2, 2018

Minor change then I can merge. As a rule, lets try to have someone different form the author of the PR, merging their own PRs

@goanpeca
Copy link
Member

goanpeca commented May 2, 2018

@danbradham also for next time pelase create a branch from master and work there, instead of directly working on your fork on master.

@goanpeca goanpeca merged commit 327c49f into spyder-ide:master May 2, 2018
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

Successfully merging this pull request may close these issues.

None yet

4 participants