diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e888850e..1beb8ae6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,15 +26,19 @@ jobs: command: fmt args: -- --check - - name: Lint with clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-targets --all-features -- -D clippy::all + # Disabled because of https://github.com/rust-lang/rust-clippy/issues/8971 + # - name: Lint with clippy + # uses: actions-rs/cargo@v1 + # with: + # command: clippy + # args: --all-targets --all-features -- -D clippy::all - name: Lint with Black run: pip install black && black --check . + - name: Lint with mypy + run: pip install mypy && mypy --non-interactive --install-types --ignore-missing-imports . + macos: runs-on: macos-latest needs: lint @@ -43,7 +47,7 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.7 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -68,7 +72,7 @@ jobs: PYO3_CROSS_LIB_DIR: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib run: | # Build wheels - maturin build -i python --release --universal2 --out dist --no-sdist + maturin build -i python --release --universal2 --out dist pip install adblock --no-index --find-links dist --force-reinstall - name: Run PyTest @@ -101,7 +105,7 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.7 architecture: ${{ matrix.platform.python-architecture }} - name: Install Rust toolchain @@ -117,7 +121,7 @@ jobs: - name: Build wheels run: | - maturin build -i python --release --out dist --no-sdist --target ${{ matrix.platform.target }} + maturin build -i python --release --out dist --target ${{ matrix.platform.target }} pip install adblock --no-index --find-links dist --force-reinstall - name: Run PyTest @@ -143,25 +147,25 @@ jobs: platform: [ { - toolchain: "1.49", + toolchain: "1.53", manylinux: "2010", target: "x86_64-unknown-linux-gnu", arch: "x86_64", - python-version: "3.6" + python-version: "3.7" }, { toolchain: "nightly", manylinux: "2010", target: "x86_64-unknown-linux-gnu", arch: "x86_64", - python-version: "3.6" + python-version: "3.7" }, { toolchain: "stable", manylinux: "2010", target: "x86_64-unknown-linux-gnu", arch: "x86_64", - python-version: "3.6" + python-version: "3.7" }, { toolchain: "stable", @@ -169,7 +173,7 @@ jobs: target: "x86_64-unknown-linux-gnu", arch: "x86_64", python-version: "3.10" - }, + } ] steps: - uses: actions/checkout@v2 @@ -184,7 +188,7 @@ jobs: source ~/.cargo/env export PATH=/opt/python/cp38-cp38/bin:$PATH pip install maturin - maturin build -i python --release --out dist --no-sdist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} + maturin build -i python --release --out dist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} ' > build-wheel.sh chmod +x build-wheel.sh docker run --rm -v "$PWD":/io -w /io quay.io/pypa/manylinux${{ matrix.platform.manylinux }}_${{ matrix.platform.arch }} bash build-wheel.sh @@ -234,23 +238,23 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.7 - name: Build Wheels run: | echo 'curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable source ~/.cargo/env rustup target add ${{ matrix.platform.target }} - maturin build -i python --release --out dist --no-sdist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} + maturin build -i python --release --out dist --target ${{ matrix.platform.target }} --manylinux ${{ matrix.platform.manylinux }} ' > build-wheel.sh chmod +x build-wheel.sh docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheel.sh - - uses: uraimo/run-on-arch-action@v2.0.5 + - uses: uraimo/run-on-arch-action@v2.2.0 name: Install built wheel with: arch: ${{ matrix.platform.arch }} - distro: ubuntu18.04 + distro: ubuntu22.04 # Mount the dist directory as /artifacts in the container dockerRunArgs: | --volume "${PWD}/dist:/artifacts" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bd65e413..8c596f185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch ## Unreleased --- +### Changes +* Update PyO3 dependency to `0.16`. +* Update upstream dependency to `0.5.6`. + +### Breaks +* Minimum Rust version is now `1.53`. +* Minimum Python version is now `3.7`. + ## 0.5.2 - (2022-03-01) --- diff --git a/Cargo.lock b/Cargo.lock index 28c063d7b..cc2596af9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,17 @@ version = 3 [[package]] name = "adblock" -version = "0.4.3" +version = "0.5.2" +dependencies = [ + "adblock 0.5.6", + "pyo3", +] + +[[package]] +name = "adblock" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52bdd00675903fd86d5d3109bb7899387c85cab52f990d14481546cb9a7102bf" +checksum = "27785ef5b89bc88fd2def3e1ecfefdf5ec1583795b916667afd15b13058f8315" dependencies = [ "addr", "base64", @@ -25,14 +33,6 @@ dependencies = [ "url", ] -[[package]] -name = "adblock" -version = "0.5.2" -dependencies = [ - "adblock 0.4.3", - "pyo3", -] - [[package]] name = "addr" version = "0.14.0" @@ -99,19 +99,17 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" [[package]] name = "flate2" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ - "cfg-if", "crc32fast", - "libc", "miniz_oxide", ] @@ -138,35 +136,9 @@ dependencies = [ [[package]] name = "indoc" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" -dependencies = [ - "indoc-impl", - "proc-macro-hack", -] - -[[package]] -name = "indoc-impl" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", - "unindent", -] - -[[package]] -name = "instant" -version = "0.1.12" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] +checksum = "05a0bd019339e5d968b37855180087b7b9d512c5046fbd244cf8c95687927d6e" [[package]] name = "itertools" @@ -179,16 +151,17 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.118" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ + "autocfg", "scopeguard", ] @@ -200,78 +173,62 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" dependencies = [ "adler", - "autocfg", ] [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if", - "instant", "libc", "redox_syscall", "smallvec", - "winapi", + "windows-sys", ] [[package]] name = "paste" -version = "0.1.18" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" [[package]] name = "percent-encoding" @@ -279,26 +236,20 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "psl" -version = "2.0.71" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f51974f40b58fd94008d3c88fa47cf1c7a58bd4e85deb0d4390bc156b0a9625" +checksum = "7e9c7d362659b525758d09e2a3ae965e371b347605e5fb2bc5bec5c2a1ecf41b" dependencies = [ "psl-types", ] @@ -311,35 +262,47 @@ checksum = "e8eda7c62d9ecaafdf8b62374c006de0adf61666ae96a96ba74a37134aa4e470" [[package]] name = "pyo3" -version = "0.15.2" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41d50a7271e08c7c8a54cd24af5d62f73ee3a6f6a314215281ebdec421d5752" +checksum = "1e6302e85060011447471887705bb7838f14aba43fcb06957d823739a496b3dc" dependencies = [ "cfg-if", "indoc", "libc", "parking_lot", - "paste", "pyo3-build-config", + "pyo3-ffi", "pyo3-macros", "unindent", ] [[package]] name = "pyo3-build-config" -version = "0.15.2" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "779239fc40b8e18bc8416d3a37d280ca9b9fb04bda54b98037bb6748595c2410" +checksum = "b5b65b546c35d8a3b1b2f0ddbac7c6a569d759f357f2b9df884f5d6b719152c8" dependencies = [ "once_cell", + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c275a07127c1aca33031a563e384ffdd485aee34ef131116fcd58e3430d1742b" +dependencies = [ + "libc", + "pyo3-build-config", ] [[package]] name = "pyo3-macros" -version = "0.15.2" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b247e8c664be87998d8628e86f282c25066165f1f8dda66100c48202fdb93a" +checksum = "284fc4485bfbcc9850a6d661d627783f18d19c2ab55880b021671c4ba83e90f7" dependencies = [ + "proc-macro2", "pyo3-macros-backend", "quote", "syn", @@ -347,39 +310,38 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.15.2" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a8c2812c412e00e641d99eeb79dd478317d981d938aa60325dfa7157b607095" +checksum = "53bda0f58f73f5c5429693c96ed57f7abdb38fdfc28ae06da4101a257adb7faf" dependencies = [ "proc-macro2", - "pyo3-build-config", "quote", "syn", ] [[package]] name = "quote" -version = "1.0.15" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.5.4" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -388,18 +350,19 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "rmp" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f55e5fa1446c4d5dd1f5daeed2a4fe193071771a2636274d0d7a3b082aa7ad6" +checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" dependencies = [ "byteorder", "num-traits", + "paste", ] [[package]] @@ -438,18 +401,18 @@ checksum = "58f57ca1d128a43733fd71d583e837b1f22239a37ebea09cde11d8d9a9080f47" [[package]] name = "serde" -version = "1.0.136" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.136" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb" dependencies = [ "proc-macro2", "quote", @@ -458,26 +421,32 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "syn" -version = "1.0.86" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] +[[package]] +name = "target-lexicon" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" + [[package]] name = "tinyvec" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] @@ -506,30 +475,30 @@ checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" [[package]] name = "unicode-bidi" -version = "0.3.7" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - [[package]] name = "unindent" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" +checksum = "52fee519a3e570f7df377a06a1a7775cdbfb7aa460be7e08de2b1f0e69973a44" [[package]] name = "url" @@ -544,23 +513,44 @@ dependencies = [ ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-sys" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_x86_64_msvc" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" diff --git a/Cargo.toml b/Cargo.toml index 73d41e8bc..bf51c19de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ requires-python = ">=3.6" debug = true [dependencies] -adblock = { version = "=0.4.3", default-features = false, features = ["full-regex-handling", "embedded-domain-resolver"] } -pyo3 = { version = "0.15", features = ["abi3-py36", "extension-module"] } +adblock = { version = "=0.5.6", default-features = false, features = ["full-regex-handling", "embedded-domain-resolver"] } +pyo3 = { version = "0.16", features = ["abi3-py37", "extension-module"] } [lib] name = "adblock" diff --git a/README.md b/README.md index 24be8037d..ee9343195 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Python wrapper for Brave's adblocking library, which is written in Rust. | Build Dependency | Versions | Arch Linux | Url | | ---------------- | -------- | ---------- | ------------------------------- | -| Python | `>=3.6` | `python` | - | -| Rust | `>=1.49` | `rust` | - | +| Python | `>=3.7` | `python` | - | +| Rust | `>=1.53` | `rust` | - | | Maturin | `>=0.10` | `maturin` | https://github.com/PyO3/maturin | #### PEP 517 diff --git a/adblock/adblock.pyi b/adblock/adblock.pyi index 9fae1dab3..544a30d11 100644 --- a/adblock/adblock.pyi +++ b/adblock/adblock.pyi @@ -1,5 +1,7 @@ from typing import Optional, Dict, List, Set +__version__: str + class AdblockException(Exception): pass @@ -58,6 +60,7 @@ class FilterSet: filter_list: str, format: str = "standard", include_redirect_urls: bool = False, + rule_types: str = "all", ) -> None: pass def add_filters( @@ -65,6 +68,7 @@ class FilterSet: filters: List[str], format: str = "standard", include_redirect_urls: bool = False, + rule_types: str = "all", ) -> None: pass diff --git a/src/lib.rs b/src/lib.rs index 9117254dc..2d6029344 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,8 +16,7 @@ use adblock::blocker::{BlockerError as RustBlockerError, Redirection}; use adblock::cosmetic_filter_cache::UrlSpecificResources as RustUrlSpecificResources; use adblock::engine::Engine as RustEngine; use adblock::lists::FilterSet as RustFilterSet; -use adblock::lists::{FilterFormat, ParseOptions}; -use pyo3::class::PyObjectProtocol; +use adblock::lists::{FilterFormat, ParseOptions, RuleTypes}; use pyo3::create_exception; use pyo3::exceptions::PyException; use pyo3::prelude::*; @@ -145,8 +144,8 @@ impl From for BlockerResult { } } -#[pyproto] -impl PyObjectProtocol for BlockerResult { +#[pymethods] +impl BlockerResult { fn __repr__(&self) -> PyResult { Ok(format!( "BlockerResult(matched={}, important={}, redirect={}, exception={}, filter={}, error={})", @@ -231,7 +230,18 @@ fn filter_format_from_string(filter_format: &str) -> PyResult { match filter_format { "standard" => Ok(FilterFormat::Standard), "hosts" => Ok(FilterFormat::Hosts), - _ => Err(PyErr::new::("Invalid format value")), + _ => Err(PyErr::new::( + "Invalid FilterFormat value", + )), + } +} + +fn rule_types_from_string(rule_types: &str) -> PyResult { + match rule_types { + "all" => Ok(RuleTypes::All), + "networkonly" => Ok(RuleTypes::NetworkOnly), + "cosmeticonly" => Ok(RuleTypes::CosmeticOnly), + _ => Err(PyErr::new::("Invalid RuleTypes value")), } } @@ -269,20 +279,28 @@ impl FilterSet { /// /// The format is a string containing either "standard" (ABP/uBO-style) /// or "hosts". - #[pyo3(text_signature = "($self, filter_list, format, include_redirect_urls)")] - #[args(filter_list, format = "\"standard\"", include_redirect_urls = "false")] + #[pyo3(text_signature = "($self, filter_list, format, include_redirect_urls, rule_types)")] + #[args( + filter_list, + format = "\"standard\"", + include_redirect_urls = "false", + rule_types = "\"all\"" + )] pub fn add_filter_list( &mut self, filter_list: &str, format: &str, include_redirect_urls: bool, + rule_types: &str, ) -> PyResult<()> { let filter_format = filter_format_from_string(format)?; + let rule_types = rule_types_from_string(rule_types)?; self.filter_set.add_filter_list( filter_list, ParseOptions { format: filter_format, include_redirect_urls, + rule_types, }, ); Ok(()) @@ -293,28 +311,33 @@ impl FilterSet { /// /// The format is a string containing either "standard" (ABP/uBO-style) /// or "hosts". - #[pyo3(text_signature = "($self, filters, format, include_redirect_urls)")] - #[args(filters, format = "\"standard\"", include_redirect_urls = "false")] + #[pyo3(text_signature = "($self, filters, format, include_redirect_urls, rule_types)")] + #[args( + filters, + format = "\"standard\"", + include_redirect_urls = "false", + rule_types = "\"all\"" + )] pub fn add_filters( &mut self, filters: Vec, format: &str, include_redirect_urls: bool, + rule_types: &str, ) -> PyResult<()> { let filter_format = filter_format_from_string(format)?; + let rule_types = rule_types_from_string(rule_types)?; self.filter_set.add_filters( &filters, ParseOptions { format: filter_format, include_redirect_urls, + rule_types, }, ); Ok(()) } -} -#[pyproto] -impl PyObjectProtocol for FilterSet { fn __repr__(&self) -> PyResult { Ok(format!("FilterSet(debug={})", self.debug.diy_python_repr())) } @@ -361,8 +384,8 @@ impl From for UrlSpecificResources { } } -#[pyproto] -impl PyObjectProtocol for UrlSpecificResources { +#[pymethods] +impl UrlSpecificResources { fn __repr__(&self) -> PyResult { Ok(format!( "UrlSpecificResources<{} hide selectors, {} style selectors, {} exceptions, injected_javascript={}, generichide={}>", @@ -662,10 +685,7 @@ impl Engine { .engine .hidden_class_id_selectors(&classes, &ids, &exceptions)) } -} -#[pyproto] -impl PyObjectProtocol for Engine { fn __repr__(&self) -> PyResult { Ok(format!( "Engine", diff --git a/tests/test_redirect.py b/tests/test_redirect.py index cca3a9160..7782df870 100644 --- a/tests/test_redirect.py +++ b/tests/test_redirect.py @@ -35,11 +35,11 @@ def test_redirect_url_is_not_recognized_without_include_redirect_urls(): def test_redirect_url_exception(): # https://github.com/brave/adblock-rust/blob/b7f29af8c0a0d000201d8d769b6a0b25a9dd4e89/src/blocker.rs#L1314 filter_set = adblock.FilterSet(debug=True) - filter_set.add_filter_list( - """ - ||imdb-video.media-imdb.com$media,redirect-url=http://xyz.com - @@||imdb-video.media-imdb.com^$domain=imdb.com - """, + filter_set.add_filters( + [ + "||imdb-video.media-imdb.com$media,redirect-url=http://xyz.com", + "@@||imdb-video.media-imdb.com^$domain=imdb.com", + ], include_redirect_urls=True, ) @@ -50,10 +50,11 @@ def test_redirect_url_exception(): "https://www.imdb.com/video/13", "media", ) + assert res.error is None assert res.matched is False assert res.redirect == "http://xyz.com" assert res.redirect_type == "url" - assert res.exception == "@@||imdb-video.media-imdb.com^$domain=imdb.com" + assert res.exception is None def test_redirect_with_custom_resource():