Skip to content
Open
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
147 changes: 147 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Build Status

on: [push, pull_request]

env:
BOOST_VERSION: 1.84.0
EIGEN_VERSION: 3.4.0

jobs:
build:
strategy:
fail-fast: false
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
python: [38, 39, 310, 311, 312]
cfg:
- { os: ubuntu-latest, cibw_id: manylinux_x86_64, cc: gcc, cxx: g++, platform: x64, root_install_dir: '/home/runner/work'}
- { os: ubuntu-latest, cibw_id: musllinux_x86_64, cc: gcc, cxx: g++, platform: x64, root_install_dir: '/home/runner/work'}
- { os: macos-13, cibw_id: macosx_x86_64, cc: clang, cxx: clang++, platform: x64, root_install_dir: '/Users/runner/work'} # intel runner
- { os: macos-14, cibw_id: macosx_arm64, cc: clang, cxx: clang++, platform: arm64, root_install_dir: '/Users/runner/work'} # apple silicon runner
- { os: windows-latest, cibw_id: win_amd64, cc: cl, cxx: cl, platform: x64, root_install_dir: 'D:\'}
env:
PYTHON_VENV_ROOT: ${{github.workspace}}/src/python-venv


name: Build and test on ${{ matrix.cfg.os }} for cp${{ matrix.python }}-${{ matrix.cfg.cibw_id }}
runs-on: ${{ matrix.cfg.os }}

steps:
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
# git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Install dependencies
id: install-dependencies
uses: vinecopulib/vinecopulib/.github/actions/install-dependencies@better-actions
with:
os: ${{ matrix.cfg.os }}
platform: ${{ matrix.cfg.platform }}
boost_install_dir: ${{ matrix.cfg.root_install_dir }}
eigen_install_dir: ${{ matrix.cfg.root_install_dir }}
boost_version: ${{ env.BOOST_VERSION }}
eigen_version: ${{ env.EIGEN_VERSION }}
wdm: 'false'
- name: Lint with flake8
if: matrix.cfg.os != 'windows-latest'
run: |
python3 -m venv ${PYTHON_VENV_ROOT}
source ${PYTHON_VENV_ROOT}/bin/activate
pip3 install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=lib
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=lib
- name: Build and test wheels
uses: pypa/cibuildwheel@v2.20.0
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.cfg.cibw_id }}
CIBW_ENVIRONMENT_WINDOWS: Boost_INCLUDE_DIR='${{steps.install-dependencies.outputs.BOOST_ROOT}}\include' EIGEN3_INCLUDE_DIR='C:\ProgramData\chocolatey\lib\eigen\include'
CIBW_ENVIRONMENT_MACOS: "Boost_INCLUDE_DIR=${{steps.install-dependencies.outputs.BOOST_ROOT}}/include EIGEN3_INCLUDE_DIR=${{matrix.cfg.root_install_dir}}/include/eigen3"
CIBW_ENVIRONMENT_LINUX: "Boost_INCLUDE_DIR=/host${{steps.install-dependencies.outputs.BOOST_ROOT}}/include EIGEN3_INCLUDE_DIR=/host${{matrix.cfg.root_install_dir}}/include/eigen3"
CIBW_ENVIRONMENT_PASS_LINUX: "Boost_INCLUDE_DIR EIGEN3_INCLUDE_DIR"
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.cfg.os }}-${{ matrix.python }}-${{ matrix.cfg.cibw_id }}
path: ./wheelhouse/*.whl

build_sdist:
runs-on: ubuntu-latest
# needs: build
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: recursive
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Install dependencies
id: install-dependencies
uses: vinecopulib/vinecopulib/.github/actions/install-dependencies@better-actions
with:
os: 'ubuntu-latest'
boost_install_dir: '/home/runner/work'
eigen_install_dir: '/home/runner/work'
boost_version: ${{ env.BOOST_VERSION }}
eigen_version: ${{ env.EIGEN_VERSION }}
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Upgrade pip and install build dependency
run: |
echo "Boost_INCLUDE_DIR=${{steps.install-dependencies.outputs.BOOST_ROOT}}/include" >> $GITHUB_ENV
echo "EIGEN3_INCLUDE_DIR=/home/runner/work/include/eigen3" >> $GITHUB_ENV
python -m pip install --upgrade pip
pip install build
- name: Create source distribution
run: |
export Boost_INCLUDE_DIR=$Boost_INCLUDE_DIR
export EIGEN3_INCLUDE_DIR=$EIGEN3_INCLUDE_DIR
pipx run build --sdist
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_to_pypi:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download cibw artifacts
uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish distribution Test PyPI
if: |
job.status == 'success'
&& github.base_ref == 'main'
&& github.head_ref == 'dev'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: |
job.status == 'success'
&& github.event_name == 'push'
&& startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,16 @@ Temporary Items
.apdisk
# boost
lib/boost

CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "lib/eigen"]
path = lib/eigen
url = https://github.com/eigenteam/eigen-git-mirror
[submodule "lib/kde1d"]
path = lib/kde1d
url = https://github.com/vinecopulib/kde1d-cpp
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2019 Thomas Nagler and Thibault Vatter
Copyright © 2024 Thomas Nagler and Thibault Vatter

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
Expand Down
5 changes: 1 addition & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
include README.md LICENSE requirements.txt
recursive-include src *
recursive-include lib/boost *.hpp *.h
recursive-include lib/eigen/Eigen *
recursive-include lib/eigen/unsupported/Eigen *
recursive-include lib/kde1d-cpp/include *.hpp
recursive-include lib/kde1d/include *.hpp
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,45 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3c0056d3ca5244a5ba6a2b32f87be4cf)](https://www.codacy.com/gh/vinecopulib/pykde1d?utm_source=github.com&utm_medium=referral&utm_content=vinecopulib/pykde1d&utm_campaign=Badge_Grade)
[![Documentation](https://img.shields.io/website/http/vinecopulib.github.io/pykde1d.svg)](https://vinecopulib.github.io/pykde1d/)

### Summary

This library provides a fast and flexible univariate kernel density estimator for Python:

- It implements a univariate kernel density estimator that can handle
bounded and discrete data,
- It provides classical kernel density as well as log-linear and log-quadratic methods,
- It is highly efficient due to the Fast Fourier Transform, spline interpolation,
and a C++ backend.

For details, see the
[API documentation](https://tnagler.github.io/kde1d/).

### Prerequisites

- numpy (>=1.14)
- To install from source:
- pybind11 (>=2.4)
- setuptools (>=30.3.0)
- setuptools_scm (>=2.0.0)
- a compiler with C++11 support (Linux, OS X) or Visual Studio 2015 (required for all Python versions, see notes below)
- Eigen (the environment variable `EIGEN3_INCLUDE_DIR` must be set to the directory containing the Eigen headers)
- boost (the environment variable `Boost_INCLUDE_DIR` must be set to the directory containing the boost headers)

### Installation

The easiest way to install the latest release is to use `pip`:

```
pip install pykde1d
```

To install from source, just clone this repository and do `pip install`.
Note the `--recursive` option which is needed for the `vinecopulib` and `wdm` submodules:

```bash
git clone --recursive https://github.com/vinecopulib/pykde1d.git
pip install ./pykde1d
```

Note that Eigen and Boost need to be available on your system for the build to succeed, using the environment variables `EIGEN3_INCLUDE_DIR` and `Boost_INCLUDE_DIR` respectively.
97 changes: 0 additions & 97 deletions clang-env.txt

This file was deleted.

Binary file removed lib/boost_1_71_0.tar.gz
Binary file not shown.
1 change: 0 additions & 1 deletion lib/eigen
Submodule eigen deleted from 36b959
50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[build-system]
requires = ["setuptools>=64.0.0", "setuptools_scm>=8.0.0", "pybind11>=2.10.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "pykde1d"
dynamic = ["version"]
authors = [
{ name="Thibault Vatter", email="info@vinecopulib.com" },
{ name="Thomas Nagler", email="info@vinecopulib.com" },
]
description = "A python interface to kde1d"
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.8"
keywords = ['kernel density estimation', 'nonparametric statistics']
classifiers = [
'Development Status :: 3 - Alpha',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Programming Language :: C++',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'License :: OSI Approved :: MIT License'
]
dependencies = [
'numpy>=1.14'
]

[tool.setuptools_scm]
version_scheme = "python-simplified-semver"
local_scheme = "no-local-version"

[project.urls]
Homepage = "https://github.com/vinecopulib/pykde1d/"
Documentation = "https://vinecopulib.github.io/pykde1d"
Repository = "https://github.com/vinecopulib/pykde1d.git"
Issues = "https://github.com/vinecopulib/pykde1d/issues"

[tool.pytest.ini_options]
pythonpath = [
"src"
]

[tool.cibuildwheel]
test-requires = "pytest"
test-command = "pytest {project}/tests -r a"
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

Loading