Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.11.5 #87

Merged
merged 3 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 50 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,75 @@
name: CI
on:
pull_request: {}
push: {}
on: [push]

jobs:
test:
runs-on: ${{ matrix.os }}
build:
name: ${{ matrix.python-version }} ${{ matrix.platform.os }}-${{ matrix.platform.python-architecture }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false # If one platform fails, allow the rest to keep testing.
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
platform: [
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
]
exclude:
# No 64-bit pypy on windows
- python-version: pypy3
platform: { os: "windows-latest", python-architecture: "x64" }
# Example rust_with_cffi broken on Python 3.5 for Windows, never mind!
- python-version: 3.5
platform: { os: "windows-latest" }

steps:
- uses: actions/checkout@master
- name: Setup python
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.platform.python-architecture }}

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

# Install dependencies on ubuntu
- if: matrix.os == 'ubuntu-latest'
name: Install build dependencies
run: sudo apt-get install -y libxml2-dev libxslt-dev

# Install 32-bit windows target for pypy3
- if: matrix.os == 'windows-latest' && matrix.python-version == 'pypy3'
name: Install 32-bit Rust target
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: i686-pc-windows-msvc
target: ${{ matrix.platform.rust-target }}
profile: minimal
default: true

- name: Install test dependencies
run: pip install --upgrade tox setuptools

- name: Build package
run: pip install -e .

- name: Test tomlgen_rust
- name: Test examples
if: matrix.python-version != 'pypy3'
shell: bash
env:
PYTHON: ${{ matrix.python-version }}
run: |
pip install wheel
cd example_tomlgen
python setup.py tomlgen_rust -w build
for example_dir in examples/*; do
tox -c $example_dir -e py
done

# FIXME: Can't test easily on windows 3.9 or pypy because have to build lxml from source!
- name: Test html-py-ever
if: ${{ !(matrix.os == 'windows-latest' && (matrix.python-version == 'pypy3' || matrix.python-version == '3.9-dev')) }}
- name: Test examples (pypy)
# FIXME: issues with tox + pypy + windows
if: matrix.python-version == 'pypy3' && matrix.platform.os != 'windows-latest'
shell: bash
run: |
cd html-py-ever
pip install -r requirements-dev.txt
python setup.py install
cd test && pytest
for example_dir in examples/*; do
if [[ $example_dir = "examples/html-py-ever" ]]; then
echo "skipping html-py-ever on pypy3 - lxml is hard to build from source"
continue
fi

tox -c $example_dir -e py
done

- name: Test other examples
shell: bash
run: |
cd examples/
# PEP517 build isolation means we don't use the setuptools-rust locally,
# instead it installs from PyPI!
pip install --no-use-pep517 -e rust_with_cffi/
pip install -r rust_with_cffi/requirements-dev.txt
pytest rust_with_cffi/tests.py
test-abi3:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -93,11 +96,12 @@ jobs:
run: |
cd examples/rust_with_cffi/
python --version
pip install wheel
python setup.py bdist_wheel --py-limited-api=cp35
ls -la dist/

# Now we switch to a differnet Python version and ensure we can install
# the wheel we just buitl.
# the wheel we just built.
- name: Setup python
uses: actions/setup-python@v2
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.11.5 (2020-11-10)

- Fix support for Python 3.5. [#86](https://github.com/PyO3/setuptools-rust/pull/86)
- Fix further cases of building for 32-bit Python on 64-bit Windows. [#87](https://github.com/PyO3/setuptools-rust/pull/87)

## 0.11.4 (2020-11-03)

- Fix `tomlgen` functionality on Windows. [#78](https://github.com/PyO3/setuptools-rust/pull/78)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/html-py-ever/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include Cargo.toml
recursive-include src *
2 changes: 1 addition & 1 deletion html-py-ever/README.md → examples/html-py-ever/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Demoing hot to use [html5ever](https://github.com/servo/html5ever) through [kuch

## Benchmarking

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.
Run `tox -e py`.

## Example benchmark results

Expand Down
File renamed without changes.
22 changes: 5 additions & 17 deletions html-py-ever/setup.py → examples/html-py-ever/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@
import sys

from setuptools import setup

try:
from setuptools_rust import RustExtension
except ImportError:
import subprocess

errno = subprocess.call([sys.executable, "-m", "pip", "install", "setuptools-rust"])
if errno:
print("Please install setuptools-rust package")
raise SystemExit(errno)
else:
from setuptools_rust import RustExtension

setup_requires = ["setuptools-rust>=0.10.1", "wheel"]
install_requires = []
from setuptools_rust import RustExtension

setup(
name="html-py-ever",
Expand All @@ -31,9 +17,11 @@
"Operating System :: MacOS :: MacOS X",
],
packages=["html_py_ever"],
install_requires=[
"beautifulsoup4",
"lxml"
],
rust_extensions=[RustExtension("html_py_ever.html_py_ever")],
install_requires=install_requires,
setup_requires=setup_requires,
include_package_data=True,
zip_safe=False,
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/usr/bin/env python
from glob import glob
import os

import html_py_ever
import pytest
from bs4 import BeautifulSoup
from html_py_ever import Document


HTML_FILES = glob(os.path.join(os.path.dirname(__file__), "*.html"))


def rust(filename: str) -> Document:
return html_py_ever.parse_file(filename)

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


@pytest.mark.parametrize("filename", list(glob("*.html")))
@pytest.mark.parametrize("filename", HTML_FILES)
def test_bench_parsing_rust(benchmark, filename):
benchmark(rust, filename)


@pytest.mark.parametrize("filename", list(glob("*.html")))
@pytest.mark.parametrize("filename", HTML_FILES)
def test_bench_parsing_python(benchmark, filename):
benchmark(python, filename)
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/usr/bin/env python
from glob import glob
import os

import html_py_ever
import pytest
from bs4 import BeautifulSoup


@pytest.mark.parametrize("filename", list(glob("*.html")))
HTML_FILES = glob(os.path.join(os.path.dirname(__file__), "*.html"))


@pytest.mark.parametrize("filename", HTML_FILES)
def test_bench_selector_rust(benchmark, filename):
document = html_py_ever.parse_file(filename)
benchmark(document.select, "a[href]")


@pytest.mark.parametrize("filename", list(glob("*.html")))
@pytest.mark.parametrize("filename", HTML_FILES)
def test_bench_selector_python(benchmark, filename):
with open(filename, encoding='utf8') as fp:
soup = BeautifulSoup(fp, "html.parser")
Expand Down
11 changes: 11 additions & 0 deletions examples/html-py-ever/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tox]
requires =
setuptools-rust @ file://{toxinidir}/../../

[testenv]
description = Run the unit tests under {basepython}
deps =
setuptools-rust @ file://{toxinidir}/../../
pytest-benchmark[historgram]
pytest>=3.6
commands = pytest {posargs}
2 changes: 1 addition & 1 deletion examples/namespace_package/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "namespace_package_bar"
name = "namespace_package_rust"
version = "0.1.0"
edition = "2018"

Expand Down
2 changes: 2 additions & 0 deletions examples/namespace_package/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include Cargo.toml
recursive-include src *
2 changes: 0 additions & 2 deletions examples/namespace_package/pyproject.toml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/namespace_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
version="0.1.0",
packages=find_namespace_packages(include=['namespace_package.*']),
zip_safe=False,
rust_extensions=[RustExtension("namespace_package.bar", path="Cargo.toml", binding=Binding.PyO3, debug=False)],
rust_extensions=[RustExtension("namespace_package.rust", path="Cargo.toml", binding=Binding.PyO3, debug=False)],
)
10 changes: 10 additions & 0 deletions examples/namespace_package/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
requires =
setuptools-rust @ file://{toxinidir}/../../

[testenv]
description = Run the unit tests under {basepython}
deps =
setuptools-rust @ file://{toxinidir}/../../
pytest
commands = pytest {posargs}
3 changes: 3 additions & 0 deletions examples/rust_with_cffi/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include Cargo.toml
include cffi_module.py
recursive-include src *
2 changes: 0 additions & 2 deletions examples/rust_with_cffi/pyproject.toml

This file was deleted.

1 change: 0 additions & 1 deletion examples/rust_with_cffi/requirements-dev.txt

This file was deleted.

8 changes: 2 additions & 6 deletions examples/rust_with_cffi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
import sys

from setuptools import setup

from setuptools_rust import RustExtension

setup_requires = ["setuptools-rust>=0.10.1", "wheel", "cffi"]
install_requires = ["cffi"]

setup(
name="rust-with-cffi",
version="0.1.0",
Expand All @@ -30,8 +26,8 @@
),
],
cffi_modules=["cffi_module.py:ffi"],
install_requires=install_requires,
setup_requires=setup_requires,
install_requires=["cffi"],
setup_requires=["cffi"],
include_package_data=True,
zip_safe=False,
)
11 changes: 11 additions & 0 deletions examples/rust_with_cffi/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tox]
requires =
setuptools-rust @ file://{toxinidir}/../../

[testenv]
description = Run the unit tests under {basepython}
deps =
setuptools-rust @ file://{toxinidir}/../../
pytest
cffi
commands = pytest {posargs}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions examples/tomlgen/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tox]
skipsdist=true

[testenv]
description = Run the unit tests under {basepython}
deps =
setuptools-rust @ file://{toxinidir}/../../
commands = python setup.py tomlgen_rust -w build
2 changes: 0 additions & 2 deletions html-py-ever/pyproject.toml

This file was deleted.

7 changes: 0 additions & 7 deletions html-py-ever/requirements-dev.txt

This file was deleted.

4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
from setuptools import setup

if __name__ == "__main__":
setup()
setup(
python_requires='>=3.5'
)
7 changes: 5 additions & 2 deletions setuptools_rust/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import json
import os
import shutil
import platform
import sys
import subprocess
from distutils.cmd import Command
Expand Down Expand Up @@ -96,8 +95,12 @@ def build_extension(self, ext):
# TODO: include --target for all platforms so env vars can't break the build
target_triple = None
target_args = []
if platform.machine() == "AMD64" and self.plat_name == "win32":
if self.plat_name == "win32":
target_triple = "i686-pc-windows-msvc"
elif self.plat_name == "win-amd64":
target_triple = "x86_64-pc-windows-msvc"

if target_triple is not None:
target_args = ["--target", target_triple]

# Find where to put the temporary build files created by `cargo`
Expand Down