Skip to content

Commit

Permalink
Merge pull request #160 from PJ-Watson/new_name
Browse files Browse the repository at this point in the history
Merge ``sep-pjw`` into ``main``
  • Loading branch information
PJ-Watson authored Nov 26, 2024
2 parents 0534ae5 + 57ef72b commit 120167a
Show file tree
Hide file tree
Showing 44 changed files with 6,232 additions and 4,895 deletions.
108 changes: 108 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2023 Intercreate, Inc.
# Author: J.P. Hutchins <[email protected]>
#
# Python(black)-inspired .clang-format for C repositories
#
# Includes Zephyr and Arm macro compatibility

---
BasedOnStyle: Google

AlignAfterOpenBracket: BlockIndent
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AttributeMacros:
- __aligned
- __deprecated
- __packed
- __printf_like
- __syscall
- __syscall_always_inline
- __subsystem
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: MultiLine
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BeforeLambdaBody: false
BeforeWhile: false
BitFieldColonSpacing: After
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakStringLiterals: true
ColumnLimit: 88
DerivePointerAlignment: false
ForEachMacros:
- 'FOR_EACH'
- 'FOR_EACH_FIXED_ARG'
- 'FOR_EACH_IDX'
- 'FOR_EACH_IDX_FIXED_ARG'
- 'FOR_EACH_NONEMPTY_TERM'
- 'RB_FOR_EACH'
- 'RB_FOR_EACH_CONTAINER'
- 'SYS_DLIST_FOR_EACH_CONTAINER'
- 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_DLIST_FOR_EACH_NODE'
- 'SYS_DLIST_FOR_EACH_NODE_SAFE'
- 'SYS_SFLIST_FOR_EACH_CONTAINER'
- 'SYS_SFLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_SFLIST_FOR_EACH_NODE'
- 'SYS_SFLIST_FOR_EACH_NODE_SAFE'
- 'SYS_SLIST_FOR_EACH_CONTAINER'
- 'SYS_SLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_SLIST_FOR_EACH_NODE'
- 'SYS_SLIST_FOR_EACH_NODE_SAFE'
- '_WAIT_Q_FOR_EACH'
- 'Z_FOR_EACH'
- 'Z_FOR_EACH_ENGINE'
- 'Z_FOR_EACH_EXEC'
- 'Z_FOR_EACH_FIXED_ARG'
- 'Z_FOR_EACH_FIXED_ARG_EXEC'
- 'Z_FOR_EACH_IDX'
- 'Z_FOR_EACH_IDX_EXEC'
- 'Z_FOR_EACH_IDX_FIXED_ARG'
- 'Z_FOR_EACH_IDX_FIXED_ARG_EXEC'
- 'Z_GENLIST_FOR_EACH_CONTAINER'
- 'Z_GENLIST_FOR_EACH_CONTAINER_SAFE'
- 'Z_GENLIST_FOR_EACH_NODE'
- 'Z_GENLIST_FOR_EACH_NODE_SAFE'
- 'STRUCT_SECTION_FOREACH'
- 'TYPE_SECTION_FOREACH'
IncludeBlocks: Preserve
IfMacros:
- 'CHECKIF'
IndentCaseBlocks: true
IndentCaseLabels: false
IndentWidth: 2
InsertBraces: true
MaxEmptyLinesToKeep: 2
PointerAlignment: Middle
SortIncludes: CaseSensitive
SpaceBeforeParens: ControlStatementsExceptControlMacros
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIFY
- Z_STRINGIFY
83 changes: 51 additions & 32 deletions .github/workflows/build-wheels-upload-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

name: build-wheels-upload-pypi

on:
push:
# Run this action on the trigger event when *any* tag is pushed
tags:
- '*'
on: [push, workflow_dispatch]
# push:
# # Run this action on the trigger event when *any* tag is pushed
# tags:
# - '*'

jobs:

Expand All @@ -18,7 +18,13 @@ jobs:
# The first and second job run in parallel.
# The uploading jos needs to have the other two finished without error.

# From now on, we run the tests before continuing with these jobs.

run_tests:
uses: ./.github/workflows/python-package-tox.yml

build_sdist:
needs: [run_tests]

# First the source distribution is done on ubuntu. This is not related
# to any operating system, so we could do it on the default os.
Expand All @@ -27,21 +33,24 @@ jobs:

steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: install_python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'

# For the build, sep needs numpy and cython and we add twine and wheel
# for better testing and checking.

- name: Install dependencies
run: python -m pip install twine numpy wheel cython
run: python -m pip install setuptools twine numpy wheel cython build

- name: Build sdist
run: python setup.py sdist
run: python -m build --sdist

- name: Show files
run: ls -lh dist
Expand All @@ -51,46 +60,52 @@ jobs:
run: twine check dist/*

- name: Upload sdist
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*.tar.gz

build_wheels:
needs: [run_tests]

# Second the wheels are build for different OS and python versions. This is
# done with the help of the `cibuildwheel` package.
#
# The wheels are built for Windows, Linux and MacOS and the python versions
# 3.5 - 3.10.
# 3.9 - 3.13.
#
# The three operating system could be done in parallel.

name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"

strategy:
max-parallel: 4
matrix:
python-version: [3.9]
python-version: ["3.12"]
os: [windows-latest, macos-latest, ubuntu-latest]
include:
- os: ubuntu-20.04
cibw_archs: "aarch64"

steps:
- name: setup QEMU
if: matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v1
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -101,7 +116,7 @@ jobs:
if: matrix.cibw_archs == 'aarch64'
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp3*"
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_BUILD_VERBOSITY: 1
Expand All @@ -112,7 +127,7 @@ jobs:
if: matrix.cibw_archs != 'aarch64'
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp3*"
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_BUILD_VERBOSITY: 1
Expand All @@ -124,9 +139,9 @@ jobs:
shell: bash

- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: dist
name: dist-${{ matrix.os }}
path: ./wheelhouse/*.whl

upload_to_pypi:
Expand All @@ -139,21 +154,25 @@ jobs:

runs-on: [ubuntu-latest]
needs: [build_wheels, build_sdist]
environment:
name: pypi
url: https://pypi.org/p/sep
permissions:
id-token: write

# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')

steps:
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: dist
pattern: dist*
merge-multiple: true
path: dist

- name: upload_to_pypi
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip_existing: true
uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
27 changes: 14 additions & 13 deletions .github/workflows/python-package-tox.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
# This workflow will install tox and use it to run tests.
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, workflow_call, workflow_dispatch, pull_request]

jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python: [3.5, 3.8]
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [windows-latest, macos-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install Tox and any other packages
run: pip install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Run Tox
# Run tox using the version of Python in `PATH`
run: tox -e py
# Run tox using the version of Python in `PATH`, append platform
run: tox
env:
PLATFORM: ${{ matrix.os }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sep.c

# PyCharm
.idea
.project
.project

# Eclipse
.pydevproject
Expand All @@ -54,3 +54,6 @@ sep.c

# tox
.tox

# version
*_version.py
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
exclude: "^data/"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args: [--preview]
- repo: https://github.com/numpy/numpydoc
rev: v1.8.0
hooks:
- id: numpydoc-validation
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
hooks:
- id: sphinx-lint
args: [--enable=all, --disable=default-role, --max-line-length=75, -v]
files: ^docs\/|^.*\.(rst$|md$)
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.4
hooks:
- id: clang-format
types_or: [c++, c, cuda]
Loading

0 comments on commit 120167a

Please sign in to comment.