Skip to content

Commit 6617244

Browse files
authored
Library (#1)
* first commit * base method * cleanup * add tests * add depends * workflows * add depends * add diagram
1 parent ca2be9f commit 6617244

29 files changed

+1912
-0
lines changed

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Package release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
8+
jobs:
9+
deploy_osx:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
python-version: ["3.7", "3.8", "3.9", "3.10"]
14+
os: [macos-latest]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
submodules: true
20+
- name: Set up Python
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Build and publish
25+
env:
26+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
27+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
28+
run: ${GITHUB_WORKSPACE}/.github/workflows/scripts/release_osx.sh
29+
30+
deploy_linux:
31+
strategy:
32+
matrix:
33+
python-version:
34+
- cp37-cp37m
35+
- cp38-cp38
36+
- cp39-cp39
37+
- cp10-cp10
38+
39+
runs-on: ubuntu-latest
40+
container: quay.io/pypa/manylinux2014_x86_64
41+
steps:
42+
- uses: actions/checkout@v1
43+
with:
44+
submodules: true
45+
- name: Set target Python version PATH
46+
run: |
47+
echo "/opt/python/${{ matrix.python-version }}/bin" >> $GITHUB_PATH
48+
- name: Build and publish
49+
env:
50+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
51+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
52+
run: ${GITHUB_WORKSPACE}/.github/workflows/scripts/release_linux.sh
53+
54+
deploy_windows:
55+
runs-on: windows-latest
56+
strategy:
57+
matrix:
58+
python-version: ["3.7", "3.8", "3.9", "3.10"]
59+
60+
steps:
61+
- uses: actions/checkout@v2
62+
with:
63+
submodules: true
64+
- name: Set up Python ${{ matrix.python-version }}
65+
uses: actions/setup-python@v1
66+
with:
67+
python-version: ${{ matrix.python-version }}
68+
- name: Build and publish
69+
env:
70+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
71+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
72+
run: |
73+
../../.github/workflows/scripts/release_windows.bat
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
yum makecache -y
6+
yum install centos-release-scl -y
7+
yum-config-manager --enable rhel-server-rhscl-7-rpms
8+
yum install llvm-toolset-7.0 python3 python3-devel -y
9+
10+
# Python
11+
python3 -m pip install --upgrade pip
12+
python3 -m pip install setuptools wheel twine auditwheel
13+
14+
# Publish
15+
python3 -m pip wheel . -w dist/ --no-deps
16+
twine upload --verbose --skip-existing dist/*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
export MACOSX_DEPLOYMENT_TARGET=10.14
4+
5+
python -m pip install --upgrade pip
6+
pip install setuptools wheel twine auditwheel
7+
8+
python3 setup.py build bdist_wheel --plat-name macosx_10_14_x86_64 --dist-dir wheel
9+
twine upload --skip-existing wheel/*
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
echo on
2+
3+
python -m pip install --upgrade pip
4+
pip install setuptools wheel twine auditwheel
5+
6+
pip wheel . -w wheel/ --no-deps
7+
twine upload --skip-existing wheel/*

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main, release]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
schedule:
9+
- cron: '0 0 * * 0'
10+
11+
12+
jobs:
13+
Linter:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
python-version: [3.8]
18+
os: [ubuntu-latest]
19+
steps:
20+
- uses: actions/checkout@v2
21+
with:
22+
submodules: true
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v1
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: pip install .[testing]
29+
- name: pre-commit validation
30+
run: pre-commit run --files src/*
31+
- name: Security checks
32+
run: |
33+
bandit -r src/*
34+
35+
Library:
36+
needs: [Linter]
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
matrix:
40+
python-version: ['3.7', '3.8', '3.9', "3.10"]
41+
os: [macos-latest, ubuntu-latest, windows-latest]
42+
steps:
43+
- uses: actions/checkout@v2
44+
with:
45+
submodules: true
46+
- name: Set up Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@v1
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
- name: Install MacOS dependencies
51+
run: |
52+
brew install libomp
53+
if: ${{ matrix.os == 'macos-latest' }}
54+
- name: Install dependencies
55+
run: |
56+
pip install .[testing]
57+
- name: Test with pytest
58+
run: pytest -vvvsx -m "not slow"

.isort.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[settings]
2+
profile = black
3+
multi_line_output = 3
4+
include_trailing_comma = True
5+
force_grid_wrap = 0
6+
use_parentheses = True
7+
line_length = 88

.pre-commit-config.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
exclude: 'setup.py|^docs|^experiments|^tests'
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: check-added-large-files
9+
- id: check-ast
10+
- id: check-json
11+
- id: check-merge-conflict
12+
- id: check-xml
13+
- id: check-yaml
14+
- id: debug-statements
15+
- id: check-executables-have-shebangs
16+
- id: end-of-file-fixer
17+
- id: requirements-txt-fixer
18+
- id: mixed-line-ending
19+
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows
20+
21+
- repo: https://github.com/pycqa/isort
22+
rev: 5.8.0
23+
hooks:
24+
- id: isort
25+
26+
- repo: https://github.com/psf/black
27+
rev: 22.3.0
28+
hooks:
29+
- id: black
30+
language_version: python3
31+
- repo: https://gitlab.com/pycqa/flake8
32+
rev: 3.9.1
33+
hooks:
34+
- id: flake8
35+
args: [
36+
"--max-line-length=400",
37+
"--extend-ignore=E203,W503"
38+
]
39+
- repo: local
40+
hooks:
41+
- id: flynt
42+
name: flynt
43+
entry: flynt
44+
args: [--fail-on-change]
45+
types: [python]
46+
language: python
47+
additional_dependencies:
48+
- flynt

docs/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
AUTODOCDIR = api
11+
12+
# User-friendly check for sphinx-build
13+
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $?), 1)
14+
$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from https://sphinx-doc.org/")
15+
endif
16+
17+
.PHONY: help clean Makefile
18+
19+
# Put it first so that "make" without argument is like "make help".
20+
help:
21+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
22+
23+
clean:
24+
rm -rf $(BUILDDIR)/* $(AUTODOCDIR)
25+
26+
# Catch-all target: route all unknown targets to Sphinx using the new
27+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
28+
%: Makefile
29+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/_static/.gitignore

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

docs/arch.png

94.1 KB
Loading

docs/authors.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. _authors:
2+
.. include:: ../AUTHORS.rst

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. _changes:
2+
.. include:: ../CHANGELOG.rst

0 commit comments

Comments
 (0)