Skip to content

Commit 1becd6a

Browse files
committed
boilerplate
0 parents  commit 1becd6a

File tree

18 files changed

+392
-0
lines changed

18 files changed

+392
-0
lines changed

.darglint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[darglint]
2+
3+
docstring_style=google

.env

Whitespace-only changes.

.github/workflows/publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish Python Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
concurrency:
13+
group: "publish"
14+
cancel-in-progress: true
15+
16+
jobs:
17+
publish:
18+
timeout-minutes: 10
19+
name: Build and publish
20+
21+
# We don't need to run on all platforms since this package is
22+
# platform-agnostic. The output wheel is something like
23+
# "monotonic_attention-<version>-py3-none-any.whl".
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: "3.10"
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install build wheel
39+
40+
- name: Build package
41+
run: python -m build --sdist --wheel --outdir dist/ .
42+
43+
- name: Publish package
44+
uses: pypa/gh-action-pypi-publish@release/v1
45+
# with:
46+
# user: __token__
47+
# password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Python Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
types:
11+
- opened
12+
- reopened
13+
- synchronize
14+
- ready_for_review
15+
16+
concurrency:
17+
group: tests-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
run-base-tests:
22+
timeout-minutes: 10
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Check out repository
26+
uses: actions/checkout@v3
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: "3.11"
32+
33+
- name: Restore cache
34+
id: restore-cache
35+
uses: actions/cache/restore@v3
36+
with:
37+
path: |
38+
${{ env.pythonLocation }}
39+
.mypy_cache/
40+
key: python-requirements-${{ env.pythonLocation }}-${{ github.event.pull_request.base.sha || github.sha }}
41+
restore-keys: |
42+
python-requirements-${{ env.pythonLocation }}
43+
python-requirements-
44+
45+
- name: Install package
46+
run: |
47+
pip install --upgrade --upgrade-strategy eager --extra-index-url https://download.pytorch.org/whl/cpu -e '.[dev]'
48+
49+
- name: Run static checks
50+
run: |
51+
mkdir -p .mypy_cache
52+
make static-checks
53+
54+
- name: Run unit tests
55+
run: |
56+
make test
57+
58+
- name: Save cache
59+
uses: actions/cache/save@v3
60+
if: github.ref == 'refs/heads/master'
61+
with:
62+
path: |
63+
${{ env.pythonLocation }}
64+
.mypy_cache/
65+
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# .gitignore
2+
3+
# Python
4+
*.py[oc]
5+
__pycache__/
6+
*.egg-info
7+
.eggs/
8+
.mypy_cache/*
9+
.pyre/
10+
.pytest_cache/
11+
.ruff_cache/
12+
.dmypy.json
13+
14+
# Databases
15+
*.db
16+
17+
# Build artifacts
18+
build/
19+
dist/
20+
*.so
21+
out*/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 OpenLCH Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include openlch/ *.py *.txt py.typed MANIFEST.in

Makefile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Makefile
2+
3+
define HELP_MESSAGE
4+
openlch
5+
6+
# Installing
7+
8+
1. Create a new Conda environment: `conda create --name openlch python=3.11`
9+
2. Activate the environment: `conda activate openlch`
10+
3. Install the package: `make install-dev`
11+
12+
# Running Tests
13+
14+
1. Run autoformatting: `make format`
15+
2. Run static checks: `make static-checks`
16+
3. Run unit tests: `make test`
17+
18+
endef
19+
export HELP_MESSAGE
20+
21+
all:
22+
@echo "$$HELP_MESSAGE"
23+
.PHONY: all
24+
25+
# ------------------------ #
26+
# Build #
27+
# ------------------------ #
28+
29+
install:
30+
@pip install --verbose -e .
31+
.PHONY: install
32+
33+
install-dev:
34+
@pip install --verbose -e '.[dev]'
35+
.PHONY: install
36+
37+
build-ext:
38+
@python setup.py build_ext --inplace
39+
.PHONY: build-ext
40+
41+
clean:
42+
rm -rf build dist *.so **/*.so **/*.pyi **/*.pyc **/*.pyd **/*.pyo **/__pycache__ *.egg-info .eggs/ .ruff_cache/
43+
.PHONY: clean
44+
45+
# ------------------------ #
46+
# Static Checks #
47+
# ------------------------ #
48+
49+
py-files := $(shell find . -name '*.py')
50+
51+
format:
52+
@black $(py-files)
53+
@ruff format $(py-files)
54+
.PHONY: format
55+
56+
format-cpp:
57+
@clang-format -i $(shell find . -name '*.cpp' -o -name '*.h')
58+
@cmake-format -i $(shell find . -name 'CMakeLists.txt' -o -name '*.cmake')
59+
.PHONY: format-cpp
60+
61+
static-checks:
62+
@black --diff --check $(py-files)
63+
@ruff check $(py-files)
64+
@mypy --install-types --non-interactive $(py-files)
65+
.PHONY: lint
66+
67+
mypy-daemon:
68+
@dmypy run -- $(py-files)
69+
.PHONY: mypy-daemon
70+
71+
# ------------------------ #
72+
# Unit tests #
73+
# ------------------------ #
74+
75+
test:
76+
python -m pytest
77+
.PHONY: test

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# openlch

openlch/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.1"

0 commit comments

Comments
 (0)