Skip to content
Merged
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
8 changes: 3 additions & 5 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ name: Check Clang Format

on:
push:
branches:
- master
- develop
branches: [ master, develop ]
pull_request:
branches:
- master
branches: [ master, develop ]


jobs:
clang-format:
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/python-distro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master ]
branches: [ master, develop ]

jobs:
build:
Expand All @@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python 3.14
uses: actions/setup-python@v4
Expand All @@ -24,11 +22,16 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential pybind11-dev
sudo apt-get install -y cmake build-essential

- name: Install Python build dependencies
run: |
python -m pip install --upgrade pip
pip install pybind11

- name: Configure CMake
run: |
cmake -S . -B build
cmake -S . -B build -DPython_EXECUTABLE="$(which python)"

- name: Build
run: |
Expand All @@ -41,8 +44,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
/.idea/
/.venv3.14/
/.venv3.13/
/.venv3.12/
/.venv3.12/
__pycache__/
*.py[cod]
.pytest_cache/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ repos:
rev: v18.1.3
hooks:
- id: clang-format
name: clang-format (C/C++)
files: \.(c|cc|cpp|cxx|h|hpp)$
name: clang-format (C/C++/CUDA)
files: \.(c|cc|cpp|cxx|cu|cuh|h|hpp)$
48 changes: 34 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
cmake_minimum_required(VERSION 3.20)
project(fastdist LANGUAGES CXX)
project(fastdist VERSION 0.1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# -----------------------------
# Generated version header
# -----------------------------
configure_file(
${PROJECT_SOURCE_DIR}/include/fastdist/version.h.in
${PROJECT_BINARY_DIR}/generated/fastdist/version.h
@ONLY
)
message(STATUS "fastdist version ${PROJECT_VERSION}")

# -----------------------------
# CUDA Backend
# -----------------------------
Expand All @@ -19,26 +29,35 @@ endif ()
# -----------------------------
# python
# -----------------------------
find_package(Python 3.14 REQUIRED COMPONENTS Interpreter Development)
find_package(Python 3.12 REQUIRED COMPONENTS Interpreter Development.Module)
message(STATUS "Building against Python ${Python_VERSION} at ${Python_EXECUTABLE}")

# -----------------------------
# pybind11
# -----------------------------
# Setting up python-pybind11 connection
set(PYBIND11_FINDPYTHON ON)
set(PYBIND11_PYTHON_EXECUTABLE ${Python_EXECUTABLE})
set(PYBIND11_PYTHON_VERSION ${Python_VERSION_STRING})

# Initializing pybind11 library
include(FetchContent)

FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.12.1
)
# Use the pybind11 installed in the active environment (already declared in
# pyproject.toml build-system.requires) so headers always match the interpreter.
if (NOT pybind11_DIR)
execute_process(
COMMAND "${Python_EXECUTABLE}" -m pybind11 --cmakedir
OUTPUT_VARIABLE _pybind11_cmakedir
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _pybind11_probe_result
ERROR_QUIET
)
if (_pybind11_probe_result EQUAL 0)
set(pybind11_DIR "${_pybind11_cmakedir}")
else ()
# No pip pybind11 in this interpreter; fall back to a system install
# (e.g. Debian's pybind11-dev), which ships its own CMake config.
message(STATUS "pip pybind11 not found; falling back to a system installation")
endif ()
endif ()

FetchContent_MakeAvailable(pybind11)
find_package(pybind11 CONFIG REQUIRED)
message(STATUS "Using pybind11 ${pybind11_VERSION} from ${pybind11_DIR}")

pybind11_add_module(_fastdist
python/bindings/bindings.cpp
Expand Down Expand Up @@ -194,6 +213,7 @@ target_include_directories(fastdist_core
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/fastdist>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/generated>
${CUDAToolkit_INCLUDE_DIRS}
$<INSTALL_INTERFACE:include>
)
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@

### Cloning the Repository

This project uses Git submodules. Clone the repository recursively:

```bash
git clone --recurse-submodule https://github.com/ghosteau/fastdist.git
git submodule update --init --recursive
git clone https://github.com/ghosteau/fastdist.git
```

---
Expand All @@ -33,7 +30,7 @@ git submodule update --init --recursive
2. From the **project root**, build the Python wheel:

```bash
python3 python/setup.py bdist_wheel
python3 setup.py bdist_wheel
```

**Important:**
Expand All @@ -43,7 +40,7 @@ python3 python/setup.py bdist_wheel
3. Install the generated wheel:

```bash
pip install .\dist\fastdist-0.0.1-cpXXX-cpXXX-win_amd64.whl --force-reinstall
pip install .\dist\fastdist-<version>-cpXXX-cpXXX-win_amd64.whl --force-reinstall
```

---
Expand Down Expand Up @@ -92,6 +89,10 @@ The normal distribution is a good reference for creating new distributions. \

---

## Updating the Version
Only update the version from the CMakeLists.txt at the line:
`project(fastdist VERSION x.y.z LANGUAGES CXX)`

## Building Wheels for Multiple Python Versions (3.12–3.14)

To generate wheels for all currently supported Python versions:
Expand Down Expand Up @@ -212,7 +213,7 @@ Testing and CI:

Python Bindings:

- Pybind11 integrated as a submodule for modular C++/Python bindings
- Pybind11 resolved from the build environment for modular C++/Python bindings
- Full Python support for all currently supported builds

---
Expand Down
20 changes: 0 additions & 20 deletions include/fastdist/version.h

This file was deleted.

25 changes: 25 additions & 0 deletions include/fastdist/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Version header for the FastDist library
//
// GENERATED FILE — do not edit the copy in your build directory.
// Edit include/fastdist/version.h.in instead, and change the version
// number only in the project() call in CMakeLists.txt.
#pragma once

// Version denoted as major.minor.patch
#define FASTDIST_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define FASTDIST_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define FASTDIST_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define FASTDIST_VERSION_STRING "@PROJECT_VERSION@"

#ifdef __cplusplus
extern "C" {
#endif

// Returns the major, minor, and patch version numbers respectively
int fd_version_major(void);
int fd_version_minor(void);
int fd_version_patch(void);

#ifdef __cplusplus
}
#endif
3 changes: 2 additions & 1 deletion python/bindings/bindings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// CPP file to link all other bindings
#include <fastdist/version.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

Expand Down Expand Up @@ -36,5 +37,5 @@ PYBIND11_MODULE(_fastdist, m) {
bind_chi_square(m);
bind_utils(m);

m.attr("__version__") = "0.0.1";
m.attr("__version__") = FASTDIST_VERSION_STRING;
}
14 changes: 11 additions & 3 deletions python/fastdist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# python/fastdist/__init__.py
from importlib.metadata import PackageNotFoundError, version as _pkg_version

from . import _fastdist
from .distributions import (
Bernoulli, Beta, Binomial, ChiSquare, DiscreteUniform,
Exponential, Gamma, Geometric, NegativeBinomial, Normal,
Poisson, Uniform, Utils
)

__all__ = ["Bernoulli", "Beta", "Binomial",
try:
__version__ = _pkg_version("fastdist")
except PackageNotFoundError: # running from an uninstalled source checkout
__version__ = "0.0.0+unknown"

__all__ = ["__version__",
"Bernoulli", "Beta", "Binomial", "ChiSquare",
"DiscreteUniform", "Exponential", "Gamma",
"Geometric", "Normal", "NegativeBinomial",
"Poisson", "Uniform", "Utils"]
"Geometric", "NegativeBinomial", "Normal",
"Poisson", "Uniform", "Utils"]
Loading
Loading