Skip to content

Commit

Permalink
Bring code up to modern standards (#142)
Browse files Browse the repository at this point in the history
  * Reorganize code into subdirectories
  * Remove old disused CI stuff
  * Add Github Actions integration
  * Add pyproject.toml
  * With pyproject, pep 517/8 simplifies the setup file dramatically
  • Loading branch information
moble authored Aug 25, 2020
1 parent 9991312 commit 35f83be
Show file tree
Hide file tree
Showing 22 changed files with 181 additions and 171 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: build

on: [push, pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]

env:
CIBW_SKIP: cp27-* cp35-* pp27-* pp36-*
CIBW_BEFORE_BUILD: python -c "print(('#'*140+'\n')*10)" && pip install "numpy>=1.13"
CIBW_TEST_REQUIRES: pytest pytest-cov
CIBW_TEST_COMMAND: "pytest {project}/test"

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'

- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel
- name: Install Visual C++ for Python 2.7
if: runner.os == 'Windows'
run: |
choco install vcpython27 -f -y
- name: Build wheels
run: |
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl


build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'

- name: Build sdist
run: |
python -m pip install numpy>=1.13 # Can't rely on pep 517 to get it from pyproject.toml
python setup.py sdist
- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz


upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: "github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, '[no release]')"
# # upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
# # publish when a GitHub Release is created
# if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
# To test: repository_url: https://test.pypi.org/legacy/
5 changes: 3 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
version: 2

python:
version: 3.7
version: 3.8
system_packages: true
install:
- method: pip
path: .
- requirements: requirements-doc.txt
extra_requirements:
- docs

# The only extra format to build is PDF
formats: [pdf]
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include README.txt LICENSE
include numpy_quaternion.c quaternion.c quaternion.h math_msvc_compatibility.h
include README.md LICENSE
include src/numpy_quaternion.c src/quaternion.c src.quaternion.h src/math_msvc_compatibility.h
4 changes: 0 additions & 4 deletions README.txt

This file was deleted.

12 changes: 3 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,14 @@

# -- Project information -----------------------------------------------------

try:
sys.path.insert(0, os.path.abspath('..'))
import _version as quat_version
except:
import quaternion._version as quat_version

project = 'quaternion'
copyright = '2019, Michael Boyle'
copyright = '2020, Michael Boyle'
author = 'Michael Boyle'

# The short X.Y version
version = quat_version.__version__
version = "2021.0a0"
# The full version, including alpha/beta/rc tags
release = version
release = "2021.0.0-alpha.0"


# -- General configuration ---------------------------------------------------
Expand Down
18 changes: 0 additions & 18 deletions pipify.sh

This file was deleted.

7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[tool.pytest.ini_options]
minversion = "6.0"
norecursedirs = ".* build dist *.egg-info install ENV"
junit_family="xunit2"
addopts = "-v --tb=short --doctest-glob='' --cov=quaternion --cov-branch --cov-report xml"

[build-system]
requires = ["setuptools", "wheel", "numpy>=1.13"]
build-backend = "setuptools.build_meta"
14 changes: 8 additions & 6 deletions __init__.py → quaternion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2017, Michael Boyle
# Copyright (c) 2020, Michael Boyle
# See LICENSE file for details: <https://github.com/moble/quaternion/blob/master/LICENSE>

from __future__ import division, print_function, absolute_import
__version__ = "2021.0.0-alpha.0"

import numpy as np

Expand All @@ -20,7 +20,8 @@
except:
pass
from .means import mean_rotor_in_chordal_metric, optimal_alignment_in_chordal_metric
from ._version import __version__



__doc_title__ = "Quaternion dtype for NumPy"
__doc__ = "Adds a quaternion dtype to NumPy."
Expand Down Expand Up @@ -778,8 +779,9 @@ def allclose(a, b, rtol=4*np.finfo(float).eps, atol=0.0, equal_nan=False, verbos
close = isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan)
result = np.all(close)
if verbose and not result:
a, b = np.atleast_1d(a), np.atleast_1d(b)
a, b = np.broadcast_arrays(a, b)
print('Non-close values:')
for i in np.argwhere(close == False):
i = tuple(i)
print('\n a[{0}]={1}\n b[{0}]={2}'.format(i, a[i], b[i]))
for i in np.nonzero(close == False):
print(' a[{0}]={1}\n b[{0}]={2}'.format(i, a[i], b[i]))
return result
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion requirements-build-115.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements-build.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements-doc.txt

This file was deleted.

7 changes: 0 additions & 7 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 35f83be

Please sign in to comment.