diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b3428a4..b860032 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,112 +6,145 @@ on: workflow_dispatch: inputs: environment: - description: 'Environment to publish to' + description: "Environment to publish to" required: true - default: 'testpypi' + default: "testpypi" type: choice options: - - testpypi - - pypi + - testpypi + - pypi dry_run: - description: 'Dry run - only build, no publishing' + description: "Dry run - build only, skip publishing jobs" required: false default: false type: boolean jobs: build-wheels: - name: Build wheels for ${{ matrix.os }} + name: Build wheels (${{ matrix.name }}) runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - # Build for multiple macOS versions to support different platforms - # macos-13: Intel (macOS 13) - # macos-14: Apple Silicon (macOS 14) - # macos-15: Intel (macOS 15) - newer Intel Macs - os: [ubuntu-latest, ubuntu-24.04-arm, macos-13, macos-14, macos-15] + include: + - name: manylinux x86_64 + os: ubuntu-latest + cibw_archs: x86_64 + - name: manylinux aarch64 + os: ubuntu-24.04-arm + cibw_archs: aarch64 + - name: macOS Intel (15+ SDK) + os: macos-15-intel + cibw_archs: x86_64 + - name: macOS Apple Silicon (15+) + os: macos-15 + cibw_archs: arm64 steps: - - uses: actions/checkout@v5 - - name: Install Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v5 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" - - name: Build wheels - uses: pypa/cibuildwheel@v3.1.4 - env: - CIBW_BEFORE_ALL: | - echo "=== Installing OpenSSL dependencies ===" - if yum > /dev/null 2>&1; then - yum update -y - yum install -y openssl-devel - export RUSTFLAGS="-C target-feature=-crt-static" - export OPENSSL_DIR=/usr - export OPENSSL_LIB_DIR=/usr/lib64 - export OPENSSL_INCLUDE_DIR=/usr/include/openssl - export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig - fi - echo "=== Installing Rust ===" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable - source $HOME/.cargo/env - export PATH="$HOME/.cargo/bin:$PATH" - # Verify Rust installation - echo "=== Rust Installation Check ===" - cargo --version - rustc --version - with: - package-dir: . - output-dir: wheelhouse - config-file: "{package}/pyproject.toml" + - name: Build wheels + uses: pypa/cibuildwheel@v3.1.4 + env: + CIBW_ARCHS: ${{ matrix.cibw_archs }} + CIBW_BEFORE_ALL: | + echo "=== Installing Linux build dependencies (if needed) ===" + if command -v dnf >/dev/null 2>&1; then + dnf install -y openssl-devel pkgconf-pkg-config || dnf install -y openssl-devel pkgconfig + elif command -v yum >/dev/null 2>&1; then + yum install -y openssl-devel pkgconfig + elif command -v apt-get >/dev/null 2>&1; then + apt-get update + apt-get install -y libssl-dev pkg-config + fi - - uses: actions/upload-artifact@v4 - with: - name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} - path: ./wheelhouse/*.whl + if command -v pkg-config >/dev/null 2>&1 && pkg-config --exists openssl; then + export OPENSSL_DIR="$(pkg-config --variable=prefix openssl)" + export OPENSSL_LIB_DIR="$(pkg-config --variable=libdir openssl)" + export OPENSSL_INCLUDE_DIR="$(pkg-config --variable=includedir openssl)" + echo "Using OpenSSL from: ${OPENSSL_DIR}" + fi + + echo "=== Installing Rust toolchain ===" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable + source "$HOME/.cargo/env" + cargo --version + rustc --version + with: + package-dir: . + output-dir: wheelhouse + config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.cibw_archs }} + path: ./wheelhouse/*.whl + + build-sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Build sdist + run: | + python -m pip install --upgrade pip + python -m pip install maturin + maturin sdist --out dist + - uses: actions/upload-artifact@v4 + with: + name: sdist + path: ./dist/*.tar.gz publish-python: name: Publish Python Package runs-on: ubuntu-latest - needs: [build-wheels] + needs: [build-wheels, build-sdist] if: > - github.event_name == 'release' || + github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && (!github.event.inputs.dry_run || github.event.inputs.dry_run == 'false')) environment: ${{ github.event.inputs.environment || 'pypi' }} permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write steps: - - uses: actions/checkout@v5 - - name: Download all wheels - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: Collect wheels - run: | - mkdir -p dist - find artifacts -name "*.whl" -exec cp {} dist/ \; - find artifacts -name "*.tar.gz" -exec cp {} dist/ \; - ls -la dist/ - - - name: Publish to TestPyPI - if: github.event.inputs.environment == 'testpypi' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - - - name: Publish to PyPI - if: github.event_name == 'release' && github.event.action == 'published' - uses: pypa/gh-action-pypi-publish@release/v1 + - uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Collect packages + run: | + mkdir -p dist + find artifacts -name "*.whl" -exec cp {} dist/ \; + find artifacts -name "*.tar.gz" -exec cp {} dist/ \; + ls -la dist/ + + - name: Publish to TestPyPI + if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + - name: Publish to PyPI + if: github.event_name == 'release' && github.event.action == 'published' + uses: pypa/gh-action-pypi-publish@release/v1 publish-rust: name: Publish Rust Crate runs-on: ubuntu-latest if: > - github.event_name == 'release' || + github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && (!github.event.inputs.dry_run || github.event.inputs.dry_run == 'false')) steps: - - uses: actions/checkout@v5 - - name: Set up Rust - uses: dtolnay/rust-toolchain@stable - - name: Publish to crates.io - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: cargo publish + - uses: actions/checkout@v5 + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + - name: Publish to crates.io + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: cargo publish diff --git a/Cargo.toml b/Cargo.toml index ff8efbf..785807c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ thiserror = "1.0" # Web scraping and browser automation thirtyfour = "0.35" -reqwest = { version = "0.11", features = ["json", "stream", "blocking"] } +reqwest = { version = "0.11", default-features = false, features = ["json", "stream", "blocking", "rustls-tls"] } url = "2.5" urlencoding = "2.1" select = "0.6" diff --git a/pyproject.toml b/pyproject.toml index 0814178..153ed78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ requires = ["maturin>=1.0,<2.0"] build-backend = "maturin" [tool.maturin] -features = ["pyo3/extension-module"] +features = ["pyo3"] module-name = "tarzi" strip = true bindings = "pyo3" @@ -75,13 +75,11 @@ python-source = "python" skip = "*-musllinux_*" [tool.cibuildwheel.macos] -# Use a more recent deployment target for better compatibility -# while still maintaining reasonable backward compatibility -environment = { MACOSX_DEPLOYMENT_TARGET = "11.0" } +environment = { MACOSX_DEPLOYMENT_TARGET = "15.0" } -# Build universal2 wheels for macOS to support both Intel and Apple Silicon -[tool.cibuildwheel.macos.universal2] -archs = ["x86_64", "arm64"] +[tool.cibuildwheel.linux] +manylinux-x86_64-image = "manylinux_2_28" +manylinux-aarch64-image = "manylinux_2_28" [project.scripts] pytarzi = "tarzi.__main__:main"