Skip to content

Commit

Permalink
build(Rust): use 2024 edition (#333)
Browse files Browse the repository at this point in the history
* build(Rust): use 2024 edition

Signed-off-by: Luka Peschke <[email protected]>

* chore: make format

Signed-off-by: Luka Peschke <[email protected]>

* fix(ci): do not rely on deprecated actions-rs github action anymore

Signed-off-by: Luka Peschke <[email protected]>

* fix(ci): replace messense/maturin action with PyO3/maturin

Signed-off-by: Luka Peschke <[email protected]>

* build: specify rust-version in Cargo.toml

Signed-off-by: Luka Peschke <[email protected]>

* fix(ci): setup rust toolchain in check-x-build steps as well

Signed-off-by: Luka Peschke <[email protected]>

* fix(ci/release): make sure the latest rust toolchain is used

Signed-off-by: Luka Peschke <[email protected]>

---------

Signed-off-by: Luka Peschke <[email protected]>
  • Loading branch information
lukapeschke authored Feb 25, 2025
1 parent 24f31f9 commit a1a9f76
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 57 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ jobs:
with:
python-version: "${{ env.MIN_PYTHON_VERSION }}"
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable
- name: Set up rustfmt
run: rustup component add rustfmt

Expand All @@ -55,11 +51,7 @@ jobs:
with:
python-version: "3.11"
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable
- run: |
git config user.name github-actions
git config user.email [email protected]
Expand Down Expand Up @@ -88,11 +80,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

# Maturin requires a venv to be activated, that's why we have to create one here
- name: Create virtualenv
Expand Down Expand Up @@ -124,6 +112,7 @@ jobs:
architecture: aarch64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Set Rust target
id: target
if: matrix.os != 'windows-latest'
Expand All @@ -132,7 +121,7 @@ jobs:
echo "target=$TARGET" >> $GITHUB_OUTPUT
- name: build (fast)
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: build
Expand All @@ -149,8 +138,9 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: build sdist
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: sdist
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ jobs:
with:
python-version: "3.11"
- name: Set up rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable
- run: |
git config user.name github-actions
git config user.email [email protected]
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
architecture: [x86-64, aarch64]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: build (release)
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: build
Expand All @@ -36,8 +37,9 @@ jobs:
architecture: [x86-64, aarch64]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: build (release)
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
command: build
args: "--release -o dist"
Expand All @@ -56,8 +58,9 @@ jobs:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: build (release)
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
command: build
args: "--release -o dist"
Expand All @@ -71,8 +74,9 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: build (sdist)
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: sdist
Expand All @@ -90,6 +94,7 @@ jobs:
runs-on: ubuntu-latest
needs: [linux, macos, windows, sdist]
steps:
- uses: dtolnay/rust-toolchain@stable
- name: Download Linux 3.9 wheels for x86-64
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -128,7 +133,7 @@ jobs:


- name: Publish to PyPI
uses: messense/maturin-action@v1
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "fastexcel"
version = "0.13.0"
edition = "2021"
rust-version = "1.85.0"
edition = "2024"
license = "MIT"
homepage = "https://github.com/ToucanToco/fastexcel"
repository = "https://github.com/ToucanToco/fastexcel.git"
Expand Down
2 changes: 1 addition & 1 deletion src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use calamine::{Data as CalData, DataRef as CalDataRef, DataType, Range};
use crate::{
error::{ErrorContext, FastExcelErrorKind, FastExcelResult},
types::{
dtype::{get_dtype_for_column, DType, DTypeCoercion},
dtype::{DType, DTypeCoercion, get_dtype_for_column},
python::excelsheet::column_info::ColumnInfo,
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<T> ErrorContext for FastExcelResult<T> {
pub(crate) mod py_errors {
use super::FastExcelErrorKind;
use crate::error;
use pyo3::{create_exception, exceptions::PyException, PyErr, PyResult};
use pyo3::{PyErr, PyResult, create_exception, exceptions::PyException};

// Base fastexcel error
create_exception!(
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ mod error;
mod types;
mod utils;

use error::{py_errors, ErrorContext};
use error::{ErrorContext, py_errors};
use pyo3::prelude::*;
use types::python::{
ExcelReader, ExcelSheet,
excelsheet::column_info::{ColumnInfo, ColumnInfoNoDtype},
table::ExcelTable,
ExcelReader, ExcelSheet,
};

/// Reads an excel file and returns an object allowing to access its sheets and a bit of metadata
Expand Down
6 changes: 3 additions & 3 deletions src/types/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use arrow::datatypes::{DataType as ArrowDataType, TimeUnit};
use calamine::{CellErrorType, CellType, DataType, Range};
use log::warn;
use pyo3::{
prelude::PyAnyMethods, types::PyString, Bound, FromPyObject, IntoPyObject, IntoPyObjectRef,
PyAny, PyResult, Python,
Bound, FromPyObject, IntoPyObject, IntoPyObjectRef, PyAny, PyResult, Python,
prelude::PyAnyMethods, types::PyString,
};

use crate::error::{py_errors::IntoPyResult, FastExcelError, FastExcelErrorKind, FastExcelResult};
use crate::error::{FastExcelError, FastExcelErrorKind, FastExcelResult, py_errors::IntoPyResult};

use super::idx_or_name::IdxOrName;

Expand Down
6 changes: 3 additions & 3 deletions src/types/idx_or_name.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pyo3::{
prelude::PyAnyMethods, Bound, FromPyObject, IntoPyObject, IntoPyObjectExt, PyAny, PyResult,
Python,
Bound, FromPyObject, IntoPyObject, IntoPyObjectExt, PyAny, PyResult, Python,
prelude::PyAnyMethods,
};

use crate::error::{py_errors::IntoPyResult, FastExcelError, FastExcelErrorKind, FastExcelResult};
use crate::error::{FastExcelError, FastExcelErrorKind, FastExcelResult, py_errors::IntoPyResult};

#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub(crate) enum IdxOrName {
Expand Down
14 changes: 7 additions & 7 deletions src/types/python/excelreader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ use std::{
};

use arrow::{pyarrow::ToPyArrow, record_batch::RecordBatch};
use pyo3::{pyclass, pymethods, Bound, IntoPyObjectExt, PyAny, PyResult, Python};
use pyo3::{Bound, IntoPyObjectExt, PyAny, PyResult, Python, pyclass, pymethods};

use calamine::{
open_workbook_auto, open_workbook_auto_from_rs, Data, DataRef, HeaderRow, Range, Reader,
ReaderRef, Sheet as CalamineSheet, Sheets, Table,
Data, DataRef, HeaderRow, Range, Reader, ReaderRef, Sheet as CalamineSheet, Sheets, Table,
open_workbook_auto, open_workbook_auto_from_rs,
};

use crate::{
data::{record_batch_from_data_and_columns, ExcelSheetData},
data::{ExcelSheetData, record_batch_from_data_and_columns},
error::{
py_errors::IntoPyResult, ErrorContext, FastExcelError, FastExcelErrorKind, FastExcelResult,
ErrorContext, FastExcelError, FastExcelErrorKind, FastExcelResult, py_errors::IntoPyResult,
},
types::{
dtype::{DTypeCoercion, DTypes},
Expand All @@ -27,8 +27,8 @@ use crate::{
use pyo3::types::PyString;

use super::excelsheet::{
column_info::{build_available_columns_info, finalize_column_info},
ExcelSheet, Header, Pagination, SelectedColumns,
column_info::{build_available_columns_info, finalize_column_info},
};
use super::table::ExcelTable;

Expand Down Expand Up @@ -79,7 +79,7 @@ impl ExcelSheets {
sheets.with_header_row(header_row);
self
}
Self::Bytes(ref mut sheets) => {
Self::Bytes(sheets) => {
sheets.with_header_row(header_row);
self
}
Expand Down
15 changes: 11 additions & 4 deletions src/types/python/excelsheet/column_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use std::{fmt::Display, str::FromStr};

use arrow::datatypes::Field;
use calamine::DataType;
use pyo3::{pyclass, pymethods, PyResult};
use pyo3::{PyResult, pyclass, pymethods};

use crate::{
data::ExcelSheetData,
error::{
py_errors::IntoPyResult, ErrorContext, FastExcelError, FastExcelErrorKind, FastExcelResult,
ErrorContext, FastExcelError, FastExcelErrorKind, FastExcelResult, py_errors::IntoPyResult,
},
types::{
dtype::{get_dtype_for_column, DType, DTypeCoercion, DTypes},
dtype::{DType, DTypeCoercion, DTypes, get_dtype_for_column},
idx_or_name::IdxOrName,
},
};
Expand Down Expand Up @@ -193,7 +193,14 @@ impl ColumnInfo {
}

pub fn __repr__(&self) -> String {
format!("ColumnInfo(name=\"{name}\", index={index}, dtype=\"{dtype}\", dtype_from=\"{dtype_from}\", column_name_from=\"{column_name_from}\" )", name=self.name, index=self.index, dtype=self.dtype, dtype_from=self.dtype_from, column_name_from=self.column_name_from)
format!(
"ColumnInfo(name=\"{name}\", index={index}, dtype=\"{dtype}\", dtype_from=\"{dtype_from}\", column_name_from=\"{column_name_from}\" )",
name = self.name,
index = self.index,
dtype = self.dtype,
dtype_from = self.dtype_from,
column_name_from = self.column_name_from
)
}

pub fn __eq__(&self, other: &Self) -> bool {
Expand Down
12 changes: 6 additions & 6 deletions src/types/python/excelsheet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ use std::{cmp, collections::HashSet, fmt::Debug, str::FromStr};
use arrow::{pyarrow::ToPyArrow, record_batch::RecordBatch};

use pyo3::{
prelude::{pyclass, pymethods, PyAnyMethods, Python},
types::{PyList, PyString},
Bound, IntoPyObject, IntoPyObjectExt, PyAny, PyObject, PyResult,
prelude::{PyAnyMethods, Python, pyclass, pymethods},
types::{PyList, PyString},
};

use crate::{
data::{record_batch_from_data_and_columns, ExcelSheetData},
data::{ExcelSheetData, record_batch_from_data_and_columns},
error::{
py_errors::IntoPyResult, ErrorContext, FastExcelError, FastExcelErrorKind, FastExcelResult,
ErrorContext, FastExcelError, FastExcelErrorKind, FastExcelResult, py_errors::IntoPyResult,
},
types::{dtype::DTypes, idx_or_name::IdxOrName},
};
use crate::{types::dtype::DTypeCoercion, utils::schema::get_schema_sample_rows};

use self::column_info::{build_available_columns_info, finalize_column_info, ColumnInfo};
use self::column_info::{ColumnInfo, build_available_columns_info, finalize_column_info};

#[derive(Debug)]
pub(crate) enum Header {
Expand Down Expand Up @@ -549,7 +549,7 @@ impl ExcelSheet {
#[getter]
pub fn visible<'py>(&'py self, py: Python<'py>) -> FastExcelResult<Bound<'py, PyString>> {
let visible: SheetVisible = self.sheet_meta.visible.into();
(&visible).into_pyobject(py).map_err(Into::into)
(&visible).into_pyobject(py)
}

pub fn to_arrow<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
Expand Down
4 changes: 2 additions & 2 deletions src/types/python/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arrow::{
pyarrow::ToPyArrow,
};
use calamine::{Data, Range, Table};
use pyo3::{pyclass, pymethods, PyObject, Python};
use pyo3::{PyObject, Python, pyclass, pymethods};

use crate::{
data::{
Expand All @@ -23,8 +23,8 @@ use crate::{
};

use super::excelsheet::{
column_info::{build_available_columns_info, AvailableColumns, ColumnInfo},
Header, Pagination, SelectedColumns,
column_info::{AvailableColumns, ColumnInfo, build_available_columns_info},
};

#[pyclass(name = "_ExcelTable")]
Expand Down

0 comments on commit a1a9f76

Please sign in to comment.