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: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- run: |
python -m pip install --upgrade pip hatch
pip install -e .[dev]
hatch run test
python -m pip install --upgrade pip
pip install --group test -e .
pytest
32 changes: 8 additions & 24 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,13 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2
build:
os: ubuntu-22.04
os: ubuntu-24.04
tools:
python: "3.10"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
# setup_py_install: true
python:
install:
- method: pip
path: .
extra_requirements:
- dev
- docs
python: "3.13"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv sync --group dev
- uv run python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
47 changes: 14 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,81 +20,62 @@ This project has a number of requirements for all code contributed.

## Setting up Your Development Environment

This project uses the [hatch](https://hatch.pypa.io/latest/) project manager and build system. We recommend you install `hatch` as a global isolated application using [pipx](https://pipx.pypa.io/stable/). See other installation options [here](https://hatch.pypa.io/latest/install/).
This project uses the [uv](https://docs.astral.sh/uv/) project manager and [uv_build](https://docs.astral.sh/uv/concepts/build-backend/) build backend.

```sh
pipx install hatch
```

> [!NOTE]
> Many custom command shortcuts are accessible through hatch (and shown below). See `tool.hatch.envs.default.scripts` in our project's `pyproject.toml` configuration file.

After forking and cloning the repository, you can create an isolated Python development environment and install the package in "editable" (i.e. development) mode as follows:
To set up your dev environment, run:

```sh
git clone https://github.com/open2c/bioframe.git
cd bioframe
hatch shell
uv sync
```

The first time you run `hatch shell` the environment will be created and activated, and the package will be installed. In future sessions, running `hatch shell` will reactivate your development environment.

> [!TIP]
> If you prefer to store your virtual environments in your working directory (like classic virtualenvs) rather than in a centralized location (similar to conda), configure hatch as follows:
>
> ```sh
> hatch config set dirs.env.virtual .venv
> ```
>
> This will make hatch set up its environments within the current working directory under `.venv`.
This command will include the requirements from the `dev` [dependency group](https://peps.python.org/pep-0735/) by default, which includes dependencies for development, testing, and documentation.

Alternatively, if you prefer to manage your virtual environments yourself, you can install the package for development using, for example:

```sh
python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev,test,docs]'
pip install --group dev -e .
```

For all pull requests, linting and unit tests are automatically run using the [GitHub Actions](https://docs.github.com/en/actions) Continuous Integration service. However, you are still encouraged to run these checks locally before pushing code to a PR.

## Linting and Formatting

We use [ruff](https://docs.astral.sh/ruff/) for style checking. Run `ruff check .` or:
We use [ruff](https://docs.astral.sh/ruff/) for style checking.

```sh
hatch run lint
uv run ruff check
```

Ruff can fix a lot of errors itself. Run `ruff check --fix .` or:
Ruff can fix a lot of errors itself.

```sh
hatch run fix
uv run ruff check --fix
```

Ruff includes a formatter that mimics [black](https://black.readthedocs.io/en/stable/). To automatically reformat your code, you can use `ruff format {source_file}`.

We use [pre-commit](https://github.com/pre-commit/pre-commit) to make sure the coding style is enforced. You first need to install pre-commit and the corresponding git commit hooks:

```sh
pip install pre-commit
pre-commit install
uv run pre-commit install
```

The last command installs the hooks listed in `.pre-commit-config.yaml` locally into your git repo. If you do this, the checks will run automatically before every commit. You can also manually make sure your code satisfies the coding style:

```sh
pre-commit run --all-files
uv run pre-commit run --all-files
```

## Testing

It is best if all new functionality and/or bug fixes have unit tests added with each use-case.

We use [pytest](https://docs.pytest.org/en/latest) as our unit testing framework. Once you've configured your environment, you can just `cd` to the root of your repository and run `pytest` or:
We use [pytest](https://docs.pytest.org/en/latest) as our unit testing framework. Once you've configured your environment, you can just `cd` to the root of your repository and run:

```sh
hatch run test
uv run pytest
```

## Documentation
Expand All @@ -108,7 +89,7 @@ We use the [Sphinx Autosummary extension](http://www.sphinx-doc.org/en/stable/ex
To build the documentation, run `sphinx-autobuild` using:

```sh
hatch run docs
uv run sphinx-autobuild docs docs/_build/html
```

This will build the documentation and serve it on a local http server which listens for changes and automatically rebuilds.
Expand Down
43 changes: 27 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
from datetime import datetime
from importlib.metadata import metadata

# autodoc_mock_imports = ["numpy", "pandas", "matplotlib", "requests"]


# -- Project information -----------------------------------------------------
# NOTE: If you installed your project in editable mode, this might be stale.
# If this is the case, reinstall it to refresh the metadata
info = metadata("bioframe")
project_name = info["Name"]
project = info["Name"]
author = "Open2C"
copyright = f"{datetime.now():%Y}, {author}."
version = info["Version"]
Expand All @@ -31,25 +28,35 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
# "sphinx.ext.autodoc",
# 'sphinx.ext.doctest',
# 'sphinx.ext.todo',
# 'sphinx.ext.coverage',
# 'sphinx.ext.mathjax',
# 'sphinx.ext.ifconfig',
"autodocsumm",
"sphinx.ext.viewcode",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon", # 'numpydoc'
# "myst_parser",
"myst_nb",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx_autodoc_typehints",
"sphinx_copybutton",
]

source_suffix = [".rst", ".md"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
exclude_patterns = [
"_build",
"**.ipynb_checkpoints",
"Thumbs.db",
".DS_Store",
".env",
".venv",
]

# nbsphinx_custom_formats = {
# '.md': ['jupytext.reads', {'fmt': 'MyST'}],
Expand All @@ -75,5 +82,9 @@
add_module_names = False

# Cache MyST (.md or .ipynb) notebook outputs if unmodified
jupyter_execute_notebooks = "cache"
execution_excludepatterns = ["guide-performance.ipynb"]
nb_execution_mode = "cache"
nb_execution_excludepatterns = ["guide-performance.ipynb"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}
65 changes: 25 additions & 40 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
requires = ["uv_build>=0.7.19"]
build-backend = "uv_build"

[project]
name = "bioframe"
Expand Down Expand Up @@ -33,6 +33,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -47,35 +48,38 @@ dependencies = [
"importlib-resources ; python_version<'3.9'",
]

[project.optional-dependencies]
dev = [
[dependency-groups]
test = [
"pytest>=6.0",
"biopython",
"pre-commit",
"pysam",
"pybbi",
"pytest",
"ruff",
]
test = [
"pytest",
]
docs = [
"autodocsumm",
"myst_nb",
"jinja2",
"Sphinx",
"myst_parser",
"sphinx >=4.0",
"sphinx-autobuild",
"sphinx_rtd_theme",
"sphinx-copybutton",
"sphinx-autodoc-typehints",
]
dev = [
{ include-group = "test" },
{ include-group = "docs" },
"pre-commit",
"ruff",
]

[project.urls]
homepage = "https://github.com/open2c/bioframe"
documentation = "https://bioframe.readthedocs.io/en/latest"
repository = "https://github.com/open2c/bioframe"
documentation = "https://bioframe.readthedocs.io"
source = "https://github.com/open2c/bioframe"
issues = "https://github.com/open2c/bioframe/issues"
changelog = "https://github.com/open2c/bioframe/blob/main/CHANGES.md"

[tool.ruff]
target-version = "py37"
exclude = [
".venv",
]
Expand All @@ -100,30 +104,11 @@ known-first-party = ["bioframe"]
convention = "numpy"

[tool.pytest.ini_options]
minversion = "7"
log_cli_level = "info"
minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
addopts = [
"-ra",
"--showlocals",
"--strict-config",
"--strict-markers",
filterwarnings = ["error"]
log_level = "INFO"
testpaths = [
"tests",
]
filterwarnings = ["ignore::PendingDeprecationWarning"]
testpaths = ["tests"]

[tool.hatch.envs.default]
features = ["dev", "test", "docs"]

[tool.hatch.envs.default.scripts]
fix = "ruff check --fix ."
lint = "ruff check bioframe tests"
format = "ruff format bioframe tests"
test = "pytest ."
docs = "sphinx-autobuild docs docs/_build/html"

[tool.hatch.envs.test]
features = ["dev", "test"]

[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]
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.
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.
File renamed without changes.
File renamed without changes.
Loading