Skip to content

Commit e6b28d4

Browse files
authored
Apply cookie and reorganize repository (#1)
* apply cookie cutter and reorganize * hook up versioning information correctly * conform to precommit * better matrix * no need for pypy * better dependencies and typing
1 parent 4dcdcae commit e6b28d4

26 files changed

+931
-39
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
ignore = E203, E231, E501, E722, W503, B950
3+
select = C,E,F,W,T,B,B9,I
4+
per-file-ignores =
5+
tests/*: T
6+
noxfile.py: T

.github/CONTRIBUTING.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
See the [Scikit-HEP Developer introduction][skhep-dev-intro] for a
2+
detailed description of best practices for developing Scikit-HEP packages.
3+
4+
[skhep-dev-intro]: https://scikit-hep.org/developer/intro
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 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-3.9 # Python 3.9 tests only
22+
$ nox -s docs -- serve # Build and serve the docs
23+
$ nox -s build # Make an SDist and wheel
24+
```
25+
26+
Nox handles everything for you, including setting up an temporary virtual
27+
environment for each run.
28+
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 .env
36+
source ./.env/bin/activate
37+
pip install -v -e .[all]
38+
```
39+
40+
# Post setup
41+
42+
You should prepare pre-commit, which will help you by checking that commits
43+
pass required checks:
44+
45+
```bash
46+
pip install pre-commit # or brew install pre-commit on macOS
47+
pre-commit install # Will install a pre-commit hook into the git repo
48+
```
49+
50+
You can also/alternatively run `pre-commit run` (changes only) or `pre-commit
51+
run --all-files` to check even without installing the hook.
52+
53+
# Testing
54+
55+
Use pytest to run the unit checks:
56+
57+
```bash
58+
pytest
59+
```
60+
61+
# Building docs
62+
63+
You can build the docs using:
64+
65+
```bash
66+
nox -s docs
67+
```
68+
69+
You can see a preview with:
70+
71+
```bash
72+
nox -s docs -- serve
73+
```
74+
75+
# Pre-commit
76+
77+
This project uses pre-commit for all style checking. While you can run it with nox, this is such an important tool that it deserves to be installed on its own. Install pre-commit and run:
78+
79+
```bash
80+
pre-commit run -a
81+
```
82+
83+
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: "daily"
8+
ignore:
9+
# Official actions have moving tags like v1
10+
# that are used, so they don't need updates here
11+
- dependency-name: "actions/*"

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
- main
10+
- develop
11+
release:
12+
types:
13+
- published
14+
15+
jobs:
16+
pre-commit:
17+
name: Format
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v1
21+
- uses: actions/setup-python@v2
22+
- uses: pre-commit/action@v2.0.3
23+
with:
24+
extra_args: --hook-stage manual --all-files
25+
26+
checks:
27+
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
28+
runs-on: ${{ matrix.runs-on }}
29+
needs: [pre-commit]
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
python-version: [3.6, 3.7, 3.8, 3.9]
34+
runs-on: [ubuntu-latest, macos-latest]
35+
36+
steps:
37+
- uses: actions/checkout@v2
38+
39+
- uses: actions/setup-python@v2
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
43+
- name: Install package
44+
run: python -m pip install .[test]
45+
46+
- name: Test package
47+
run: python -m pytest -ra
48+
49+
50+
dist:
51+
name: Distribution build
52+
runs-on: ubuntu-latest
53+
needs: [pre-commit]
54+
55+
steps:
56+
- uses: actions/checkout@v1
57+
58+
- name: Build sdist and wheel
59+
run: pipx run build
60+
61+
- uses: actions/upload-artifact@v2
62+
with:
63+
path: dist
64+
65+
- name: Check products
66+
run: pipx run twine check dist/*
67+
68+
- uses: pypa/gh-action-pypi-publish@v1.4.2
69+
if: github.event_name == 'release' && github.event.action == 'published'
70+
with:
71+
user: __token__
72+
# Remember to generate this and set it in "GitHub Secrets"
73+
password: ${{ secrets.pypi_password }}
74+
# Remove this line
75+
repository_url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
98+
__pypackages__/
99+
100+
# Celery stuff
101+
celerybeat-schedule
102+
celerybeat.pid
103+
104+
# SageMath parsed files
105+
*.sage.py
106+
107+
# Environments
108+
.env
109+
.venv
110+
env/
111+
venv/
112+
ENV/
113+
env.bak/
114+
venv.bak/
115+
116+
# Spyder project settings
117+
.spyderproject
118+
.spyproject
119+
120+
# Rope project settings
121+
.ropeproject
122+
123+
# mkdocs documentation
124+
/site
125+
126+
# mypy
127+
.mypy_cache/
128+
.dmypy.json
129+
dmypy.json
130+
131+
# Pyre type checker
132+
.pyre/
133+
134+
# pytype static type analyzer
135+
.pytype/
136+
137+
# Cython debug symbols
138+
cython_debug/
139+
140+
# setuptools_scm
141+
src/*/_version.py

.pre-commit-config.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 21.6b0
4+
hooks:
5+
- id: black
6+
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.0.1
9+
hooks:
10+
- id: check-added-large-files
11+
- id: check-case-conflict
12+
- id: check-merge-conflict
13+
- id: check-symlinks
14+
- id: check-yaml
15+
- id: debug-statements
16+
- id: end-of-file-fixer
17+
- id: mixed-line-ending
18+
- id: requirements-txt-fixer
19+
- id: trailing-whitespace
20+
21+
- repo: https://github.com/PyCQA/isort
22+
rev: 5.9.2
23+
hooks:
24+
- id: isort
25+
26+
- repo: https://github.com/asottile/pyupgrade
27+
rev: v2.21.0
28+
hooks:
29+
- id: pyupgrade
30+
args: ["--py36-plus"]
31+
32+
- repo: https://github.com/asottile/setup-cfg-fmt
33+
rev: v1.17.0
34+
hooks:
35+
- id: setup-cfg-fmt
36+
37+
- repo: https://github.com/pycqa/flake8
38+
rev: 3.9.2
39+
hooks:
40+
- id: flake8
41+
exclude: docs/conf.py
42+
additional_dependencies: [flake8-bugbear, flake8-print]
43+
44+
- repo: https://github.com/pre-commit/mirrors-mypy
45+
rev: v0.910
46+
hooks:
47+
- id: mypy
48+
files: src
49+
50+
- repo: https://github.com/codespell-project/codespell
51+
rev: v2.1.0
52+
hooks:
53+
- id: codespell
54+
55+
- repo: local
56+
hooks:
57+
- id: disallow-caps
58+
name: Disallow improper capitalization
59+
language: pygrep
60+
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
61+
exclude: .pre-commit-config.yaml
62+
63+
- repo: https://github.com/mgedmin/check-manifest
64+
rev: "0.46"
65+
hooks:
66+
- id: check-manifest
67+
stages: [manual]

0 commit comments

Comments
 (0)