Skip to content

Commit cf6f693

Browse files
authored
Merge pull request #168 from davidhewitt/tidy-html-py-ever
html-py-ever: tidy ups for tests and CI
2 parents 5793b58 + a1e2e5c commit cf6f693

File tree

7 files changed

+118
-108
lines changed

7 files changed

+118
-108
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ jobs:
2626
strategy:
2727
fail-fast: false # If one platform fails, allow the rest to keep testing.
2828
matrix:
29-
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
29+
python-version: [3.6, 3.7, 3.8, 3.9, 3.10-dev, pypy-3.6, pypy-3.7]
3030
platform: [
3131
{ os: "macos-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
3232
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
3333
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
3434
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
3535
]
3636
exclude:
37-
# No 64-bit pypy on windows
38-
- python-version: pypy3
37+
# No 64-bit pypy 3.6 on Windows
38+
- python-version: pypy-3.6
3939
platform: { os: "windows-latest", python-architecture: "x64" }
40-
# Example rust_with_cffi broken on Python 3.5 for Windows, never mind!
41-
- python-version: 3.5
42-
platform: { os: "windows-latest" }
40+
# No 32-bit pypy 3.7 on Windows
41+
- python-version: pypy-3.7
42+
platform: { os: "windows-latest", python-architecture: "x86" }
4343

4444
steps:
4545
- uses: actions/checkout@v2
@@ -65,11 +65,14 @@ jobs:
6565
- name: Install test dependencies
6666
run: pip install --upgrade tox setuptools
6767

68+
- name: Install wheel (workaround python 3.10 CI issue)
69+
if: matrix.python-version == '3.10-dev'
70+
run: pip install --upgrade wheel
71+
6872
- name: Build package
6973
run: pip install -e .
7074

7175
- name: Test examples
72-
if: matrix.python-version != 'pypy3'
7376
shell: bash
7477
env:
7578
PYTHON: ${{ matrix.python-version }}
@@ -78,20 +81,6 @@ jobs:
7881
tox -c $example_dir -e py
7982
done
8083
81-
- name: Test examples (pypy)
82-
# FIXME: issues with tox + pypy + windows
83-
if: matrix.python-version == 'pypy3' && matrix.platform.os != 'windows-latest'
84-
shell: bash
85-
run: |
86-
for example_dir in examples/*; do
87-
if [[ $example_dir = "examples/html-py-ever" ]]; then
88-
echo "skipping html-py-ever on pypy3 - lxml is hard to build from source"
89-
continue
90-
fi
91-
92-
tox -c $example_dir -e py
93-
done
94-
9584
- name: Test macOS universal2
9685
if: matrix.platform.os == 'macos-latest'
9786
shell: bash

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Processing dependencies for hello_rust==1.0
7777
Finished processing dependencies for hello_rust==1.0
7878
```
7979

80-
Or you can use commands like ``bdist_wheel`` (after installing ``wheel``). See also [the notes in the documentation about building wheels](https://setuptools-rust.readthedocs.io/en/latest/building_wheels.html).
80+
Or you can use commands like `bdist_wheel` (after installing `wheel`). See also [the notes in the documentation about building wheels](https://setuptools-rust.readthedocs.io/en/latest/building_wheels.html).
8181

8282
By default, `develop` will create a debug build, while `install` will create a release build.
8383

examples/html-py-ever/README.md

Lines changed: 59 additions & 54 deletions
Large diffs are not rendered by default.

examples/html-py-ever/setup.cfg

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[metadata]
2+
name = html-py-ever
3+
version = 0.1.0
4+
license = MIT
5+
url = https://github.com/PyO3/setuptools-rust/blob/main/examples/html-py-ever
6+
long_description = file: README.md
7+
long_description_content_type = text/markdown
8+
classifiers =
9+
License :: OSI Approved :: MIT License
10+
Intended Audience :: Developers
11+
Programming Language :: Python :: 3
12+
Programming Language :: Python :: 3.6
13+
Programming Language :: Python :: 3.7
14+
Programming Language :: Python :: 3.8
15+
Programming Language :: Python :: 3.9
16+
Development Status :: 5 - Production/Stable
17+
Operating System :: POSIX
18+
Operating System :: MacOS :: MacOS X
19+
Operating System :: Microsoft :: Windows
20+
21+
[options]
22+
packages = html_py_ever
23+
zip_safe = False
24+
setup_requires = setuptools-rust >= 0.12.1;
25+
python_requires = >=3.6
26+
include_package_data = True

examples/html-py-ever/setup.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,9 @@
22
import sys
33

44
from setuptools import setup
5+
56
from setuptools_rust import RustExtension
67

78
setup(
8-
name="html-py-ever",
9-
version="0.1.0",
10-
classifiers=[
11-
"License :: OSI Approved :: MIT License",
12-
"Development Status :: 3 - Alpha",
13-
"Intended Audience :: Developers",
14-
"Programming Language :: Python :: 3.6",
15-
"Programming Language :: Python :: 3.7",
16-
"Programming Language :: Python :: 3.8",
17-
"Programming Language :: Rust",
18-
"Operating System :: POSIX",
19-
"Operating System :: MacOS :: MacOS X",
20-
],
21-
packages=["html_py_ever"],
22-
install_requires=["beautifulsoup4", "lxml"],
239
rust_extensions=[RustExtension("html_py_ever.html_py_ever")],
24-
include_package_data=True,
25-
zip_safe=False,
2610
)

examples/html-py-ever/test/run_all.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#!/usr/bin/env python3
2+
import os
23
from glob import glob
34
from time import perf_counter
45
from typing import Tuple
56

67
import html_py_ever
78
from bs4 import BeautifulSoup
89

10+
try:
11+
import lxml
12+
13+
HAVE_LXML = True
14+
except ImportError:
15+
HAVE_LXML = False
16+
917

1018
def rust(filename: str) -> Tuple[int, float, float]:
1119
start_load = perf_counter()
@@ -34,23 +42,20 @@ def python(filename: str, parser: str) -> Tuple[int, float, float]:
3442

3543

3644
def main():
37-
for filename in glob("*.html"):
45+
files_glob = os.path.abspath(os.path.join(os.path.dirname(__file__), "*.html"))
46+
for filename in glob(files_glob):
3847
count_rs, parse_rs, select_rs = rust(filename)
39-
count_lxml, parse_lxml, select_lxml = python(filename, "lxml")
4048
count_py, parse_py, select_py = python(filename, "html.parser")
41-
assert count_rs == count_lxml
4249
assert count_rs == count_py
43-
print(f"{filename} {count_rs}")
44-
print(
45-
f"Parse lxml {parse_rs:6f}s {parse_lxml:6f}s {parse_lxml/parse_rs:6.3f}x"
46-
)
47-
print(f"Parse py {parse_rs:6f}s {parse_py:6f}s {parse_py/parse_rs:6.3f}x")
48-
print(
49-
f"Select lxml {select_lxml:6f}s {select_rs:6f}s {select_lxml/select_rs:6.3f}x"
50-
)
51-
print(
52-
f"Select py {select_py:6f}s {select_rs:6f}s {select_py/select_rs:6.3f}x"
53-
)
50+
print(f"{filename} {count_rs} {parse_rs:6f}s")
51+
print(f"Parse py {parse_py:6f}s {parse_py/parse_rs:6.3f}x")
52+
print(f"Select py {select_py:6f}s {select_py/select_rs:6.3f}x")
53+
54+
if HAVE_LXML:
55+
count_lxml, parse_lxml, select_lxml = python(filename, "lxml")
56+
assert count_rs == count_lxml
57+
print(f"Parse lxml {parse_lxml:6f}s {parse_lxml/parse_rs:6.3f}x")
58+
print(f"Select lxml {select_lxml:6f}s {select_lxml/select_rs:6.3f}x")
5459

5560

5661
if __name__ == "__main__":

examples/html-py-ever/tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ requires =
66
description = Run the unit tests under {basepython}
77
deps =
88
setuptools-rust @ file://{toxinidir}/../../
9-
pytest-benchmark[historgram]
9+
pytest-benchmark
10+
beautifulsoup4
1011
pytest>=3.6
1112
commands = pytest {posargs}

0 commit comments

Comments
 (0)