Skip to content

Commit

Permalink
Merge branch 'online-ml:main' into rls_branch
Browse files Browse the repository at this point in the history
  • Loading branch information
slach31 authored Nov 26, 2024
2 parents 0953c5e + 0390346 commit 8752ab4
Show file tree
Hide file tree
Showing 39 changed files with 2,485 additions and 2,262 deletions.
11 changes: 6 additions & 5 deletions .github/actions/install-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ runs:
with:
python-version: ${{ inputs.python-version }}

- name: Load cached Poetry installation
uses: actions/cache@v4
with:
path: ~/.local # the path depends on the OS
key: poetry-2 # increment to reset cache
# Getting errors since using not the latest Python version in docs workflows
# - name: Load cached Poetry installation
# uses: actions/cache@v4
# with:
# path: ~/.local # the path depends on the OS
# key: poetry-3 # modify to reset cache

- name: Install poetry
uses: snok/install-poetry@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build River
uses: ./.github/actions/install-env
with:
python-version: "3.12"
python-version: "3.13"
build-root: false

- name: Run pre-commit on all files
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/dev-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build River
uses: ./.github/actions/install-env
with:
# Use 3.12 for the docs env waiting for spaCy and srsly to support 3.13
python-version: "3.12"
build-root: false

Expand Down
160 changes: 92 additions & 68 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,127 +7,151 @@ on:
- "*"

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
build_linux_wheels:
name: Build ${{ matrix.linux_tag }} wheels with cp${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
# https://github.com/actions/runner-images/tree/main
matrix:
os:
[
ubuntu-20.04,
ubuntu-22.04,
windows-2019,
windows-2022,
macos-12,
macos-13,
macos-14,
]

linux_tag: ["manylinux", "musllinux"]
python-version: ["310", "311", "312", "313"]
steps:
- uses: actions/checkout@v3

- name: Set up rust
if: matrix.os != 'ubuntu-20.04' && matrix.os != 'ubuntu-22.04'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- run: rustup target add aarch64-apple-darwin && rustup target add x86_64-apple-darwin
if: matrix.os == 'macos-12' || matrix.os == 'macos-13' || matrix.os == 'macos-14'

- run: rustup toolchain install stable-i686-pc-windows-msvc
if: matrix.os == 'windows-2019' || matrix.os == 'windows-2022'

- run: rustup target add i686-pc-windows-msvc
if: matrix.os == 'windows-2019' || matrix.os == 'windows-2022'

- uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
uses: pypa/cibuildwheel@v2.22.0
timeout-minutes: 720
env:
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*"
CIBW_BUILD: "cp${{ matrix.python-version }}-${{ matrix.linux_tag }}_*"
CIBW_ARCHS_LINUX: "x86_64 i686 aarch64"
# CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_MACOS: "universal2"
# We don't build ARM64 wheels yet because there's a Rust issue
CIBW_ARCHS_WINDOWS: "AMD64 x86"
# Rust nighlty doesn't seem to be available for musl linux on i686
CIBW_SKIP: "*-musllinux_i686"

# arm64 and universal2 wheels are tagged with x86_64 because there's an issue with Poetry
# More information here: https://cibuildwheel.readthedocs.io/en/stable/faq/#how-to-cross-compile (CTRL + F "poetry")
# https://github.com/pypa/cibuildwheel/issues/1415
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
ls {dest_dir} &&
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
for file in {dest_dir}/*.whl ; do mv $file ${file//x86_64/universal2} ; done
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
CIBW_MANYLINUX_I686_IMAGE: "manylinux2014"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux2014"
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: "manylinux2014"
CIBW_MANYLINUX_PYPY_I686_IMAGE: "manylinux2014"
CIBW_MANYLINUX_PYPY_AARCH64_IMAGE: "manylinux2014"

CIBW_MUSLLINUX_X86_64_IMAGE: "musllinux_1_1"
CIBW_MUSLLINUX_I686_IMAGE: "musllinux_1_1"
CIBW_MUSLLINUX_AARCH64_IMAGE: "musllinux_1_1"

CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
# Fix the following error: error: cargo rustc --lib --message-format=json-render-diagnostics --manifest-path Cargo.toml --release -v --features pyo3/extension-module -- --crate-type cdylibfailed with code -9
# You need to set a second environment variable CARGO_NET_GIT_FETCH_WITH_CLI="true" for linux environments
# Solutio found here: https://github.com/rust-lang/cargo/issues/10583
CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_NET_GIT_FETCH_WITH_CLI="true"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'

CIBW_BEFORE_BUILD: >
rustup default nightly &&
rustup show
CIBW_BEFORE_BUILD_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y &&
rustup show
- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.linux_tag }}-cp${{ matrix.python-version }}
path: ./wheelhouse/*.whl

build_macos_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, macos-14]
steps:
- uses: actions/checkout@v4
- name: Set up rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: rustup target add aarch64-apple-darwin && rustup target add x86_64-apple-darwin
- name: Build wheels
uses: pypa/[email protected]
timeout-minutes: 720
env:
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*"
CIBW_ARCHS_MACOS: "universal2"
# arm64 and universal2 wheels are tagged with x86_64 because there's an issue with Poetry
# More information here: https://cibuildwheel.readthedocs.io/en/stable/faq/#how-to-cross-compile (CTRL + F "poetry")
# https://github.com/pypa/cibuildwheel/issues/1415
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
ls {dest_dir} &&
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
for file in {dest_dir}/*.whl ; do mv $file ${file//x86_64/universal2} ; done
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
CIBW_BEFORE_BUILD: >
rustup default nightly &&
rustup show
- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}
path: ./wheelhouse/*.whl

- uses: actions/upload-artifact@v2
build_windows_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019, windows-2022]
steps:
- uses: actions/checkout@v4
- name: Set up rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: rustup toolchain install stable-i686-pc-windows-msvc
- run: rustup target add i686-pc-windows-msvc
- name: Build wheels
uses: pypa/[email protected]
timeout-minutes: 720
env:
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*"
CIBW_ARCHS_WINDOWS: "AMD64 x86"
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_BEFORE_BUILD: >
rustup default nightly &&
rustup show
- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
# Can't use more than 12 jobs in parallel
needs: [build_macos_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build River
uses: ./.github/actions/install-env
with:
python-version: "3.12"
python-version: "3.13"

- name: Build dist
run: poetry build

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: artifact-sdist
path: dist/*.tar.gz

merge_artifacts:
runs-on: ubuntu-latest
needs: [build_linux_wheels, build_macos_wheels, build_windows_wheels, build_sdist]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: artifact
pattern: artifact-*

upload_pypi:
needs: [build_wheels, build_sdist]
needs: merge_artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.8.10
- uses: pypa/gh-action-pypi-publish@v1.12.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/release-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- name: Build River
uses: ./.github/actions/install-env
with:
# Use 3.12 for the docs env waiting for spaCy and srsly to support 3.13
python-version: "3.12"

- name: Install extra Ubuntu dependencies
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.12", "3.11", "3.10"]
python-version: ["3.13", "3.12", "3.11", "3.10"]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build River
uses: ./.github/actions/install-env
with:
python-version: "3.12"
python-version: ${{ matrix.python-version }}

- name: Cache River datasets
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/river_data
key: ${{ runner.os }}

- name: Cache scikit-learn datasets
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/scikit_learn_data
key: ${{ runner.os }}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ path = "rust_src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.18.3", features = ["extension-module"] }
pyo3 = { version = "0.23.1", features = ["extension-module"] }
watermill = "0.1.1"
bincode = "1.3.3"
serde = { version = "1.0", features = ["derive"] }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Of course, this is just a contrived example. We welcome you to check the [introd

## 🛠 Installation

River is intended to work with **Python 3.8 and above**. Installation can be done with `pip`:
River is intended to work with **Python 3.10 and above**. Installation can be done with `pip`:

```sh
pip install river
Expand Down
31 changes: 9 additions & 22 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
import platform
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError

import numpy
import setuptools
from Cython.Build import cythonize
from setuptools.command.build_ext import build_ext
from setuptools.errors import CCompilerError
from setuptools_rust import Binding, RustExtension

try:
from numpy import __version__ as numpy_version
from numpy import get_include
except ImportError:
subprocess.check_call([sys.executable, "-m", "pip", "install", "numpy"])
from numpy import __version__ as numpy_version
from numpy import get_include

try:
from Cython.Build import cythonize
except ImportError:
subprocess.check_call([sys.executable, "-m", "pip", "install", "Cython"])
from Cython.Build import cythonize # type: ignore


ext_modules = cythonize(
module_list=[
setuptools.Extension(
"*",
sources=["**/*.pyx"],
include_dirs=[get_include()],
sources=["river/**/*.pyx"],
include_dirs=[numpy.get_include()],
libraries=[] if platform.system() == "Windows" else ["m"],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
)
],
compiler_directives={
"language_level": 3,
"binding": True,
"embedsignature": True,
},
Expand All @@ -47,13 +34,13 @@ class ExtBuilder(build_ext):
def run(self):
try:
build_ext.run(self)
except (DistutilsPlatformError, FileNotFoundError):
except (FileNotFoundError):
raise BuildFailed("File not found. Could not compile C extension.")

def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
except (CCompilerError, ValueError):
raise BuildFailed("Could not compile C extension.")


Expand Down
Loading

0 comments on commit 8752ab4

Please sign in to comment.