Skip to content

Commit d234d54

Browse files
Saransh-cpplgray
andcommitted
Initial commit
Co-authored-by: lgray <[email protected]>
0 parents  commit d234d54

23 files changed

+4449
-0
lines changed

.git_archival.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
4+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/CONTRIBUTING.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
See the [Scientific Python Developer Guide][spc-dev-intro] for a detailed
2+
description of best practices for developing scientific packages.
3+
4+
[spc-dev-intro]: https://learn.scientific-python.org/development/
5+
6+
# Quick development
7+
8+
The fastest way to start with development is to use nox. If you don't have nox,
9+
you can use `pipx run nox` to run it without installing, or `pipx install nox`.
10+
If you don't have pipx (pip for applications), then you can install with
11+
`pip install pipx` (the only case were installing an application with regular
12+
pip is reasonable). If you use macOS, then pipx and nox are both in brew, use
13+
`brew install pipx nox`.
14+
15+
To use, run `nox`. This will lint and test using every installed version of
16+
Python on your system, skipping ones that are not installed. You can also run
17+
specific jobs:
18+
19+
```console
20+
$ nox -s lint # Lint only
21+
$ nox -s tests # Python tests
22+
$ nox -s coverage # Python tests and coverage report
23+
$ nox -s docs -- --serve # Build and serve the docs
24+
$ nox -s build # Make an SDist and wheel
25+
```
26+
27+
Nox handles everything for you, including setting up an temporary virtual
28+
environment for each run.
29+
30+
# Setting up a development environment manually
31+
32+
You can set up a development environment by running:
33+
34+
```bash
35+
python3 -m venv .venv
36+
source ./.venv/bin/activate
37+
pip install -v -e .[dev]
38+
```
39+
40+
If you have the
41+
[Python Launcher for Unix](https://github.com/brettcannon/python-launcher), you
42+
can instead do:
43+
44+
```bash
45+
py -m venv .venv
46+
py -m install -v -e .[dev]
47+
```
48+
49+
# Post setup
50+
51+
You should prepare pre-commit, which will help you by checking that commits pass
52+
required checks:
53+
54+
```bash
55+
pip install pre-commit # or brew install pre-commit on macOS
56+
pre-commit install # Will install a pre-commit hook into the git repo
57+
```
58+
59+
You can also/alternatively run `pre-commit run` (changes only) or
60+
`pre-commit run --all-files` to check even without installing the hook.
61+
62+
# Testing
63+
64+
Use pytest to run the unit checks:
65+
66+
```bash
67+
pytest
68+
```
69+
70+
# Coverage
71+
72+
Use pytest-cov to generate coverage reports:
73+
74+
```bash
75+
pytest --cov=cuda-histogram
76+
```
77+
78+
# Building docs
79+
80+
You can build the docs using:
81+
82+
```bash
83+
nox -s docs
84+
```
85+
86+
You can see a preview with:
87+
88+
```bash
89+
nox -s docs -- --serve
90+
```
91+
92+
# Pre-commit
93+
94+
This project uses pre-commit for all style checking. While you can run it with
95+
nox, this is such an important tool that it deserves to be installed on its own.
96+
Install pre-commit and run:
97+
98+
```bash
99+
pre-commit run -a
100+
```
101+
102+
to check all files.

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"

.github/matchers/pylint.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"severity": "warning",
5+
"pattern": [
6+
{
7+
"regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"code": 4,
12+
"message": 5
13+
}
14+
],
15+
"owner": "pylint-warning"
16+
},
17+
{
18+
"severity": "error",
19+
"pattern": [
20+
{
21+
"regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
22+
"file": 1,
23+
"line": 2,
24+
"column": 3,
25+
"code": 4,
26+
"message": 5
27+
}
28+
],
29+
"owner": "pylint-error"
30+
}
31+
]
32+
}

.github/workflows/cd.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CD
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
release:
10+
types:
11+
- published
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
# Many color libraries just need this to be set to any value, but at least
19+
# one distinguishes color depth, where "3" -> "256-bit color".
20+
FORCE_COLOR: 3
21+
22+
jobs:
23+
dist:
24+
name: Distribution build
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Generate artifact attestation for sdist and wheel
33+
uses: actions/attest-build-provenance@bdd51370e0416ac948727f861e03c2f05d32d78e # v1.3.2
34+
with:
35+
subject-path: "dist/cuda-histogram-*"
36+
37+
- uses: hynek/build-and-inspect-python-package@v2
38+
39+
publish:
40+
needs: [dist]
41+
name: Publish to PyPI
42+
environment:
43+
name: pypi
44+
url: https://pypi.org/p/cuda-histogram
45+
permissions:
46+
id-token: write
47+
runs-on: ubuntu-latest
48+
if: github.event_name == 'release' && github.event.action == 'published'
49+
50+
steps:
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: Packages
54+
path: dist
55+
56+
- name: List distributions to be deployed
57+
run: ls -l dist/
58+
59+
- name: Verify sdist artifact attestation
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run:
63+
gh attestation verify dist/cuda-histogram-*.tar.gz --repo ${{
64+
github.repository }}
65+
66+
- name: Verify wheel artifact attestation
67+
env:
68+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
run:
70+
gh attestation verify dist/cuda-histogram-*.whl --repo ${{
71+
github.repository }}
72+
73+
- uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
# Many color libraries just need this to be set to any value, but at least
16+
# one distinguishes color depth, where "3" -> "256-bit color".
17+
FORCE_COLOR: 3
18+
19+
jobs:
20+
pre-commit:
21+
name: Format
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.x"
30+
- uses: pre-commit/[email protected]
31+
with:
32+
extra_args: --hook-stage manual --all-files
33+
- name: Run PyLint
34+
run: |
35+
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
36+
pipx run nox -s pylint
37+
38+
checks:
39+
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
40+
runs-on: ${{ matrix.runs-on }}
41+
needs: [pre-commit]
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
46+
runs-on: [ubuntu-latest, macos-latest, windows-latest]
47+
48+
include:
49+
- python-version: pypy-3.10
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 0
56+
57+
- uses: actions/setup-python@v5
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
allow-prereleases: true
61+
62+
- name: Test package and generate coverage report
63+
run:
64+
pipx run nox -s coverage-${{ matrix.python-version.key ||
65+
matrix.python-version }} --verbose
66+
67+
- name: Upload coverage report
68+
uses: codecov/[email protected]
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)