Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Drop support for Python 3.4
See #2742
  • Loading branch information
The-Compiler committed Sep 18, 2017
1 parent 852baaa commit 505321c
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 189 deletions.
4 changes: 1 addition & 3 deletions README.asciidoc
Expand Up @@ -99,9 +99,7 @@ Requirements

The following software and libraries are required to run qutebrowser:

* http://www.python.org/[Python] 3.4 or newer (3.6 recommended) - note that
support for Python 3.4
https://github.com/qutebrowser/qutebrowser/issues/2742[will be dropped soon].
* http://www.python.org/[Python] 3.5 or newer (3.6 recommended)
* http://qt.io/[Qt] 5.7.1 or newer with the following modules:
- QtCore / qtbase
- QtQuick (part of qtbase in some distributions)
Expand Down
2 changes: 1 addition & 1 deletion doc/changelog.asciidoc
Expand Up @@ -22,7 +22,7 @@ Breaking changes

- (TODO) Support for legacy QtWebKit (before 5.212 which is distributed
independently from Qt) is dropped.
- (TODO) Support for Python 3.4 is dropped.
- Support for Python 3.4 is dropped.
- Support for Qt before 5.7.1 and PyQt before 5.7 is dropped.
- (TODO) New dependency on ruamel.yaml; dropped PyYAML dependency.
- (TODO) The QtWebEngine backend is now used by default if available.
Expand Down
12 changes: 6 additions & 6 deletions doc/contributing.asciidoc
Expand Up @@ -180,7 +180,7 @@ In the _scripts/_ subfolder there's a `run_profile.py` which profiles the code
and shows a graphical representation of what takes how much time.

It uses the built-in Python
https://docs.python.org/3.4/library/profile.html[cProfile] module and can show
https://docs.python.org/3.6/library/profile.html[cProfile] module and can show
the output in four different ways:

* Raw profile file (`--profile-tool=none`)
Expand Down Expand Up @@ -535,11 +535,11 @@ ____
Setting up a Windows Development Environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Install https://www.python.org/downloads/release/python-344/[Python 3.4]
* Install https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.5.1/[PyQt 5.5]
* Create a file at `C:\Windows\system32\python3.bat` with the following content:
`@C:\Python34\python %*`
This will make the Python 3.4 interpreter available as `python3`, which is used by various development scripts.
* Install https://www.python.org/downloads/release/python-362/[Python 3.6].
* Install PyQt via `pip install PyQt5`
* Create a file at `C:\Windows\system32\python3.bat` with the following content (adjust the path as necessary):
`@C:\Python36\python %*`
This will make the Python 3.6 interpreter available as `python3`, which is used by various development scripts.
* Install git from the https://git-scm.com/download/win[git-scm downloads page]
Try not to enable `core.autocrlf`, since that will cause `flake8` to complain a lot. Use an editor that can deal with plain line feeds instead.
* Clone your favourite qutebrowser repository.
Expand Down
4 changes: 2 additions & 2 deletions doc/install.asciidoc
Expand Up @@ -17,8 +17,8 @@ running.
Debian Jessie / Ubuntu 14.04 LTS / Linux Mint < 18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Those distributions only have Python 3.4 and a too old Qt version available. A
newer Qt isn't easily installable on Python 3.4, unfortunately.
Those distributions only have Python 3.4 and a too old Qt version available,
while qutebrowser requires Python 3.5 and Qt 5.7.1 or newer.

It should be possible to install Python 3.5 e.g. from the
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa[deadsnakes PPA] or via_ipca
Expand Down
5 changes: 3 additions & 2 deletions qutebrowser/browser/commands.py
Expand Up @@ -24,6 +24,7 @@
import os.path
import shlex
import functools
import typing

from PyQt5.QtWidgets import QApplication, QTabBar, QDialog
from PyQt5.QtCore import Qt, QUrl, QEvent, QUrlQuery
Expand All @@ -39,10 +40,11 @@
webelem, downloads)
from qutebrowser.keyinput import modeman
from qutebrowser.utils import (message, usertypes, log, qtutils, urlutils,
objreg, utils, typing, debug)
objreg, utils, debug)
from qutebrowser.utils.usertypes import KeyMode
from qutebrowser.misc import editor, guiprocess
from qutebrowser.completion.models import urlmodel, miscmodels
from qutebrowser.mainwindow import mainwindow


class CommandDispatcher:
Expand Down Expand Up @@ -70,7 +72,6 @@ def __repr__(self):

def _new_tabbed_browser(self, private):
"""Get a tabbed-browser from a new window."""
from qutebrowser.mainwindow import mainwindow
new_window = mainwindow.MainWindow(private=private)
new_window.show()
return new_window.tabbed_browser
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/browser/navigate.py
Expand Up @@ -24,6 +24,7 @@
from qutebrowser.browser import webelem
from qutebrowser.config import config
from qutebrowser.utils import objreg, urlutils, log, message, qtutils
from qutebrowser.mainwindow import mainwindow


class Error(Exception):
Expand Down Expand Up @@ -134,7 +135,6 @@ def _prevnext_cb(elems):
window=win_id)

if window:
from qutebrowser.mainwindow import mainwindow
new_window = mainwindow.MainWindow(
private=cur_tabbed_browser.private)
new_window.show()
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/browser/shared.py
Expand Up @@ -23,6 +23,7 @@

from qutebrowser.config import config
from qutebrowser.utils import usertypes, message, log, objreg, jinja
from qutebrowser.mainwindow import mainwindow


class CallSuper(Exception):
Expand Down Expand Up @@ -234,7 +235,6 @@ def get_tab(win_id, target):
elif target == usertypes.ClickTarget.window:
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
from qutebrowser.mainwindow import mainwindow
window = mainwindow.MainWindow(private=tabbed_browser.private)
window.show()
win_id = window.win_id
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/browser/webelem.py
Expand Up @@ -31,6 +31,7 @@

from qutebrowser.config import config
from qutebrowser.keyinput import modeman
from qutebrowser.mainwindow import mainwindow
from qutebrowser.utils import log, usertypes, utils, qtutils, objreg


Expand Down Expand Up @@ -372,7 +373,6 @@ def _click_href(self, click_target):
background = click_target == usertypes.ClickTarget.tab_bg
tabbed_browser.tabopen(url, background=background)
elif click_target == usertypes.ClickTarget.window:
from qutebrowser.mainwindow import mainwindow
window = mainwindow.MainWindow(private=tabbed_browser.private)
window.show()
window.tabbed_browser.tabopen(url)
Expand Down
8 changes: 3 additions & 5 deletions qutebrowser/commands/command.py
Expand Up @@ -22,10 +22,11 @@
import inspect
import collections
import traceback
import typing

from qutebrowser.commands import cmdexc, argparser
from qutebrowser.utils import (log, utils, message, docutils, objreg,
usertypes, typing)
usertypes)
from qutebrowser.utils import debug as debug_utils
from qutebrowser.misc import objects

Expand Down Expand Up @@ -415,10 +416,7 @@ def _get_param_value(self, param):
# We also can't use isinstance here because typing.Union doesn't
# support that.
# pylint: disable=no-member,useless-suppression
try:
types = list(typ.__union_params__)
except AttributeError:
types = list(typ.__args__)
types = list(typ.__args__)
# pylint: enable=no-member,useless-suppression
if param.default is not inspect.Parameter.empty:
types.append(type(param.default))
Expand Down
8 changes: 2 additions & 6 deletions qutebrowser/config/config.py
Expand Up @@ -28,9 +28,9 @@
from PyQt5.QtWidgets import QMessageBox

from qutebrowser.config import configdata, configexc, configtypes, configfiles
from qutebrowser.utils import utils, objreg, message, log, usertypes
from qutebrowser.utils import utils, objreg, message, log, usertypes, jinja
from qutebrowser.misc import objects, msgbox
from qutebrowser.commands import cmdexc, cmdutils
from qutebrowser.commands import cmdexc, cmdutils, runners
from qutebrowser.completion.models import configmodel

# An easy way to access the config from other code via config.val.foo
Expand Down Expand Up @@ -176,8 +176,6 @@ def get_command(self, key, mode):

def bind(self, key, command, *, mode, force=False, save_yaml=False):
"""Add a new binding from key to command."""
# Doing this here to work around a Python 3.4 circular import
from qutebrowser.commands import runners
key = self._prepare(key, mode)

parser = runners.CommandParser()
Expand Down Expand Up @@ -594,8 +592,6 @@ def set_register_stylesheet(obj, *, stylesheet=None, update=True):
@functools.lru_cache()
def _render_stylesheet(stylesheet):
"""Render the given stylesheet jinja template."""
# Imported here to avoid a Python 3.4 circular import
from qutebrowser.utils import jinja
with jinja.environment.no_autoescape():
template = jinja.environment.from_string(stylesheet)
return template.render(conf=val)
Expand Down
3 changes: 1 addition & 2 deletions qutebrowser/config/configexc.py
Expand Up @@ -19,7 +19,7 @@

"""Exceptions related to config parsing."""

from qutebrowser.utils import utils
from qutebrowser.utils import utils, jinja


class Error(Exception):
Expand Down Expand Up @@ -108,7 +108,6 @@ def __init__(self, basename, errors):

def to_html(self):
"""Get the error texts as a HTML snippet."""
from qutebrowser.utils import jinja
template = jinja.environment.from_string("""
Errors occurred while reading {{ basename }}:
Expand Down
7 changes: 3 additions & 4 deletions qutebrowser/config/configfiles.py
Expand Up @@ -30,7 +30,7 @@
from PyQt5.QtCore import QSettings

import qutebrowser
from qutebrowser.config import configexc
from qutebrowser.config import configexc, config
from qutebrowser.utils import standarddir, utils, qtutils


Expand Down Expand Up @@ -152,8 +152,8 @@ class ConfigAPI:
errors: Errors which occurred while setting options.
"""

def __init__(self, config, keyconfig):
self._config = config
def __init__(self, conf, keyconfig):
self._config = conf
self._keyconfig = keyconfig
self.load_autoconfig = True
self.errors = []
Expand Down Expand Up @@ -189,7 +189,6 @@ def unbind(self, key, *, mode):

def read_config_py(filename=None):
"""Read a config.py file."""
from qutebrowser.config import config
api = ConfigAPI(config.instance, config.key_instance)

if filename is None:
Expand Down
7 changes: 2 additions & 5 deletions qutebrowser/config/configtypes.py
Expand Up @@ -59,9 +59,9 @@
from PyQt5.QtGui import QColor, QFont
from PyQt5.QtWidgets import QTabWidget, QTabBar

from qutebrowser.commands import cmdutils
from qutebrowser.commands import cmdutils, runners, cmdexc
from qutebrowser.config import configexc
from qutebrowser.utils import standarddir, utils, qtutils
from qutebrowser.utils import standarddir, utils, qtutils, urlutils


SYSTEM_PROXY = object() # Return value for Proxy type
Expand Down Expand Up @@ -791,7 +791,6 @@ def to_py(self, value):
if not Command.unvalidated:
Command.unvalidated = True
try:
from qutebrowser.commands import runners, cmdexc
parser = runners.CommandParser()
try:
parser.parse_all(value)
Expand Down Expand Up @@ -1287,7 +1286,6 @@ def __init__(self, none_ok=False):
('none', "Don't use any proxy"))

def to_py(self, value):
from qutebrowser.utils import urlutils
self._basic_py_validation(value, str)
if not value:
return None
Expand Down Expand Up @@ -1352,7 +1350,6 @@ class FuzzyUrl(BaseType):
"""A URL which gets interpreted as search if needed."""

def to_py(self, value):
from qutebrowser.utils import urlutils
self._basic_py_validation(value, str)
if not value:
return None
Expand Down
8 changes: 6 additions & 2 deletions qutebrowser/mainwindow/mainwindow.py
Expand Up @@ -31,8 +31,7 @@
from qutebrowser.config import config, configfiles
from qutebrowser.utils import (message, log, usertypes, qtutils, objreg, utils,
jinja, debug)
from qutebrowser.mainwindow import tabbedbrowser, messageview, prompt
from qutebrowser.mainwindow.statusbar import bar
from qutebrowser.mainwindow import messageview, prompt
from qutebrowser.completion import completionwidget, completer
from qutebrowser.keyinput import modeman
from qutebrowser.browser import (commands, downloadview, hints,
Expand Down Expand Up @@ -140,6 +139,11 @@ def __init__(self, *, private, geometry=None, parent=None):
parent: The parent the window should get.
"""
super().__init__(parent)
# Late import to avoid a circular dependency
# - browsertab -> hints -> webelem -> mainwindow -> bar -> browsertab
from qutebrowser.mainwindow import tabbedbrowser
from qutebrowser.mainwindow.statusbar import bar

self.setAttribute(Qt.WA_DeleteOnClose)
self._commandrunner = None
self._overlays = []
Expand Down
3 changes: 1 addition & 2 deletions qutebrowser/mainwindow/tabbedbrowser.py
Expand Up @@ -28,7 +28,7 @@

from qutebrowser.config import config
from qutebrowser.keyinput import modeman
from qutebrowser.mainwindow import tabwidget
from qutebrowser.mainwindow import tabwidget, mainwindow
from qutebrowser.browser import signalfilter, browsertab
from qutebrowser.utils import (log, usertypes, utils, qtutils, objreg,
urlutils, message, jinja)
Expand Down Expand Up @@ -432,7 +432,6 @@ def tabopen(self, url=None, background=None, related=True, idx=None, *,

if (config.val.tabs.tabs_are_windows and self.count() > 0 and
not ignore_tabs_are_windows):
from qutebrowser.mainwindow import mainwindow
window = mainwindow.MainWindow(private=self.private)
window.show()
tabbed_browser = objreg.get('tabbed-browser', scope='window',
Expand Down
4 changes: 2 additions & 2 deletions qutebrowser/misc/checkpyver.py
Expand Up @@ -43,12 +43,12 @@
# to stderr.
def check_python_version():
"""Check if correct python version is run."""
if sys.hexversion < 0x03040000:
if sys.hexversion < 0x03050000:
# We don't use .format() and print_function here just in case someone
# still has < 2.6 installed.
# pylint: disable=bad-builtin
version_str = '.'.join(map(str, sys.version_info[:3]))
text = ("At least Python 3.4 is required to run qutebrowser, but " +
text = ("At least Python 3.5 is required to run qutebrowser, but " +
version_str + " is installed!\n")
if Tk and '--no-err-windows' not in sys.argv: # pragma: no cover
root = Tk()
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/misc/earlyinit.py
Expand Up @@ -19,7 +19,7 @@

"""Things which need to be done really early (e.g. before importing Qt).
At this point we can be sure we have all python 3.4 features available.
At this point we can be sure we have all python 3.5 features available.
"""

try:
Expand Down
2 changes: 1 addition & 1 deletion qutebrowser/misc/sessions.py
Expand Up @@ -32,6 +32,7 @@
from qutebrowser.commands import cmdexc, cmdutils
from qutebrowser.config import config, configfiles
from qutebrowser.completion.models import miscmodels
from qutebrowser.mainwindow import mainwindow


default = object() # Sentinel value
Expand Down Expand Up @@ -371,7 +372,6 @@ def load(self, name, temp=False):
name: The name of the session to load.
temp: If given, don't set the current session.
"""
from qutebrowser.mainwindow import mainwindow
path = self._get_session_path(name, check_exists=True)
try:
with open(path, encoding='utf-8') as f:
Expand Down

0 comments on commit 505321c

Please sign in to comment.