Skip to content

Commit 1b25c1f

Browse files
endre bakken stovnerendre bakken stovner
authored andcommitted
switch to pyproject.toml
1 parent 37dd5a9 commit 1b25c1f

17 files changed

+250
-154
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and upload to PyPI
2+
3+
# Source: https://raw.githubusercontent.com/pypa/cibuildwheel/main/examples/github-deploy.yml
4+
5+
env:
6+
CIBW_SKIP: "cp36-*"
7+
8+
# Build on every branch push, tag push, and pull request change:
9+
on:
10+
workflow_dispatch:
11+
12+
jobs:
13+
build_wheels:
14+
name: Build wheels on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-20.04, windows-2019, macos-11]
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Build wheels
24+
uses: pypa/cibuildwheel@v2.12.3
25+
26+
- uses: actions/upload-artifact@v3
27+
with:
28+
path: ./wheelhouse/*.whl
29+
30+
build_sdist:
31+
name: Build source distribution
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v3
35+
36+
- name: Build sdist
37+
run: pipx run build --sdist
38+
39+
- uses: actions/upload-artifact@v3
40+
with:
41+
path: dist/*.tar.gz
42+
43+
upload_pypi:
44+
needs: [build_wheels, build_sdist]
45+
runs-on: ubuntu-latest
46+
# upload to PyPI on every tag starting with 'v'
47+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
48+
# alternatively, to publish when a GitHub Release is created, use the following rule:
49+
# if: github.event_name == 'release' && github.event.action == 'published'
50+
steps:
51+
- uses: actions/download-artifact@v3
52+
with:
53+
# unpacks default artifact into dist/
54+
# if `name: artifact` is omitted, the action will create extra parent dir
55+
name: artifact
56+
path: dist
57+
58+
- uses: pypa/gh-action-pypi-publish@v1.5.0
59+
with:
60+
user: ${{ secrets.PYPI_USER }}
61+
password: ${{ secrets.PYPI_PROD_PASSWORD }}
62+
verbose: true
63+
# To test: repository_url: https://test.pypi.org/legacy/
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Install, test, doctest, lint, typecheck ncls
2+
3+
# Source: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#using-multiple-python-versions
4+
5+
on: [pull_request, workflow_dispatch]
6+
7+
jobs:
8+
install_and_test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
# You can use PyPy versions in python-version.
12+
# For example, pypy2.7 and pypy3.9
13+
matrix:
14+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- run:
23+
pip install pytest
24+
- name: Install
25+
run: |
26+
pip install .
27+
pytest tests/*.py
28+
29+
isort:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
- name: Set up Python environment
34+
uses: actions/setup-python@v4
35+
with:
36+
python-version: "3.11"
37+
- run: pip install isort
38+
- run: isort --profile black -l 120 --check --diff ncls tests
39+
40+
black:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v3
44+
- name: Set up Python environment
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: "3.11.0"
48+
- run: pip install black
49+
- run: black -l 120 --check --diff ncls tests
50+
51+
flake8:
52+
runs-on: ubuntu-latest
53+
name: Lint
54+
steps:
55+
- name: Check out source repository
56+
uses: actions/checkout@v3
57+
- name: Set up Python environment
58+
uses: actions/setup-python@v4
59+
- name: flake8 Lint install
60+
run: pip install flake8
61+
- name: flake8 Lint
62+
run: flake8 --max-line-length=120 --ignore E203,E501,W503 ncls tests
63+
64+
mypy:
65+
runs-on: ubuntu-latest
66+
name: Mypy
67+
steps:
68+
- name: Check out source repository
69+
uses: actions/checkout@v3
70+
- name: Set up Python environment
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: "3.11"
74+
- name: Install mypy
75+
run: pip install mypy
76+
- name: mypy
77+
run: |
78+
pip install numpy # for the typing stubs
79+
python -m pip install pandas-stubs types-setuptools
80+
mypy ncls

CHANGELOG

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
<<<<<<< HEAD
21
# 0.0.67/68 (12.05.23)
32
- Remove .c files that should be regenerated (@starsareintherose)
4-
=======
5-
# 0.0.67 (12.05.23)
6-
- Remove .c files that should be regenerated
7-
>>>>>>> 6f7f5f27f2d9117ce9dfab58edee183a04da135a
83

94
# 0.0.66 (09.01.23)
105
- fix more deprecated stuff

examples/test_all_overlaps_both.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
3-
41
from ncls import NCLS
52

63
import pickle

examples/test_find_overlap_list.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
2-
3-
41
from ncls import NCLS
52

63
import pickle

examples/test_fncls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from ncls import FNCLS
22
import numpy as np
3+
34
np.random.seed(0)
45

56
import pandas as pd
7+
68
size = int(1e4)
79

810
starts = np.random.randint(0, high=int(1e6), size=size) + np.random.random()

ncls/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
from ncls.src.ncls import NCLS64
2-
from ncls.src.ncls32 import NCLS32
3-
41
import numpy as np
2+
import pkg_resources
3+
4+
__version__ = pkg_resources.get_distribution("ncls").version
5+
6+
from ncls.src.ncls import NCLS64 # type: ignore
7+
from ncls.src.ncls32 import NCLS32 # type: ignore
58

6-
def NCLS(starts, ends, ids):
79

10+
def NCLS(starts, ends, ids):
811
if isinstance(starts, list) or "pandas" in str(type(starts)):
912
starts, ends, ids = [np.array(s) for s in [starts, ends, ids]]
1013

@@ -18,8 +21,7 @@ def NCLS(starts, ends, ids):
1821

1922

2023
def FNCLS(starts, ends, ids):
21-
22-
from ncls.src.fncls import FNCLS
24+
from ncls.src.fncls import FNCLS # type: ignore
2325

2426
if isinstance(starts, list) or "pandas" in str(type(starts)):
2527
starts, ends, ids = [np.array(s) for s in [starts, ends, ids]]
@@ -28,5 +30,3 @@ def FNCLS(starts, ends, ids):
2830
return FNCLS(starts, ends.astype(np.double), ids)
2931
else:
3032
raise Exception("Starts/Ends not double: " + str(starts.dtype))
31-
32-
from ncls.version import __version__

ncls/src/cncls32.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
from libc.stdint cimport int32_t, int64_t
33

4+
45
cdef extern from "stdlib.h":
56
void free(void *)
67
void *malloc(size_t)

ncls/src/fncls.pyx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
cimport ncls.src.cfncls as cn
2-
31
cimport cython
4-
52
from libc.stdint cimport int64_t
3+
from libc.stdlib cimport malloc
64

5+
cimport ncls.src.cfncls as cn
76
cimport ncls.src.cncls as cn
87

9-
from libc.stdlib cimport malloc
108
import numpy as np
119

10+
1211
cdef inline int int_max(int a, int b): return a if a >= b else b
1312
cdef inline int int_min(int a, int b): return a if a <= b else b
1413
# import ctypes as c

ncls/src/ncls.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# import numpy as cnp
22
import sys
33

4-
54
cimport cython
6-
75
from libc.stdint cimport int64_t
6+
from libc.stdlib cimport malloc
87

98
cimport ncls.src.cncls as cn
109

11-
from libc.stdlib cimport malloc
1210
import numpy as np
1311

12+
1413
cdef inline int int_max(int a, int b): return a if a >= b else b
1514
cdef inline int int_min(int a, int b): return a if a <= b else b
1615
# import ctypes as c

0 commit comments

Comments
 (0)