Skip to content

Conversation

@Acture
Copy link
Contributor

@Acture Acture commented Oct 21, 2025

Summary

Depends on #153.
Closes #154.

This PR is a comprehensive build system and packaging refactor following the pybind11 migration.
It consolidates all build logic under a modern, reproducible structure and aligns EasyGraph’s native extension, Python packaging, and test workflow.

While the diff is large (+3,176 −2,979, 142 files changed), most edits are:

  • structural (directory moves, renames, CMake rewrites),
  • dependency normalization (pybind11, scikit-build-core, uv),
  • or automated formatting (Ruff and pytest modernization).

No algorithmic logic is altered.

Key Changes

  1. Build System
    • 将所有 py::object/py::dict/py::list 的 Boost 习语改为 pybind11 API 与异常:
    • throw py::key_error/py::value_error/py::type_error 等替代手写 PyErr_*。
    • 使用 py::arg("...") = py::none()/py::str("...") 提供默认参数。
    • def() 绑定处修复“默认参数重复定义”与签名不匹配问题。
    • 统一 C++17(-std=gnu++17),移除结构化绑定告警;修正 py::dict 只读访问(用 get_item() 或 obj = dict[key] 的 pybind11 方式)。
    • 模块入口:PYBIND11_MODULE(_core, m);导出类型挂载到 easygraph.cpp_easygraph。
  2. Packaging / Build
    • 仅保留 一个顶层包 easygraph。
    • pyproject.toml 使用 scikit-build-core 控制打包:
  3. Tests & CI Modernization
    • 移除 nose:from unittest import SkipTest 或 pytest.importorskip 取代 from nose import SkipTest。
    • Pandas 2.x:将所有 DataFrame.append(...) 改为 pd.concat([df, row_or_df], ignore_index=True)。
    • pytest -ra -W always 可显示全部 warnings;默认配置不再全局禁用 warnings。
  4. Tooling: Ruff / pytest / tox / uv
    • Ruff 取代 Flake8:
    • [tool.ruff] 与 [tool.ruff.lint]、[tool.ruff.format];
    • 选择性启用规则族(E/F/W, B, Q, SIM, TID, TCH, ERA, UP),而非大批量 ignore;
    • 纠正不被 Ruff 支持的小节。
    • 在 pyproject.toml 汇总:
    • pytest:-ra;移除 --disable-warnings。
    • tox:迁移到 [tool.tox],使用 tox-uv 加速环境创建。

Acture added 17 commits October 21, 2025 02:57
The `test_suite` and `tests_require` arguments in `setup()` are legacy
setuptools features that have been deprecated. Modern test runners like
`pytest` and `tox` handle test discovery and dependency management externally.

This commit removes these obsolete arguments to modernize the packaging
configuration, reduce clutter, and silence deprecation warnings.

Signed-off-by: acture <[email protected]>
The `setup.py` file used the deprecated license classifier
`License :: OSI Approved :: BSD License`. Modern Python packaging standards
(PyPA) recommend using specific, machine-readable SPDX identifiers.

This commit replaces the old classifier with the precise `BSD-3-Clause`
identifier in the `license` field. This aligns the project with best
practices and silences setuptools deprecation warnings.

Signed-off-by: acture <[email protected]>
…restructure project

Replaced the legacy `setup.py` with modern `pyproject.toml` following PEP 517 and PEP 518 standards. Updated the project structure to move source files into a `src/` directory. Also, introduced `scikit-build` for efficient handling of C++ extensions.

This change modernizes the project's packaging approach, aligns with best practices, and simplifies dependency management.

Signed-off-by: acture <[email protected]>
Introduced a `.envrc` file to automate virtual environment setup using `direnv`. This inclusion ensures that the virtual environment is automatically initialized on directory entry and the necessary environment is activated.

Signed-off-by: acture <[email protected]>
… for clarity

This commit removes redundant imports, such as `deepcopy` and others from several modules, to reduce unnecessary dependencies. Additionally, improved the variable naming for better readability (e.g., `l` renamed to `length`).

The changes optimize the codebase and enhance code clarity while preserving current functionality.

Signed-off-by: acture <[email protected]>
Migrated from `Boost.Python` to `pybind11` for Python bindings, removing the dependency on Boost. Updated `CMakeLists.txt` to drop Boost requirements and refactored binding definitions to align with the pybind11 API. This includes updating function signatures and argument handling for consistency with pybind11.

This migration simplifies the build process and reduces external dependencies while maintaining existing functionality.

Signed-off-by: acture <[email protected]>
- Renamed `blogcatalog.mat` for consistency in the dataset samples.
- Updated `.gitignore` by adding IDE-specific build directory patterns (e.g., `**/cmake-build-debug`).
- Removed support for Python versions <3.10 in `pyproject.toml`.
- Adjusted `pyproject.toml` to include `scikit-build`-specific details (`source-dir` added under `[tool.scikit-build.cmake]`).
- Simplified package structure by modifying `setuptools.packages.find.where`.

These changes streamline project organization, enhance compatibility with modern packaging standards, and refine dependency management.

Signed-off-by: acture <[email protected]>
Completely replaced all Boost.Python bindings with modern pybind11 equivalents.
All modules, method bindings, and function wrappers were rewritten to use
pybind11’s C++17 interface (py::object, py::dict, py::list, etc.).
Removed Boost.Python headers and adjusted build/CMake configuration accordingly.

Signed-off-by: acture <[email protected]>
…ct structure

- Removed `pytest.ini`, `tox.ini`, and `.flake8` as part of the configuration cleanup.
- Updated and reorganized `pyproject.toml` with modern configurations for dependency management, linting, and testing.
- Migrated build-related files from `cpp_easygraph` to `_cpp_easygraph` to align with updated CMake project structure.
- Introduced Ruff linting with detailed rule selection and customization.
- Consolidated `tox` configurations into `pyproject.toml`.

These updates simplify project setup, align with modern tooling practices, and improve maintainability.

Signed-off-by: acture <[email protected]>
- Replaced `from nose import SkipTest` with `from unittest import SkipTest` for compatibility with Python ≥3.12.
- Removed all residual `nose` imports and related code paths.
- Ensures pytest-native skip handling (`pytest.importorskip`, `pytest.skip`) is used consistently.

This change removes an unmaintained dependency (`nose`) and restores compatibility with modern Python versions.

Signed-off-by: acture <[email protected]>
- Introduced `graphviz` as an optional dependency in `pyproject.toml`, requiring `lxml>=6.0.2`.
- Enables additional functionality for users needing Graphviz-related features.

This addition improves the flexibility of the package by allowing optional integration with Graphviz.

Signed-off-by: acture <[email protected]>
- Updated instances of `np.float_` to `np.float64` in `graphml.py`, `gexf.py`, and associated tests.
- Ensures compatibility with newer NumPy versions where `np.float_` is deprecated.

Signed-off-by: acture <[email protected]>
….14`

- Replaced `lxml>=6.0.2` with `pygraphviz>=1.14` in `pyproject.toml` under `[project.optional-dependencies]`.
- Ensures compatibility and better alignment with Graphviz-related features.

Signed-off-by: acture <[email protected]>
- Updated `test_convert.py` to replace the deprecated `DataFrame.append` method with `pd.concat` for constructing dataframes.
- Ensures compatibility with newer pandas versions where `DataFrame.append` is deprecated.

Signed-off-by: acture <[email protected]>
…arsing logic

- Removed unnecessary `warnings` imports and deprecated warnings in the GML parsing module (`gml.py`).
- Fixed inconsistent indentation across GML and GraphML modules to adhere to PEP 8 standards.
- Improved readability by cleaning up GML parsing logic, particularly around `parse_gml_lines` and helper functions.
- Minor fix in GraphML

Signed-off-by: acture <[email protected]>
- Updated all single-quoted strings in `directed_graph.py` to double-quoted strings for consistency.
- Replaced `.format` with f-strings for improved readability and performance.
- Simplified import statements by removing redundant imports and adhering to PEP 8 guidelines.
- Used type hints with native `list` and `dict` instead of `List` and `Dict` from `typing`.

These changes align the codebase with modern Python conventions and enhance readability.

Signed-off-by: acture <[email protected]>
….suppress`

- Replaced `try-except` blocks catching generic exceptions with `contextlib.suppress` for improved readability and performance.
- Modified default mutable arguments (`{}` and `[]`) to `None` with proper initialization to prevent unintended side effects.
- Simplified `for` loop variables by prefixing unused ones with an underscore (`_`).
- Refactored conditional logic to use explicit boolean checks (`if not ...` for clarity).
- Updated `dict.keys()` and `dict.items()` iterations to directly iterate over dictionary views.
- Standardized function imports to ensure consistency by eliminating relative imports where applicable.

These updates improve readability, reduce potential bugs, and align the codebase with Python best practices.

Signed-off-by: acture <[email protected]>
@Acture Acture changed the title • Refactor build Refactor: migrate C++ bindings to pybind11; modernize build, packaging & tests Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Modernize the Development Workflow with pyproject.toml and uv

1 participant