Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various additions and improvements to the phasor module #32

Merged
merged 11 commits into from
Feb 16, 2024
31 changes: 31 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build wheels

on:
push:
tags:
- '*'
branches:
- main
# pull_request:
# branches:
# - main
workflow_dispatch:

jobs:
build:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-12, windows-2019]
steps:
- uses: actions/checkout@v4
- uses: pypa/cibuildwheel@v2.16.5
env:
CIBW_ARCHS_LINUX: auto
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_WINDOWS: AMD64 ARM64
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}
26 changes: 25 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ on:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Test library and docs
@@ -17,7 +21,8 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-20.04"]
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.12"]
# 3.11 tested with cibuildwheel
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
@@ -49,6 +54,7 @@ jobs:
matrix:
os: ["windows-2019", "macos-12"]
python-version: ["3.10"]
# 3.12 tested with cibuildwheel
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
@@ -69,6 +75,24 @@ jobs:
cd docs
make html

build_wheels:
name: Test cibuildwheel
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "windows-2019", "macos-12"]
steps:
- uses: actions/checkout@v4
- uses: pypa/cibuildwheel@v2.16.5
env:
CIBW_BUILD: "cp311-manylinux_x86_64 cp312-win_amd64 cp312-macosx_x86_64"
CIBW_SKIP:
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}

static_analysis:
name: Static code analysis
runs-on: "ubuntu-latest"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@ __pycache__/
# C extensions
*.so

# generated by Cython
_*.c

# Distribution / packaging
setup.cfg
.Python
@@ -158,6 +161,7 @@ ENV/
env.bak/
venv.bak/
phasorpy_dev
phasorpy-dev

# Spyder project settings
.spyderproject
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@
# 'image_dark': '_static/logo-dark.svg',
},
'header_links_before_dropdown': 4,
'navigation_with_keys': False,
'icon_links': [
{
'name': 'GitHub',
4 changes: 4 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -109,6 +109,10 @@ Instead of using the git command line application, you may find
Create a development environment
................................

A Python compatible C compiler is required for developing the PhasorPy
library. For example, `Visual Studio <https://visualstudio.microsoft.com/>`_,
`Xcode <https://developer.apple.com/xcode/>`_, or gcc.

To work with the PhasorPy source code, it is recommended to set up a Python
virtual environment and install all PhasorPy dependencies in it.
For example, to create a `venv <https://docs.python.org/3/library/venv.html>`_
18 changes: 11 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[build-system]
requires = [
"setuptools>=68",
"wheel",
# "numpy",
# "Cython",
"numpy",
"Cython",
]
build-backend = "setuptools.build_meta"

@@ -134,7 +133,10 @@ exclude_lines = ["pragma: no cover", "pragma: ${PY_MAJOR_VERSION} no cover"]
directory = "_htmlcov"

[tool.pytest.ini_options]
addopts = "--cov=phasorpy --cov-report html --doctest-modules --doctest-glob=*.py --doctest-glob=*.rst"
minversion = "7"
log_cli_level = "INFO"
xfail_strict = true
addopts = "-ra --strict-config --strict-markers --cov=phasorpy --cov-report html --doctest-modules --doctest-glob=*.py --doctest-glob=*.rst"
doctest_optionflags = [
"NORMALIZE_WHITESPACE",
"ELLIPSIS",
@@ -156,9 +158,11 @@ norecursedirs = [
"_htmlcov",
"tutorials",
"phasorpy.egg-info",
"phasorpy_dev",
"phasorpy-dev",
]

[tool.cibuildwheel]
skip = "cp37 cp38 cp39 pp*"
test-requires = ["pytest", "pytest-cov", "coverage"]
test-command = "pytest tests"
skip = "pp* cp37* cp38* cp39* *musllinux* *i686 *ppc64le *s390x cp39*win*arm64 cp310*win*arm64"
test-requires = ["lfdfiles", "sdtfile", "ptufile", "pytest", "pytest-cov", "pytest-runner", "pytest-doctestplus", "coverage"]
test-command = "pytest {project}/tests"
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ build
wheel
twine
packaging
# Cython
cibuildwheel
Cython
# meson-python
#
# documentation requirements
41 changes: 39 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
"""PhasorPy package Setuptools script."""

# project metadata are defined in pyproject.toml
import os
import sys

from setuptools import setup
import numpy
from setuptools import Extension, setup

setup()
DEBUG = bool(os.environ.get('PHASORPY_DEBUG', False))

if sys.platform == 'win32':
extra_compile_args = ['/openmp']
extra_link_args: list[str] = []
if DEBUG:
extra_compile_args += ['/Zi', '/Od']
extra_link_args += ['-debug:full']
elif sys.platform == 'darwin':
# OpenMP not available in Xcode
# https://mac.r-project.org/openmp/
extra_compile_args = [] # ['-Xclang', '-fopenmp']
extra_link_args = [] # ['-lomp']
else:
extra_compile_args = ['-fopenmp']
extra_link_args = ['-fopenmp']

ext_modules = [
Extension(
'phasorpy._phasor',
['src/phasorpy/_phasor.pyx'],
include_dirs=[numpy.get_include()],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
define_macros=[
# ('CYTHON_TRACE_NOGIL', '1'),
# ('CYTHON_LIMITED_API', '1'),
# ('Py_LIMITED_API', '1'),
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
],
)
]


setup(ext_modules=ext_modules)
Loading
Oops, something went wrong.