Skip to content

Commit 9291ae9

Browse files
committed
Fix html-py-ever in CI
1 parent 4ad51ba commit 9291ae9

File tree

9 files changed

+40
-42
lines changed

9 files changed

+40
-42
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ jobs:
2323
toolchain: stable
2424
override: true
2525

26-
# Install dependencies on ubuntu
27-
- if: matrix.os == 'ubuntu-latest'
28-
name: Install build dependencies
29-
run: sudo apt-get install -y libxml2-dev libxslt-dev
30-
3126
# Install 32-bit windows target for pypy3
3227
- if: matrix.os == 'windows-latest' && matrix.python-version == 'pypy3'
3328
name: Install 32-bit Rust target
@@ -48,15 +43,18 @@ jobs:
4843
cd example_tomlgen
4944
python setup.py tomlgen_rust -w build
5045
51-
# FIXME: Can't test easily on windows 3.9 or pypy because have to build lxml from source!
46+
# Install lxml build dependencies on ubuntu for pypy
47+
- if: matrix.os == 'ubuntu-latest' && matrix.python-version == 'pypy3'
48+
name: Install lxml build dependencies
49+
run: sudo apt-get install -y libxml2-dev libxslt-dev
50+
51+
# Can't test easily on windows pypy because have to build lxml from source!
5252
- name: Test html-py-ever
53-
if: ${{ !(matrix.os == 'windows-latest' && (matrix.python-version == 'pypy3' || matrix.python-version == '3.9-dev')) }}
53+
if: ${{ !(matrix.os == 'windows-latest' && matrix.python-version == 'pypy3') }}
5454
shell: bash
5555
run: |
56-
cd html-py-ever
57-
pip install -r requirements-dev.txt
58-
python setup.py install
59-
cd test && pytest
56+
pip install tox
57+
tox -c html-py-ever -e py
6058
6159
- name: Test other examples
6260
shell: bash

html-py-ever/MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include Cargo.toml
2+
recursive-include src *

html-py-ever/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Demoing hot to use [html5ever](https://github.com/servo/html5ever) through [kuch
88

99
## Benchmarking
1010

11-
Create a python 3.6+ venv and activate it. Install html-py-ever in there (`python setup.py install`). To get a readable benchmark, run `test/run_all.py`. To get a real benchmark, run `pytest test_parsing.py` or `pytest test_selector.py`. Both have a `--benchmark-histogram` option.
11+
Run `tox -e py`.
1212

1313
## Example benchmark results
1414

html-py-ever/pyproject.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

html-py-ever/requirements-dev.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

html-py-ever/setup.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,7 @@
22
import sys
33

44
from setuptools import setup
5-
6-
try:
7-
from setuptools_rust import RustExtension
8-
except ImportError:
9-
import subprocess
10-
11-
errno = subprocess.call([sys.executable, "-m", "pip", "install", "setuptools-rust"])
12-
if errno:
13-
print("Please install setuptools-rust package")
14-
raise SystemExit(errno)
15-
else:
16-
from setuptools_rust import RustExtension
17-
18-
setup_requires = ["setuptools-rust>=0.10.1", "wheel"]
19-
install_requires = []
5+
from setuptools_rust import RustExtension
206

217
setup(
228
name="html-py-ever",
@@ -31,9 +17,11 @@
3117
"Operating System :: MacOS :: MacOS X",
3218
],
3319
packages=["html_py_ever"],
20+
install_requires=[
21+
"beautifulsoup4",
22+
"lxml"
23+
],
3424
rust_extensions=[RustExtension("html_py_ever.html_py_ever")],
35-
install_requires=install_requires,
36-
setup_requires=setup_requires,
3725
include_package_data=True,
3826
zip_safe=False,
3927
)

html-py-ever/test/test_parsing.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/usr/bin/env python
22
from glob import glob
3+
import os
34

45
import html_py_ever
56
import pytest
67
from bs4 import BeautifulSoup
78
from html_py_ever import Document
89

910

11+
HTML_FILES = glob(os.path.join(os.path.dirname(__file__), "*.html"))
12+
13+
1014
def rust(filename: str) -> Document:
1115
return html_py_ever.parse_file(filename)
1216

@@ -18,11 +22,11 @@ def python(filename: str) -> BeautifulSoup:
1822
return soup
1923

2024

21-
@pytest.mark.parametrize("filename", list(glob("*.html")))
25+
@pytest.mark.parametrize("filename", HTML_FILES)
2226
def test_bench_parsing_rust(benchmark, filename):
2327
benchmark(rust, filename)
2428

2529

26-
@pytest.mark.parametrize("filename", list(glob("*.html")))
30+
@pytest.mark.parametrize("filename", HTML_FILES)
2731
def test_bench_parsing_python(benchmark, filename):
2832
benchmark(python, filename)

html-py-ever/test/test_selector.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
#!/usr/bin/env python
22
from glob import glob
3+
import os
34

45
import html_py_ever
56
import pytest
67
from bs4 import BeautifulSoup
78

89

9-
@pytest.mark.parametrize("filename", list(glob("*.html")))
10+
HTML_FILES = glob(os.path.join(os.path.dirname(__file__), "*.html"))
11+
12+
13+
@pytest.mark.parametrize("filename", HTML_FILES)
1014
def test_bench_selector_rust(benchmark, filename):
1115
document = html_py_ever.parse_file(filename)
1216
benchmark(document.select, "a[href]")
1317

1418

15-
@pytest.mark.parametrize("filename", list(glob("*.html")))
19+
@pytest.mark.parametrize("filename", HTML_FILES)
1620
def test_bench_selector_python(benchmark, filename):
1721
with open(filename, encoding='utf8') as fp:
1822
soup = BeautifulSoup(fp, "html.parser")

html-py-ever/tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tox]
2+
requires =
3+
setuptools-rust @ file://{toxinidir}/../
4+
5+
[testenv]
6+
description = Run the unit tests under {basepython}
7+
deps =
8+
setuptools-rust @ file://{toxinidir}/../
9+
pytest-benchmark[historgram]
10+
pytest>=3.6
11+
commands = pytest {posargs}

0 commit comments

Comments
 (0)