Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,81 @@ jobs:
uses: NWChemEx/.github/.github/workflows/test_nwx_library.yaml@master
with:
compilers: '["gcc-14", "clang-18"]'

test_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install clang-18
run: |
sudo apt-get update -y
sudo apt-get install -y clang-18
echo "CC=clang-18" >> $GITHUB_ENV
echo "CXX=clang++-18" >> $GITHUB_ENV

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Editable install (dev)
run: pip install -e ".[dev]"

- name: Run C++ tests
run: cd build && ctest --output-on-failure

- name: Run Python tests
run: pytest tests/python/

deploy_to_testpypi:
needs: test_python
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
cibw_build: cp312-manylinux_x86_64
- os: macos-14
cibw_build: cp312-macosx_arm64
runs-on: ${{ matrix.os }}
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set pretend version for TestPyPI (unique per workflow run)
run: |
python3 -m pip install --upgrade pip
python3 -m pip install "setuptools-scm>=8"
python3 <<'PY'
import os

from setuptools_scm import get_version

gh_env = os.environ.get("GITHUB_ENV")
if not gh_env:
raise SystemExit("GITHUB_ENV is not set")

base = get_version(local_scheme="no-local-version")
rid = os.environ["GITHUB_RUN_ID"]
pretend = f"{base}.post{rid}"
with open(gh_env, "a", encoding="utf-8") as f:
f.write(f"SETUPTOOLS_SCM_PRETEND_VERSION={pretend}\n")
print(f"SETUPTOOLS_SCM_PRETEND_VERSION={pretend}")
PY

- name: Build wheels
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_BUILD: ${{ matrix.cibw_build }}

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheelhouse/
repository-url: https://test.pypi.org/legacy/
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
# limitations under the License.

venv/
.cache/
.venv/
build/
__pycache__/
.pytest_cache/
61 changes: 32 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,50 @@
# limitations under the License.

cmake_minimum_required(VERSION 3.14)

# Version from scikit-build-core when building wheels/sdists; plain CMake keeps 1.0.0.
# project(VERSION) accepts only numeric major.minor.patch[.tweak]; strip any PEP440 suffix.
if(DEFINED SKBUILD_PROJECT_VERSION AND NOT SKBUILD_PROJECT_VERSION STREQUAL "")
set(_wtf_version_source "${SKBUILD_PROJECT_VERSION}")
else()
set(_wtf_version_source "1.0.0")
endif()
if(_wtf_version_source MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(_wtf_cmake_version "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
else()
set(_wtf_cmake_version "1.0.0")
endif()

# Downloads common CMake modules used throughout NWChemEx
project(wtf VERSION "${_wtf_cmake_version}" LANGUAGES CXX)

include(cmake/get_nwx_cmake.cmake)

project(wtf VERSION "1.0.0" LANGUAGES CXX)
include(cmake/disable_in_source_builds.cmake)
include(disable_in_source_builds)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

# TODO: Make these into proper options
set(BUILD_TESTING TRUE)
set(CMAKE_BUILD_SHARED_LIBS ON)

include(cmake/get_dependencies.cmake)
option(BUILD_PYBIND11_BINDINGS "Build Python bindings via pybind11" ON)

# Define the documentation target
include(nwx_cxx_api_docs)
nwx_cxx_api_docs("include" "src")
nwx_cxx_api_docs("cxx/include" "cxx/src")

# Build the Library
file(GLOB_RECURSE WTF_HEADER_FILES CONFIGURE_DEPENDS include/wtf/*.hpp)
file(GLOB_RECURSE WTF_SOURCE_FILES CONFIGURE_DEPENDS src/wtf/*.cpp)
add_library(${PROJECT_NAME} ${WTF_SOURCE_FILES})
target_link_libraries(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

if(${BUILD_TESTING})
include(CTest)
get_dependencies(catch2)
include(cmake/catch2_tests_from_dir.cmake)
catch2_tests_from_dir(
"unit_test_${PROJECT_NAME}"
tests/unit_tests/wtf
${PROJECT_NAME}
)
endif()

include(cmake/install_target.cmake)
install_library(
include(nwx_library)
nwx_library(${PROJECT_NAME} "cxx/include" "cxx/src")

# Register the C++ tests
include(catch2_tests_from_dir)
catch2_tests_from_dir(
"unit_test_${PROJECT_NAME}"
"tests/cxx/unit_tests/${PROJECT_NAME}"
${PROJECT_NAME}
"${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}"
)

# Register the Python module
include(nwx_python_module)
nwx_python_module(${PROJECT_NAME} "cxx/src")
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,42 @@ writes their interfaces in terms of "weakly typed" objects like `Float` and
`FloatBuffer`, and determination of the actual floating-point type is deferred
to runtime.

## Development Setup

### Prerequisites

- CMake >= 3.14
- A C++20-capable compiler
- Python >= 3.8

### Editable install

Create and activate a virtual environment, then install the package in editable
(dev) mode. This builds the Python bindings and the C++ test suite:

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
```

### Running the C++ tests

The editable install keeps its build tree in `build/` (configured via
`build-dir` in `pyproject.toml`). Run CTest directly from there:

```bash
cd build && ctest --output-on-failure
```

### Running the Python tests

With the virtual environment active:

```bash
pytest tests/python/
```

## Problem Description

Full description (TODO: Add link to the documentation)
Expand Down
29 changes: 0 additions & 29 deletions cmake/catch2_tests_from_dir.cmake

This file was deleted.

22 changes: 0 additions & 22 deletions cmake/dependencies/catch2.cmake

This file was deleted.

25 changes: 0 additions & 25 deletions cmake/get_dependencies.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/get_nwx_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ macro(get_nwx_cmake)
include(FetchContent)
FetchContent_Declare(
nwx_cmake
GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake
GIT_REPOSITORY https://github.com/ryanmrichard/NWXCMake
)
FetchContent_MakeAvailable(nwx_cmake)
set(
Expand Down
68 changes: 0 additions & 68 deletions cmake/install_target.cmake

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions cxx/src/wtf/export_wtf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2025 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "export_wtf.hpp"

namespace wtf {

PYBIND11_MODULE(wtf, m) { fp::export_float(m); }

} // namespace wtf
Loading
Loading