Skip to content

Commit

Permalink
Bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
acabal committed Dec 27, 2024
1 parent f3676ca commit 6a8d970
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ We export `COLUMNS` because `se lint` needs to know the width of the terminal so
Before we can use `pylint` or `mypy` on the toolset source, we have to inject them (and additional typings) into the venv `pipx` created for the `standardebooks` package:

```shell
pipx inject standardebooks pylint==3.2.2 mypy==1.10.0 types-requests==2.32.0.20240602 types-setuptools==70.0.0.20240524 types-Pillow==10.2.0.20240520
pipx inject standardebooks pylint==3.3.3 mypy==1.14.0 types-requests==2.32.0.20241016 types-setuptools==75.6.0.20241223 types-Pillow==10.2.0.20240822
```

Then make sure to call the `pylint` and `mypy` binaries that `pipx` installed in the `standardebooks` venv, *not* any other globally-installed binaries:
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ignore=vendor
extension-pkg-whitelist=lxml,math,unicodedata

[MESSAGES CONTROL]
disable=line-too-long,too-many-nested-blocks,too-many-branches,too-many-statements,too-many-boolean-expressions,too-many-lines,too-many-locals,broad-except,too-few-public-methods,too-many-arguments,too-many-instance-attributes,too-many-public-methods,duplicate-code
disable=line-too-long,too-many-nested-blocks,too-many-branches,too-many-statements,too-many-boolean-expressions,too-many-lines,too-many-locals,broad-except,too-few-public-methods,too-many-arguments,too-many-instance-attributes,too-many-public-methods,duplicate-code,too-many-positional-arguments

[FORMAT]
indent-string=\t
Expand Down
29 changes: 7 additions & 22 deletions se/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
Defines functions for interacting with headless browser sessions.
"""

import os
import platform
import shutil
from pathlib import Path

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

import se

def initialize_selenium_firefox_webdriver() -> webdriver.firefox.webdriver.WebDriver:
def initialize_selenium_firefox_webdriver() -> webdriver.Firefox:
"""
Initialize a Selenium Firefox driver and return it for use in other applications.
Expand All @@ -29,8 +28,8 @@ def initialize_selenium_firefox_webdriver() -> webdriver.firefox.webdriver.WebDr
# Initialize the selenium driver to take screenshots

# We have to use the headless option, otherwise it will pop up a Firefox window
options = webdriver.FirefoxOptions()
options.headless = True
options = Options()
options.add_argument('-headless')

# Disable the history, because otherwise links to (for example to end notes) may appear as "visited" in visits to other pages, and thus cause a fake diff
profile = webdriver.FirefoxProfile()
Expand All @@ -41,20 +40,6 @@ def initialize_selenium_firefox_webdriver() -> webdriver.firefox.webdriver.WebDr
profile.set_preference("browser.http.use-cache", False)
profile.set_preference("layout.css.devPixelsPerPx", "2.0")

possible_system_geckodriver = shutil.which("geckodriver")

if platform.system() == "Linux":
geckodriver_path = Path("se.data.geckodriver", "geckodriver-linux64")
elif platform.system() == "Windows":
geckodriver_path = Path("se.data.geckodriver", "geckodriver-win64.exe")
elif platform.system() == "Darwin":
if platform.machine() == "arm64":
geckodriver_path = Path("se.data.geckodriver", "geckodriver-macos-aarch64")
else:
geckodriver_path = Path("se.data.geckodriver", "geckodriver-macos")
elif possible_system_geckodriver is not None:
geckodriver_path = Path(possible_system_geckodriver)
else:
raise se.MissingDependencyException("Selenium Firefox web driver is not installed. To install it on Linux or Windows, download the appropriate zip file from [url][link=https://github.com/mozilla/geckodriver/releases/latest]https://github.com/mozilla/geckodriver/releases/latest[/][/] and place the [bash]geckodriver[/] executable in your [path]$PATH[/] (for example, in [path]~/.local/bin/[/] or [path]/usr/local/bin/[/]). To install it on macOS, run [bash]brew install geckodriver[/].")

return webdriver.Firefox(firefox_profile=profile, options=options, service_log_path=os.devnull, executable_path=geckodriver_path)
options.profile = profile

return webdriver.Firefox(options=options)
12 changes: 7 additions & 5 deletions se/commands/compare_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ def compare_versions(plain_output: bool) -> int:
# driver.quit() if execution is interrupted (like by ctrl + c, or by an unhandled exception). If we don't call driver.quit(),
# Firefox will stay around as a zombie process even if the Python script is dead.
try:
try:
driver = se.browser.initialize_selenium_firefox_webdriver()
except se.MissingDependencyException as ex:
se.print_error(ex, plain_output=plain_output)
return ex.code
driver = se.browser.initialize_selenium_firefox_webdriver()

# Ready to go!
for target in args.targets:
Expand Down Expand Up @@ -187,9 +183,15 @@ def compare_versions(plain_output: bool) -> int:

with open(output_directory / "diff.html", "w", encoding="utf-8") as file:
file.write(html)

except se.MissingDependencyException as ex:
se.print_error(ex, plain_output=plain_output)
return ex.code

except KeyboardInterrupt as ex:
# Bubble the exception up, but proceed to `finally` so we quit the driver
raise ex

finally:
try:
driver.quit()
Expand Down
Empty file removed se/data/geckodriver/__init__.py
Empty file.
Binary file removed se/data/geckodriver/geckodriver-linux64
Binary file not shown.
Binary file removed se/data/geckodriver/geckodriver-macos
Binary file not shown.
Binary file removed se/data/geckodriver/geckodriver-macos-aarch64
Binary file not shown.
Binary file removed se/data/geckodriver/geckodriver-win64.exe
Binary file not shown.
30 changes: 15 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ def _get_version() -> str:
"chardet==5.2.0",
"cssselect==1.2.0",
"cssutils==2.9.0",
"ftfy==6.0.3",
"gitpython==3.1.41",
"ftfy==6.3.1",
"gitpython==3.1.43",
"importlib_resources==1.0.2",
"lxml==4.9.3",
"lxml==5.3.0",
"natsort==8.4.0",
"pillow==10.3.0",
"psutil==5.9.6",
"pyphen==0.14.0",
"regex==2023.10.3",
"requests==2.32.0",
"rich==13.7.0",
"roman==4.1",
"selenium==4.9.0",
"setuptools==70.0.0",
"pillow==11.0.0",
"psutil==6.1.1",
"pyphen==0.17.0",
"regex==2024.11.6",
"requests==2.32.3",
"rich==13.9.4",
"roman==4.2",
"selenium==4.27.1",
"setuptools==75.6.0",
"smartypants==2.0.1",
"tinycss2==1.2.1",
"titlecase==2.4",
"unidecode==1.3.7"
"tinycss2==1.4.0",
"titlecase==2.4.1",
"unidecode==1.3.8"
]
)

0 comments on commit 6a8d970

Please sign in to comment.