Skip to content

PR[1]: build: migrate from setuptools to scikit-build-core - #252

Open
San1357 wants to merge 6 commits into
theochem:masterfrom
San1357:pr-1/scikit-build-migration
Open

PR[1]: build: migrate from setuptools to scikit-build-core#252
San1357 wants to merge 6 commits into
theochem:masterfrom
San1357:pr-1/scikit-build-migration

Conversation

@San1357

@San1357 San1357 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • I migrated the build system from setuptools to scikit-build-core.

  • In the existing pyproject.toml, setuptools was being used — but setuptools cannot compile C code. So I replaced it with
    scikit-build-core — because scikit-build-core can call CMake, and CMake will compile libcint.

  • I referred to the repo matrix-permanent project for this — it already had the same
    scikit-build-core setup. so I followed the same structure.

  • Added CMakeLists.txt with FetchContent for automatic libcint/qcint download

  • Platform detection: x86+AVX2 → qcint (optimized), ARM/non-AVX → libcint (generic)

  • Referenced matrix-permanent repo and Libcint 6 paper (Section IV) for structure and compile flags

  • Part of Issue GSoC 2026: Better linking between Libcint and GBasis #229 (PR-1)[Week-1]

Description:

  • Migrated build backend from setuptools to scikit-build-core
  • Updated numpy dependency to >=2.0
  • Removed setuptools specific configurations
  • Added scikit-build configuration
  • This enables CMake integration for libcint compilation
  • Added root level CMakeLists.txt
  • FetchContent automatically downloads and compiles libcint or qcint based on platform
  • x86 + AVX2 → qcint (SIMD optimized)
  • ARM/non-AVX → libcint (generic, works on all platforms)
  • Compile flags: WITH_FORTRAN=OFF, WITH_RANGE_COULOMB=ON
  • Added placeholder gbasis/integrals/src/libcint_wrap.c (actual C wrapper will be in next PR)
  • Updated numpy version in .github/workflows/pytest.yaml for consistency with pyproject.toml

How To Test

Tested locally on Mac M5 (ARM):

Prerequisites:

pip install scikit-build-core==0.9.0

Build locally:

pip install -e . --no-build-isolation -v
Screenshot 2026-06-08 at 1 02 43 AM Screenshot 2026-06-08 at 1 04 25 AM ... ... ... ... Screenshot 2026-06-08 at 1 05 21 AM

Expected output during build:

-- Architecture: ARM/non-AVX detected — use libcint   (on ARM/Mac M-series)
-- Architecture: x86 + AVX2 detected — use qcint      (on Intel/AMD x86)
-- Configuring done
-- Build files have been written to: ...
Successfully installed qc-gbasis

Verify installation:

python -c "import gbasis; print('gbasis import successful')"

Expected output:

gbasis import successful
Screenshot 2026-06-08 at 12 57 06 AM

IMPORTANT NOTES:

Note: CMakeLists.txt has been included in this PR.
Note: CMakeLists.txt has been included in this PR.
Note: pytest CI checks are expected to fail — CI/CD will be configured in a later PR.
Note: C wrapper (libcint_wrap.c) is a placeholder — actual implementation will follow in next PR.

@San1357
San1357 requested a review from msricher June 4, 2026 19:58

@msricher msricher left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also upload the CMakeLists.txt. Thanks

Comment thread pyproject.toml
Comment on lines -94 to -101
# E is pycodestyle
# F is pyflakes
# UP is pyupgrade - automatically updates syntax
# B is flake8-bugbear
# I is sort imports alphabetically
# PGH is pygrep-hooks
# PL is pylint
# RUF is Ruff-specific rules

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove someone's comments? Keep them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@msricher msricher left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Thank you, this seems fine. Can you create a new branch, san1357:dev, from theochem:master? We should merge these PRs into your dev branch, and then at the end, merge that into theochem:master.

@PaulWAyers

Copy link
Copy Markdown
Member

I'm going to run a copilot review. I usually do that automatically (we should add it to the GitHub actions workflow). It's not perfect but it often helps a bit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Python packaging/build backend from setuptools to scikit-build-core in order to integrate a CMake-based build that can fetch and compile libcint/qcint as part of building GBasis wheels.

Changes:

  • Switch pyproject.toml build backend to scikit_build_core.build, add scikit-build configuration, and raise NumPy baseline to >=2.0.
  • Add a top-level CMakeLists.txt that uses FetchContent to pull/build libcint or qcint based on platform/AVX2 detection.
  • Add a placeholder C source for future Python/C bindings and update the pytest workflow’s NumPy pin.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 13 comments.

File Description
pyproject.toml Migrates build backend to scikit-build-core, adjusts dependencies, and adds scikit-build metadata/version config.
CMakeLists.txt Introduces CMake build logic to fetch/build libcint/qcint and build/install a Python extension module.
gbasis/integrals/src/libcint_wrap.c Adds a placeholder C file intended for future libcint Python/C bindings.
.github/workflows/pytest.yaml Updates CI dependency pinning for NumPy in the Py3.9 “old deps” step.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment on lines 5 to +7
[build-system]
requires = ["setuptools>=64", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"
requires = ["numpy>=2.0", "scikit-build-core>=0.9"]
build-backend = "scikit_build_core.build"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — added setuptools-scm to [build-system].requires.

Comment thread pyproject.toml
Comment on lines 39 to 45
dependencies = [
# Ensure the minimal versions are kept consistent with those in .github/workflows/pytest.yaml
"numpy >=1.22, <2.0.0; platform_system=='Windows'",
"numpy >=1.22; platform_system=='Linux'",
# Updated to numpy>=2.0 required for scikit-build-core C extension support
# Note: Keep consistent with .github/workflows/pytest.yaml
"numpy>=2.0",
"scipy>=1.11.1",
"importlib_resources",
"sympy",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised scipy minimum to 1.13.0 which added NumPy 2.x support.

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml
Comment on lines 68 to +71
[project.optional-dependencies]

# Install with: pip install gbasis[dev]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed - updated package name from gbasis to qc-gbasis in install comment

Comment thread pyproject.toml Outdated
Comment on lines +86 to +87
# Install with: pip install gbasis[doc]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread CMakeLists.txt
Comment on lines +28 to +30
include(CheckCCompilerFlag)
check_c_compiler_flag("-mavx2" HAS_AVX2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Windows-specific AVX2 detection using /arch:AVX2 for MSVC compilers.

Comment thread CMakeLists.txt Outdated
Comment on lines +31 to +37
if(HAS_AVX2 AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set(USE_QCINT ON)
message(STATUS "Architecture: x86 + AVX2 detected → use qcint")
else()
set(USE_QCINT OFF)
message(STATUS "Architecture: ARM/non-AVX detected → use libcint")
endif()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added user override support — if USE_QCINT is explicitly set by the user, auto-detection is skipped.

Comment thread CMakeLists.txt
Comment on lines +84 to +93
# Link C extension with libcint
target_link_libraries(libcint_bindings PRIVATE cint)

# Prevent libcint from installing to system directories
set(CINT_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/cint_install CACHE PATH "" FORCE)

# Install only the Python extension into the wheel
install(TARGETS libcint_bindings
LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}/gbasis/integrals/lib
) No newline at end of file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be addressed in the next PR which adds the platform-aware libcint shared library copying alongside the extension.

Comment thread gbasis/integrals/src/libcint_wrap.c Outdated
Comment on lines +1 to +4

/* libcint Python/C API bindings
* PR 3 mein implement hoga
*/ No newline at end of file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a placeholder file in PR 1. The full implementation including PyInit_libcint_bindings will be added in the follow-up PR.

Comment thread .github/workflows/pytest.yaml Outdated
Comment on lines +32 to +36
@@ -33,7 +33,7 @@ jobs:
if: ${{ matrix.py == '3.9'}}
# Ensure these versions are consistent with the minimal version requirements
# in pyproject.toml
run: pip install numpy==1.22 scipy==1.11.1
run: pip install numpy==2.0 scipy==1.11.1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — bumped scipy to 1.13.0 in pytest.yaml to match pyproject.toml minimum.

San1357 and others added 2 commits June 9, 2026 03:21
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@San1357

San1357 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author
  • Thank you, this seems fine. Can you create a new branch, san1357:dev, from theochem:master? We should merge these PRs into your dev branch, and then at the end, merge that into theochem:master.

@msricher Created san1357:dev branch from theochem:master.
Here is the branch: https://github.com/San1357/gbasis/tree/dev

@msricher

msricher commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

OK, fixes look good. Please merge this into your dev branch and we'll continue from there with the next PR.

@PaulWAyers PaulWAyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like @msricher or @marco-2023 to do a detailed review and final approval but it is OK for me.

@msricher

msricher commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

I'd like @msricher or @marco-2023 to do a detailed review and final approval but it is OK for me.

I'm fine with it, it's just boilerplate he's going to merge into his dev branch,.

@PaulWAyers PaulWAyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@San1357 you can merge it now, then.

@marco-2023

Copy link
Copy Markdown
Contributor

@msricher, @PaulWAyers, @San1357 if it is going to be merged in dev, it would need to be another PR. This one is trying to merge on main.

@San1357

San1357 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

As suggested by @marco-2023, I've created a new PR targeting san1357:dev: San1357#1

The changes have been successfully merged into the dev branch.

@San1357

San1357 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@msricher @marco-2023 @PaulWAyers For the next PR, I'll create them targeting san1357:dev on my fork. I can add you as collaborators so you can review them there. Would that work, or do you prefer a different approach?

@msricher

Copy link
Copy Markdown
Collaborator

Sure, that works for me.

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.

5 participants