Skip to content

Commit

Permalink
Overhaul the package (#49)
Browse files Browse the repository at this point in the history
This is a major rewrite of the package for better consistency with the IRanges R/Bioconductor package.

- Using pybind11, reimplement inter-range methods to a cpp implementation using code derived from the R package.
- Better Start/End/Width resolver that is similar to the R implementation.
- Overhaul of many of the find overlaps and search methods to better align with R's expectations of how they work.
- Update docstrings, more tests.
  • Loading branch information
jkanche authored Jan 7, 2025
1 parent c03bb35 commit 7fb4f78
Show file tree
Hide file tree
Showing 30 changed files with 2,278 additions and 1,082 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build documentation

on:
push:
tags:
- "*"

jobs:
test:
name: Build docs
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install cmake pybind11 numpy tox
- name: Build docs
run: |
python setup.py build_ext --inplace
cp build/lib*/iranges/lib_iranges* src/iranges/
tox -e docs
touch ./docs/_build/html/.nojekyll
- name: GH Pages Deployment
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: ./docs/_build/html
clean: true # Automatically remove deleted files from the deploy branch
62 changes: 62 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Publish to PyPI

on:
push:
tags:
- "*"

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, higher macos's are apple silicon
# At some point, maybe get this to work on windows-latest
os: [ubuntu-latest, macos-13, macos-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build wheels
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_ARCHS_LINUX: x86_64 # remove this later so we build for all linux archs
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
CIBW_SKIP: pp*

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@v1.12.2
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
51 changes: 0 additions & 51 deletions .github/workflows/pypi-publish.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/pypi-test.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test the library

on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Get latest CMake
uses: lukka/get-cmake@latest

- name: Test with tox
run: |
pip install tox
tox
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## Version 0.4.0

This is a major rewrite of the package partly driven by performance and for better consistency with the IRanges R/Bioconductor package.

- Using pybind11, reimplement inter-range methods to a cpp implementation using code derived from the R package.
- Better Start/End/Width resolver that is similar to the R implementation.
- Overhaul of many of the find overlaps and search methods to better align with R's expectations of how these methods work.
- Update docstrings, more tests.

## Version 0.3.0

- chore: Remove Python 3.8 (EOL)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
[![PyPI-Server](https://img.shields.io/pypi/v/IRanges.svg)](https://pypi.org/project/IRanges/)
![Unit tests](https://github.com/BiocPy/IRanges/actions/workflows/pypi-test.yml/badge.svg)
![Unit tests](https://github.com/BiocPy/IRanges/actions/workflows/run-tests.yml/badge.svg)

# Integer ranges in Python

Expand Down
24 changes: 24 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.24)

project(iranges
VERSION 1.0.0
DESCRIPTION "Building the rds shared library"
LANGUAGES CXX)

find_package(pybind11 CONFIG)

# pybind11 method:
pybind11_add_module(iranges
src/coverage.cpp
src/interranges.cpp
src/init.cpp
)

set_property(TARGET iranges PROPERTY CXX_STANDARD 17)

target_link_libraries(iranges PRIVATE pybind11::pybind11)

set_target_properties(iranges PROPERTIES
OUTPUT_NAME lib_iranges
PREFIX ""
)
Loading

0 comments on commit 7fb4f78

Please sign in to comment.