Skip to content

Commit

Permalink
Merge branch 'main' into typing-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams committed Nov 19, 2024
2 parents 23b6f3e + 094d446 commit 59e1818
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: "CodeQL"

on:
push:
branches: [master]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
branches: [main]
schedule:
- cron: '0 11 * * 0'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
with:
python-version: 3.x
architecture: x64
- name: Install setuptools
run: pip install setuptools
- name: Build a source distribution
run: python setup.py sdist
- name: Publish to prod PyPI
Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ name: Test Eel

on:
push:
branches: [ master ]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
python-version: 3.7

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
Expand All @@ -25,18 +31,22 @@ jobs:
- name: Setup test execution environment.
run: pip3 install -r requirements-meta.txt
- name: Run tox tests
run: tox -- --durations=0 --timeout=30
run: tox -- --durations=0 --timeout=240

typecheck:
runs-on: windows-latest
strategy:
matrix:
os: [windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.x"
- name: Setup test execution environment.
run: pip3 install -r requirements-meta.txt
- name: Run tox tests
Expand Down
5 changes: 1 addition & 4 deletions .python-version
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
3.7.14
3.8.14
3.9.13
3.10.8
3.10
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change log

### 0.17.0
* Adds support for Python 3.11 and Python 3.12

### v0.16.0
* Drop support for Python versions below 3.7

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Additional options can be passed to `eel.start()` as keyword arguments.
Some of the options include the mode the app is in (e.g. 'chrome'), the port the app runs on, the host name of the app, and adding additional command line flags.

As of Eel v0.12.0, the following options are available to `start()`:
- **mode**, a string specifying what browser to use (e.g. `'chrome'`, `'electron'`, `'edge'`, `'custom'`). Can also be `None` or `False` to not open a window. *Default: `'chrome'`*
- **mode**, a string specifying what browser to use (e.g. `'chrome'`, `'electron'`, `'edge'`,`'msie'`, `'custom'`). Can also be `None` or `False` to not open a window. *Default: `'chrome'`*
- **host**, a string specifying what hostname to use for the Bottle server. *Default: `'localhost'`)*
- **port**, an int specifying what port to use for the Bottle server. Use `0` for port to be picked automatically. *Default: `8000`*.
- **block**, a bool saying whether or not the call to `start()` should block the calling thread. *Default: `True`*
Expand Down
5 changes: 4 additions & 1 deletion eel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import gevent as gvt
import json as jsn
import bottle as btl
import bottle.ext.websocket as wbs
try:
import bottle_websocket as wbs
except ImportError:
import bottle.ext.websocket as wbs
import re as rgx
import os
import eel.browsers as brw
Expand Down
4 changes: 3 additions & 1 deletion eel/browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import eel.chrome as chm
import eel.electron as ele
import eel.edge as edge
import eel.msIE as ie
#import eel.firefox as ffx TODO
#import eel.safari as saf TODO

_browser_paths: Dict[str, str] = {}
_browser_modules: Dict[str, ModuleType] = {'chrome': chm,
'electron': ele,
'edge': edge}
'edge': edge,
'msie':ie}


def _build_url_from_dict(page: Dict[str, str], options: OptionsDictT) -> str:
Expand Down
13 changes: 10 additions & 3 deletions eel/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@


def run(_path: str, options: OptionsDictT, start_urls: List[str]) -> None:
cmd = 'start microsoft-edge:{}'.format(start_urls[0])
sps.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sps.PIPE, shell=True)

if not isinstance(options['cmdline_args'], list):
raise TypeError("'cmdline_args' option must be of type List[str]")
args: List[str] = options['cmdline_args']
if options['app_mode']:
cmd = 'start msedge --app={} '.format(start_urls[0])
cmd = cmd + (" ".join(args))
sps.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sps.PIPE, shell=True)
else:
cmd = "start msedge --new-window "+(" ".join(args)) +" "+(start_urls[0])
sps.Popen(cmd,stdout=sys.stdout, stderr=sys.stderr, stdin=sps.PIPE, shell=True)

def find_path() -> bool:
if platform.system() == 'Windows':
Expand Down
20 changes: 20 additions & 0 deletions eel/msIE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import platform
import subprocess as sps
import sys
from typing import List

from eel.types import OptionsDictT

name: str = 'MSIE'


def run(_path: str, options: OptionsDictT, start_urls: List[str]) -> None:
cmd = 'start microsoft-edge:{}'.format(start_urls[0])
sps.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, stdin=sps.PIPE, shell=True)


def find_path() -> bool:
if platform.system() == 'Windows':
return True

return False
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
python_version = 3.10
warn_unused_configs = True

[mypy-bottle_websocket]
ignore_missing_imports = True

[mypy-gevent]
ignore_missing_imports = True

Expand Down
1 change: 1 addition & 0 deletions requirements-meta.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ tox>=3.15.2,<4.0.0
tox-pyenv==1.1.0
tox-gh-actions==2.0.0
virtualenv>=16.7.10
setuptools
16 changes: 8 additions & 8 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.[jinja2]

psutil==5.9.2
pytest==7.0.1
pytest-timeout==2.1.0
selenium==3.141.0
webdriver_manager==3.7.1
mypy==0.971
pyinstaller==4.10
types-setuptools==67.2.0.1
psutil>=5.0.0,<6.0.0
pytest>=7.0.0,<8.0.0
pytest-timeout>=2.0.0,<3.0.0
selenium>=4.0.0,<5.0.0
webdriver_manager>=4.0.0,<5.0.0
mypy>=1.0.0,<2.0.0
pyinstaller
types-setuptools
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='Eel',
version='0.16.0',
version='0.17.0',
author='Python Eel Organisation',
author_email='python-eel@protonmail.com',
url='https://github.com/python-eel/Eel',
Expand Down
11 changes: 4 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager


Expand All @@ -14,18 +14,15 @@ def driver():

if TEST_BROWSER == "chrome":
options = webdriver.ChromeOptions()
options.headless = True
capabilities = DesiredCapabilities.CHROME
capabilities["goog:loggingPrefs"] = {"browser": "ALL"}
options.add_argument('--headless=new')
options.set_capability("goog:loggingPrefs", {"browser": "ALL"})

if platform.system() == "Windows":
options.binary_location = "C:/Program Files/Google/Chrome/Application/chrome.exe"

driver = webdriver.Chrome(
ChromeDriverManager().install(),
service=ChromeService(ChromeDriverManager().install()),
options=options,
desired_capabilities=capabilities,
service_log_path=os.path.devnull,
)

# Firefox doesn't currently supported pulling JavaScript console logs, which we currently scan to affirm that
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ def test_04_file_access(driver: webdriver.Remote):
assert driver.title == "Eel Demo"

with TemporaryDirectory() as temp_dir, NamedTemporaryFile(dir=temp_dir) as temp_file:
driver.find_element_by_id('input-box').clear()
driver.find_element_by_id('input-box').send_keys(temp_dir)
driver.find_element(value='input-box').clear()
driver.find_element(value='input-box').send_keys(temp_dir)
time.sleep(0.5)
driver.find_element_by_css_selector('button').click()
driver.find_element(By.CSS_SELECTOR, 'button').click()

assert driver.find_element_by_id('file-name').text == os.path.basename(temp_file.name)
assert driver.find_element(value='file-name').text == os.path.basename(temp_file.name)


def test_06_jinja_templates(driver: webdriver.Remote):
with get_eel_server('examples/06 - jinja_templates/hello.py', 'templates/hello.html') as eel_url:
driver.get(eel_url)
assert driver.title == "Hello, World!"

driver.find_element_by_css_selector('a').click()
driver.find_element(By.CSS_SELECTOR, 'a').click()
WebDriverWait(driver, 2.0).until(expected_conditions.presence_of_element_located((By.XPATH, '//h1[text()="This is page 2"]')))


Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = typecheck,py{37,38,39,310}
envlist = typecheck,py{37,38,39,310,311,312}

[pytest]
timeout = 30
Expand All @@ -10,6 +10,9 @@ python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312


[testenv]
description = run py.test tests
Expand Down

0 comments on commit 59e1818

Please sign in to comment.