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

Include numpy 2 compatibility layer #233

Merged
merged 31 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2782e5b
Include numpy 2 compatibility layer
moble May 19, 2024
a32bf58
Automatically update github actions versions
moble May 19, 2024
17e890e
Update copyrights
moble May 19, 2024
a4d7997
Remove poetry
moble May 19, 2024
38430f7
First try with numpy 2
moble Jun 14, 2024
e4a45a2
Ignore .vscode directory in git
moble Aug 17, 2024
3da5718
Don't restrict numpy version
moble Aug 17, 2024
039ad39
Update npy_2_compat as in numpy source
moble Aug 17, 2024
1a8c05a
Incorporate some more changes for numpy 2
moble Aug 17, 2024
c8900c3
Drop support for python versions numpy doesn't support
moble Aug 17, 2024
8e86fa6
Skip builds on python 3.8
moble Sep 30, 2024
5666abe
Try to ensure the right python is being used
moble Sep 30, 2024
fe84374
Don't insist on non-copying views
moble Sep 30, 2024
9e508cd
oldest-supported-numpy is deprecated; Numpy no longer supports python…
moble Sep 30, 2024
ca46e27
Soften Euler angle tolerance slightly
moble Sep 30, 2024
9d4d6a5
Bring hatch version usage in line with `sxs` package
moble Sep 30, 2024
5bac788
Correct application to docs/conf.py; don't apply to pyproject.toml
moble Sep 30, 2024
8b698f5
Require hatchling for build
moble Sep 30, 2024
61fc15f
Tell hatch where to find the current version
moble Sep 30, 2024
b0751ff
Correct sharing of version number across jobs
moble Sep 30, 2024
34eaf62
Correct version syntax typo in dependencies
moble Sep 30, 2024
289647d
Update sdist installation
moble Sep 30, 2024
907cde4
Remove unused script
moble Sep 30, 2024
a0e2218
Use simpler version of numpy 2 compat
moble Sep 30, 2024
c34ac6f
Remove unused npy_2_compat.h
moble Sep 30, 2024
36b312f
Skip python 3.13 while numba catches up
moble Sep 30, 2024
bb7fa1c
Use only versions of scipy,numpy with binaries
moble Sep 30, 2024
62b51e1
Skip win32 builds; not supported by numpy
moble Sep 30, 2024
18eb2f2
Skip builds on all mulslinux
moble Sep 30, 2024
48ad7b4
Explain CIBW_SKIPs #major
moble Sep 30, 2024
07b8c1f
Format CIBW_SKIPs #major
moble Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
15 changes: 7 additions & 8 deletions .github/scripts/parse_bump_rule.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import sys
import os


def parse(message):
if "#prerelease" in message:
return 'prerelease'
return "prerelease"

for pre in ['pre', '']:
for level in ['patch', 'minor', 'major']:
if f'#{pre}{level}' in message:
return f'{pre}{level}'
for pre in ["pre", ""]:
for level in ["patch", "minor", "major"]:
if f"#{pre}{level}" in message:
return f"{pre}{level}"

return 'patch'
return "patch"


message = os.environ['github_event_head_commit_message']
message = os.environ["github_event_head_commit_message"]
print(parse(message))
11 changes: 0 additions & 11 deletions .github/scripts/parse_version.py

This file was deleted.

13 changes: 12 additions & 1 deletion .github/scripts/update_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
def update(version):
if not version:
raise ValueError("Can't replace version with empty string")
files = ("pyproject.toml", "setup.py", "src/quaternion/__init__.py")
short_version = ".".join(version.split(".")[:2])

files = ("setup.py", "src/quaternion/__init__.py")
pattern = re.compile('^(__version__|version) *= *".*?"')
replacement = r'\1 = "' + version + '"'
with fileinput.input(files=files, inplace=True) as f:
for line in f:
print(pattern.sub(replacement, line), end="")

files = ("docs/conf.py")
pattern = re.compile('^release *= *".*?"')
short_pattern = re.compile('^version *= *".*?"')
replacement = r'release = "' + version + '"'
short_replacement = r'version = "' + short_version + '"'
with fileinput.input(files=files, inplace=True) as f:
for line in f:
print(short_pattern.sub(short_replacement, pattern.sub(replacement, line)), end="")


version = os.environ["new_version"]

Expand Down
79 changes: 50 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,51 @@ on:
tags: '*'
pull_request:

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:

get_new_version:
name: Get new version number
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
new_version: ${{ steps.get_version.outputs.new_version }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
python-version: '3.12'

- name: Install tomli
- name: Install Hatch
shell: bash
run: |
python -m pip install --upgrade pip tomli

- name: Install poetry
shell: bash
run: |
curl -sSL https://install.python-poetry.org | POETRY_HOME="$HOME/.poetry" python -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
run: python -m pip install --disable-pip-version-check --upgrade hatch

- name: Bump version
id: get_version
shell: bash
env:
github_event_head_commit_message: ${{ github.event.head_commit.message }}
run: |
# Note: The following line reads the HEAD commit message to look for an indication of how
# to bump the version number. Specifically, if `#patch`, `#minor`, or `#major` is present
# in the commit message, it bumps the corresponding version number. Those can also be
# prepended as `#premajor`, etc., to add/bump the prerelease modifier. If none of those
# are present, `#patch` is assumed — that is, the lowest-significance number is
# incremented. See the documentation of the `hatch version` command for details.
export version_bump_rule=$(python .github/scripts/parse_bump_rule.py)
echo "version_bump_rule: '${version_bump_rule}'"
poetry version "${version_bump_rule}"
export new_version=$(python .github/scripts/parse_version.py pyproject.toml)
hatch version "${version_bump_rule}"
export new_version=$(TERM="unknown" hatch version)
echo "new_version: '${new_version}'"
# echo "::set-output name=version::${new_version}"
echo "version=${new_version}" >> $GITHUB_OUTPUT
echo "new_version=${new_version}" >> "$GITHUB_OUTPUT" # Save variable for later steps


build_wheels:
Expand All @@ -73,12 +79,18 @@ jobs:
archs: "aarch64"

env:
CIBW_SKIP: cp27-* cp35-* cp36-* cp37-* pp* *-musllinux_aarch64 cp312-*_i686
CIBW_ARCHS: ${{matrix.archs}}
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_BEFORE_BUILD: python -c "print(('#'*130+'\n')*10)" && python -m pip install oldest-supported-numpy
CIBW_BEFORE_BUILD: python -c "print(('#'*130+'\n')*10)" && python -m pip install "numpy>=2.0,<3"
CIBW_TEST_REQUIRES: pytest pytest-cov
CIBW_TEST_COMMAND: "pytest {project}/tests"
CIBW_SKIP: "*-win32 *-manylinux_i686 cp36-* cp37-* cp38-* cp39-* pp* *-musllinux* cp313-*"
# Exclude 32-bit builds: *-win32 *-manylinux_i686
# Exclude python versions not supported by numpy: cp36-* cp37-* cp38-* cp39-* pp*
# Exclude musllinux builds: *-musllinux*
# Exclude python versions not yet supported by numba: cp313-*
# https://numpy.org/neps/nep-0029-deprecation_policy.html
# https://numba.readthedocs.io/en/stable/user/installing.html#numba-support-info

steps:
- name: Set up QEMU
Expand All @@ -96,12 +108,12 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
python-version: '3.12'

- name: Update versions
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.version}}
export new_version=${{needs.get_new_version.outputs.new_version}}
echo "Updating version to '${new_version}'"
python .github/scripts/update_versions.py

Expand Down Expand Up @@ -135,18 +147,19 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
python-version: '3.12'

- name: Update versions
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.version}}
export new_version=${{needs.get_new_version.outputs.new_version}}
echo "Updating version to '${new_version}'"
python .github/scripts/update_versions.py

- name: Build sdist
run: |
python -m pip install oldest-supported-numpy
python -m pip install --upgrade pip
python -m pip install --upgrade "setuptools>=61" wheel "numpy>=2.0,<3"
python setup.py sdist

- uses: actions/upload-artifact@v3 # Don't upgrade to v4 until each artifact is named
Expand Down Expand Up @@ -190,19 +203,19 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
python-version: '3.12'

- name: Update versions
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.version}}
export new_version=${{needs.get_new_version.outputs.new_version}}
echo "Updating version to '${new_version}'"
python .github/scripts/update_versions.py

- name: Tag and push new version
shell: bash
run: |
export new_version=${{needs.get_new_version.outputs.version}}
export new_version=${{needs.get_new_version.outputs.new_version}}
git config user.name github-actions
git config user.email github-actions@github.com
git commit -m "Update version for new release" pyproject.toml setup.py src/quaternion/__init__.py
Expand All @@ -217,10 +230,18 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.get_new_version.outputs.version }}
name: Release v${{ needs.get_new_version.outputs.version }}
tag_name: v${{ needs.get_new_version.outputs.new_version }}
name: Release v${{ needs.get_new_version.outputs.new_version }}
draft: false
prerelease: false

- name: Send to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish to PyPI
if: "!contains(github.event.head_commit.message, '[no pypi]')"
env:
# 1) Get key from https://pypi.org/manage/account/token/
# 2) Copy it to Github > repo > Settings > Secrets
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
shell: bash
run: |
hatch publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ pip_manylinux1_cache
.envs
notes
poetry.lock
.vscode
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Michael Boyle
Copyright (c) 2024 Michael Boyle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# -- Project information -----------------------------------------------------

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

# The short X.Y version
Expand Down
59 changes: 53 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,63 @@
[tool.poetry]
[project]
name = "quaternion"
version = "2023.0.4"
description = "Add a quaternion dtype to NumPy"
readme = "README.md"
license = "MIT"
authors = ["Michael Boyle <mob22@cornell.edu>"]
homepage = "https://github.com/moble/quaternion"
requires-python = ">=3.10"
license = {file = "LICENSE"}
authors = [
{ name = "Michael Boyle", email = "michael.oliver.boyle@gmail.com" }
]
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Astronomy"
]
dependencies = [
"numpy >=1.25,<3",
"scipy >=1.5,<2",
"numba >=0.55; implementation_name == 'cpython'"
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/moble/quaternion"
Documentation = "https://quaternionic.readthedocs.io/en/latest"

[build-system]
requires = ["setuptools!=50.0", "wheel", "oldest-supported-numpy"]
requires = ["hatchling", "setuptools>=61", "wheel", "numpy>=2.0,<3"]
build-backend = "setuptools.build_meta"

[tool.hatch.envs.default]
dependencies = [
"pytest",
"pytest-cov",
"black"
]
[tool.hatch.envs.default.scripts]
# Run these as `hatch run test`
test = "pytest {args:tests}"

[tool.hatch.envs.docs]
dependencies = [
"mkdocs",
"mktheapidocs",
"pymdown-extensions"
]
[tool.hatch.envs.docs.scripts]
# Run these as `hatch run docs:build` or `hatch run docs:serve`
build = "mkdocs build --clean"
serve = "mkdocs serve --dev-addr localhost:8000"

[tool.hatch.version]
path = "src/quaternion/__init__.py"

[tool.setuptools.dynamic]
version = {attr = "quaternion.__version__"}

[tool.pytest.ini_options]
minversion = "6.0"
norecursedirs = ".* build dist *.egg-info install ENV"
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

30 changes: 3 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


# Set this first for easier replacement
version = "2023.0.4"
version = "2023.1.0"

# read the contents of the README file into the PyPI description
this_directory = Path(__file__).parent
Expand All @@ -30,7 +30,8 @@
depends=[
"src/quaternion.c",
"src/quaternion.h",
"src/numpy_quaternion.c"
"src/numpy_quaternion.c",
"src/npy_2_compat.h"
],
include_dirs=[
np.get_include(),
Expand All @@ -51,31 +52,6 @@
long_description=long_description,
long_description_content_type="text/markdown",
ext_modules=extensions,
install_requires=[
"numpy>=1.13, < 2.0",
# See also extras and :environment_marker specs below
],
extras_require={
"scipy": [
"scipy",
],
"numba:python_version < '3.6' and platform_python_implementation != 'PyPy'": [
"numba<0.49.0",
"llvmlite<0.32.0",
],
"numba:python_version >= '3.6' and platform_python_implementation != 'PyPy'": [
"numba",
],
"docs": [
"mkdocs",
"mktheapidocs[plugin]",
"pymdown-extensions",
],
"testing": [
"pytest",
"pytest-cov",
]
},
version=version,
)

Expand Down
2 changes: 1 addition & 1 deletion src/math_msvc_compatibility.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021, Michael Boyle
// Copyright (c) 2024, Michael Boyle
// See LICENSE file for details: <https://github.com/moble/quaternion/blob/main/LICENSE>

#ifndef __MATH_MSVC_COMPATIBILITY_H__
Expand Down
Loading
Loading