Skip to content

Commit

Permalink
v1.0.0: Update numpy pins (#109)
Browse files Browse the repository at this point in the history
* Update pins and bump version

* Remove old pythons

* Remove Python3.9

* Set macos 13

* Reenable 3.9

* Fix pyproject

* Fix build constraint

* Wip/cibuildwheel (#110)

* Try to add cibuildwheel workflow

* Configure cibuildwheel

* Remove macos 14

* Fix workflow

* Update cibuildwheel config

* Try to fix archs commands

* Fix config

* Skip pypy

* Add another failure repro decorator

* Temporarily try increasing error tolerance

* Try to add more debugging

* Comment

* Try to get cibuildwheel uploading to pypi
  • Loading branch information
honnibal authored Jul 22, 2024
1 parent ec60745 commit a5bdba1
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 27 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build

on:
release:
types:
- published

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-13]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SOME_OPTION: value
with:
package-dir: .
output-dir: wheelhouse
config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

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

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
6 changes: 1 addition & 5 deletions build-constraints.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
# build version constraints for use with wheelwright + multibuild
numpy==1.15.0; python_version<='3.7' and platform_machine!='aarch64'
numpy==1.19.2; python_version<='3.7' and platform_machine=='aarch64'
numpy==1.17.3; python_version=='3.8' and platform_machine!='aarch64'
numpy==1.19.2; python_version=='3.8' and platform_machine=='aarch64'
numpy>=1.25.0; python_version>='3.9'
numpy>=2.0.0; python_version>='3.9'
57 changes: 50 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,58 @@
requires = [
"setuptools",
"cython>=0.25",
"numpy>=1.15.0; python_version < '3.9'",
"numpy>=1.25.0; python_version >= '3.9'",
"numpy>=2.0.0,<3.0.0"
]
build-backend = "setuptools.build_meta"

# NOTE: overrides here are only used if CIBW_ENVIRONMENT is not set
[tool.cibuildwheel]
environment = { PIP_CONSTRAINT="build-constraints.txt" }
build = "*"
skip = "pp* cp36* cp37* cp38*"
test-skip = ""
free-threaded-support = false

[[tool.cibuildwheel.overrides]]
select = "*-macosx_arm64"
environment = { PIP_CONSTRAINT="build-constraints.txt", BLIS_COMPILER="clang -arch arm64" }
archs = ["native"]

build-frontend = "default"
config-settings = {}
dependency-versions = "pinned"
environment = {}
environment-pass = []
build-verbosity = 0

before-all = ""
before-build = ""
repair-wheel-command = ""

test-command = ""
before-test = ""
test-requires = []
test-extras = []

container-engine = "docker"

manylinux-x86_64-image = "manylinux2014"
manylinux-i686-image = "manylinux2014"
manylinux-aarch64-image = "manylinux2014"
manylinux-ppc64le-image = "manylinux2014"
manylinux-s390x-image = "manylinux2014"
manylinux-pypy_x86_64-image = "manylinux2014"
manylinux-pypy_i686-image = "manylinux2014"
manylinux-pypy_aarch64-image = "manylinux2014"

musllinux-x86_64-image = "musllinux_1_2"
musllinux-i686-image = "musllinux_1_2"
musllinux-aarch64-image = "musllinux_1_2"
musllinux-ppc64le-image = "musllinux_1_2"
musllinux-s390x-image = "musllinux_1_2"


[tool.cibuildwheel.linux]
repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}"

[tool.cibuildwheel.macos]
repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"

[tool.cibuildwheel.windows]

[tool.cibuildwheel.pyodide]
41 changes: 26 additions & 15 deletions tests/test_dotv.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
from __future__ import division
from hypothesis import given, assume
from math import sqrt, floor
import numpy

from blis_tests_common import *
from blis.py import dotv
from blis.cy import NO_CONJUGATE, CONJUGATE


@given(
ndarrays(min_len=10, max_len=100,
min_val=-100.0, max_val=100.0, dtype='float64'),
ndarrays(min_len=10, max_len=100,
min_val=-100.0, max_val=100.0, dtype='float64'),
ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float64"),
ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float64"),
)
def test_memoryview_double_noconj(A, B):
if len(A) < len(B):
B = B[:len(A)]
B = B[: len(A)]
else:
A = A[:len(B)]
A = A[: len(B)]
assume(A is not None)
assume(B is not None)
numpy_result = A.dot(B)
Expand All @@ -26,18 +23,32 @@ def test_memoryview_double_noconj(A, B):


@given(
ndarrays(min_len=10, max_len=100,
min_val=-100.0, max_val=100.0, dtype='float32'),
ndarrays(min_len=10, max_len=100,
min_val=-100.0, max_val=100.0, dtype='float32'),
ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float32"),
ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float32"),
)
def test_memoryview_float_noconj(A, B):
if len(A) < len(B):
B = B[:len(A)]
B = B[: len(A)]
else:
A = A[:len(B)]
A = A[: len(B)]
assume(A is not None)
assume(B is not None)
numpy_result = A.dot(B)
result = dotv(A, B)
assert_allclose([numpy_result], result, atol=1e-3, rtol=1e-3)
# We want to also know the true(r) answer, if one of them is off.
A_float64 = A.astype(numpy.float64)
B_float64 = B.astype(numpy.float64)
numpy_result64 = A_float64.dot(B_float64)
blis_result64 = dotv(A_float64, B_float64)
try:
assert_allclose(
[numpy_result],
result,
atol=1e-3,
rtol=1e-3,
)
except AssertionError as e:
# Probably better to make a combined message, but eh
print(f"Numpy 64bit result: {numpy_result64}")
print(f"blis 64bit result: {blis_result64}")
raise e

0 comments on commit a5bdba1

Please sign in to comment.