diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7f00acd..08824ed 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,4 +1,4 @@ -# This file is autogenerated by maturin v1.5.1 +# This file is autogenerated by maturin v1.7.0 # To update, run # # maturin generate-ci github -o .github/workflows/CI.yml --pytest --zig @@ -29,18 +29,16 @@ jobs: target: x86_64 - runner: ubuntu-latest target: aarch64 - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9', 'pypy3.10'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: 3.x - name: Build wheels uses: PyO3/maturin-action@v1 with: - rust-toolchain: stable target: ${{ matrix.platform.target }} - args: --release --out dist --zig -i ${{ matrix.python-version }} + args: --release --out dist --zig sccache: 'true' manylinux: auto env: @@ -48,18 +46,23 @@ jobs: - name: Upload wheels uses: actions/upload-artifact@v4 with: - name: wheels-linux-${{ matrix.platform.target }}-${{ matrix.python-version }} + name: wheels-linux-${{ matrix.platform.target }} path: dist - name: pytest if: ${{ startsWith(matrix.platform.target, 'x86_64') }} shell: bash run: | set -e - pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall - pip install pytest - pytest + pip install uv + for version in 3.8 3.9 3.10 3.11 3.12; do + uv venv --preview --python $version + source .venv/bin/activate + uv pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall + uv pip install pytest + pytest + done - name: pytest - if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' && !startsWith(matrix.python-version, 'pypy')}} + if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }} uses: uraimo/run-on-arch-action@v2 with: arch: ${{ matrix.platform.target }} @@ -67,15 +70,17 @@ jobs: githubToken: ${{ github.token }} install: | apt-get update - apt-get install -y --no-install-recommends software-properties-common gpg gpg-agent curl - add-apt-repository ppa:deadsnakes/ppa - apt-get update - apt-get install -y python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv + apt-get install -y --no-install-recommends python3 python3-pip run: | - python${{ matrix.python-version }} -m venv venv - venv/bin/pip install -U pip wheel pytest - venv/bin/pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall - venv/bin/python -m pytest + set -e + pip install uv + for version in 3.8 3.9 3.10 3.11 3.12; do + uv venv --preview --python $version + source .venv/bin/activate + uv pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall + uv pip install pytest + pytest + done musllinux: runs-on: ${{ matrix.platform.runner }} @@ -87,39 +92,39 @@ jobs: target: x86_64 - runner: ubuntu-latest target: aarch64 - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9', 'pypy3.10'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: 3.x - name: Build wheels uses: PyO3/maturin-action@v1 with: - rust-toolchain: stable target: ${{ matrix.platform.target }} - args: --release --out dist --zig -i ${{ matrix.python-version }} + args: --release --out dist --zig sccache: 'true' manylinux: musllinux_1_2 - name: Upload wheels uses: actions/upload-artifact@v4 with: - name: wheels-musllinux-${{ matrix.platform.target }}-${{ matrix.python-version }} + name: wheels-musllinux-${{ matrix.platform.target }} path: dist - name: QEMU if: matrix.platform.target != 'x86_64' uses: docker/setup-qemu-action@v3 - name: pytest - if: ${{ !startsWith(matrix.python-version, 'pypy')}} uses: addnab/docker-run-action@v3 with: image: quay.io/pypa/musllinux_1_2_${{ matrix.platform.target }}:latest options: -v ${{ github.workspace }}:/io -w /io run: | - python${{ matrix.python-version }} -m venv venv - venv/bin/pip install -U pip wheel pytest - venv/bin/pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall - venv/bin/python -m pytest + for version in 3.8 3.9 3.10 3.11 3.12; do + python$version -m venv .venv + source .venv/bin/activate + pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall + pip install pytest + pytest + done windows: runs-on: ${{ matrix.platform.runner }} @@ -129,35 +134,38 @@ jobs: platform: - runner: windows-latest target: x64 - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: 3.x architecture: ${{ matrix.platform.target }} - name: Install nasm run: choco install nasm - name: Build wheels uses: PyO3/maturin-action@v1 with: - rust-toolchain: stable target: ${{ matrix.platform.target }} - args: --release --out dist -i ${{ matrix.python-version }} + args: --release --out dist sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 with: - name: wheels-windows-${{ matrix.platform.target }}-${{ matrix.python-version }} + name: wheels-windows-${{ matrix.platform.target }} path: dist - name: pytest if: ${{ !startsWith(matrix.platform.target, 'aarch64') }} shell: bash run: | set -e - pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall - pip install pytest - pytest + pip install uv + for version in 3.8 3.9 3.10 3.11 3.12; do + uv venv --preview --python $version + source .venv/Scripts/activate + uv pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall + uv pip install pytest + pytest + done macos: runs-on: ${{ matrix.platform.runner }} @@ -169,31 +177,33 @@ jobs: target: x86_64 - runner: macos-14 target: aarch64 - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: 3.x - name: Build wheels uses: PyO3/maturin-action@v1 with: - rust-toolchain: stable target: ${{ matrix.platform.target }} - args: --release --out dist -i ${{ matrix.python-version }} + args: --release --out dist sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 with: - name: wheels-macos-${{ matrix.platform.target }}-${{ matrix.python-version }} + name: wheels-macos-${{ matrix.platform.target }} path: dist - name: pytest - shell: bash run: | set -e - pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall - pip install pytest - pytest + pip install uv + for version in 3.8 3.9 3.10 3.11 3.12; do + uv venv --preview --python $version + source .venv/bin/activate + uv pip install pyreqwest_impersonate --no-index --find-links dist --force-reinstall + uv pip install pytest + pytest + done sdist: runs-on: ubuntu-latest @@ -229,44 +239,39 @@ jobs: permissions: contents: write runs-on: ubuntu-latest - if: "startsWith(github.ref, 'refs/tags/')" - needs: [release] + needs: [linux] steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.12' + python-version: 3.x + - name: Download wheels + uses: actions/download-artifact@v4 + with: + name: wheels-linux-x86_64 - name: Install dependencies run: | - sleep 30 # Wait for the package to be available on PyPI - python -m pip install --upgrade pip pip install -r benchmark/requirements.txt + pip install pyreqwest_impersonate --no-index --find-links ./ --force-reinstall - name: Start Uvicorn server run: | uvicorn benchmark.server:app --host 0.0.0.0 --port 8000 & sleep 10 - name: Run benchmark run: python benchmark/benchmark.py - - name: Generate image and commit to the new branch + - name: Generate image, commit to the temp branch, merge changes into main, delete temp branch + if: "startsWith(github.ref, 'refs/tags/')" run: | python benchmark/generate_image.py git config --global user.name 'GitHub Actions' git config --global user.email 'actions@github.com' git add \*.jpg git diff --quiet && git diff --staged --quiet || git commit -m "Update generated image" - # Create a new branch and switch to it git checkout -b update-generated-image - # Attempt to push changes to the new branch git push https://${{ secrets.PUSH_TOKEN }}@github.com/deedy5/pyreqwest_impersonate.git update-generated-image || echo "No changes to push" - - name: Merge changes into main and delete temporary branch - run: | - # Fetch the latest changes from the remote repository git fetch origin - # Merge the temporary branch into main git checkout main git merge update-generated-image - # Push the changes to the main branch git push https://${{ secrets.PUSH_TOKEN }}@github.com/deedy5/pyreqwest_impersonate.git main - # Delete the temporary branch git push origin --delete update-generated-image diff --git a/Cargo.toml b/Cargo.toml index c3a2430..ceba63a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ name = "pyreqwest_impersonate" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.22", features = ["extension-module", "indexmap"] } +pyo3 = { version = "0.22", features = ["extension-module", "abi3-py38", "indexmap"] } reqwest-impersonate = { version = "0.11", default-features = false, features = [ "cookies", "boring-tls",