Skip to content

Commit 4406965

Browse files
committed
Make: NumBa is now optional
1 parent 289df9f commit 4406965

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ pytest test.py -s -x
1010
Alternatively, consider using `uv`:
1111

1212
```sh
13-
uv venv --python 3.12 # Or your preferred Python version
14-
source .venv/bin/activate # To activate the virtual environment
15-
uv pip install ".[dev]" # To install the package and development dependencies
16-
uv run pytest -ra -q test.py # To run the tests
13+
uv venv --python 3.12 # Or your preferred Python version
14+
source .venv/bin/activate # To activate the virtual environment
15+
uv pip install ".[dev]" # To install the package and development dependencies
16+
uv run pytest -ra -q test.py # To run the tests
1717
```
1818

1919
### Symmetry Test for Needleman-Wunsch

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ During my exploration of exiting implementations, I've noticed several bugs:
3030

3131
## Installation
3232

33-
Even without installing Python, you can just use `uv` to get the latest version of the library:
33+
Numba is optional.
34+
Installing without it gives a pure-Python baseline; installing with the `numba` extra enables JIT acceleration when a compatible Numba is available.
3435

35-
```bash
36-
$ uv tool install git+https://github.com/ashvardanian/affine-gaps.git
37-
$ affine-gaps --help
36+
```sh
37+
uv pip install affine-gaps # minimal
38+
uv pip install 'affine-gaps[numba]' # with JIT
3839
```
3940

40-
Alternatively, you can install it using `pip`:
41+
Even without installing Python or touching PyPi, you can just use `uv` to get the latest version of the library:
4142

4243
```bash
43-
$ pip install git+https://github.com/ashvardanian/affine-gaps.git
44+
$ uv tool install git+https://github.com/ashvardanian/affine-gaps.git
4445
$ affine-gaps --help
4546
```
4647

affine_gaps.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
from typing import Tuple, Optional, Callable
22

33
import numpy as np
4-
import numba as nb
4+
5+
# Numba is optional: provide a no-op fallback for the decorator
6+
try:
7+
import numba as nb # type: ignore
8+
except Exception: # pragma: no cover - fallback when Numba isn't available
9+
class _NoNumba:
10+
def jit(self, *args, **kwargs):
11+
def _decorator(fn):
12+
return fn
13+
14+
return _decorator
15+
16+
nb = _NoNumba() # type: ignore
17+
518
from colorama import Fore, Style
619
from colorama import init as _colorama_init
720

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors = [
1111
{ name = "Ash Vardanian", email = "1983160+ashvardanian@users.noreply.github.com" },
1212
]
1313
requires-python = ">=3.6"
14-
dependencies = ["numba", "numpy", "colorama"]
14+
dependencies = ["numpy", "colorama"]
1515
keywords = ["bioinformatics", "sequence alignment", "numba", "affine gaps"]
1616
classifiers = [
1717
"Programming Language :: Python :: 3",
@@ -21,6 +21,7 @@ classifiers = [
2121

2222
[project.optional-dependencies]
2323
dev = ["biopython", "stringzilla", "pytest", "pytest-repeat"]
24+
numba = ["numba"]
2425

2526
[tool.pytest.ini_options]
2627
addopts = "-s -x"

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
long_description_content_type="text/markdown",
1111
url="https://github.com/ashvardanian/affine-gaps",
1212
py_modules=["affine_gaps"],
13-
install_requires=["numba", "numpy", "colorama"],
13+
install_requires=["numpy", "colorama"],
1414
classifiers=[
1515
"Programming Language :: Python :: 3",
1616
"License :: OSI Approved :: Apache Software License",
1717
"Operating System :: OS Independent",
1818
],
1919
python_requires=">=3.6",
20-
extras_require={"dev": ["biopython", "stringzilla", "pytest", "pytest-repeat"]},
20+
extras_require={
21+
"dev": ["biopython", "stringzilla", "pytest", "pytest-repeat"],
22+
"numba": ["numba"],
23+
},
2124
entry_points={
2225
"console_scripts": [
2326
"affine-gaps=affine_gaps:main",

0 commit comments

Comments
 (0)