From 8c07e5c1f4f95322262985c18578891dc3695b83 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 18 Jun 2024 10:27:50 +0200 Subject: [PATCH 1/8] Update pins and bump version --- blis/about.py | 2 +- requirements.txt | 3 +-- setup.py | 14 +++----------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/blis/about.py b/blis/about.py index fb5a294a..8334b414 100644 --- a/blis/about.py +++ b/blis/about.py @@ -5,7 +5,7 @@ # https://github.com/pypa/warehouse/blob/master/warehouse/__about__.py __name__ = "blis" -__version__ = "0.9.1" +__version__ = "1.0.0" __summary__ = ( "The Blis BLAS-like linear algebra library, as a self-contained C-extension." ) diff --git a/requirements.txt b/requirements.txt index be9f9e45..2315fec9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ # Test requirements -numpy>=1.15.0; python_version < "3.9" -numpy>=1.19.0; python_version >= "3.9" +numpy>=2.0.0,<3.0.0 pytest cython hypothesis>=4.0.0,<7.0.0 diff --git a/setup.py b/setup.py index 21052f95..8c42193e 100644 --- a/setup.py +++ b/setup.py @@ -253,9 +253,7 @@ def compile_objects(self, platform, py_arch, obj_dir): ] # Ensure that symbols are visible to aid debugging and profiling. spec["flags"] = [ - f - for f in spec["flags"] - if "visibility=hidden" not in f + f for f in spec["flags"] if "visibility=hidden" not in f ] objects.append(self.build_object(env=env, **spec)) return objects @@ -329,11 +327,10 @@ def chdir(new_dir): setup( setup_requires=[ "cython>=0.25", - "numpy>=1.15.0", + "numpy>=2.0.0,<3.0.0", ], install_requires=[ - "numpy>=1.15.0; python_version < '3.9'", - "numpy>=1.19.0; python_version >= '3.9'", + "numpy>=2.0.0,<3.0.0", ], ext_modules=cythonize( [ @@ -371,11 +368,6 @@ def chdir(new_dir): "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", "Programming Language :: Cython", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", From a8ea53a459e37fe103723747e08bb591d20c49a3 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 18 Jun 2024 10:29:48 +0200 Subject: [PATCH 2/8] Remove old pythons --- .github/workflows/tests.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d67994f6..47cc3a4a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,12 +21,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] - include: - - os: windows-2019 - python_version: "3.6" - - os: ubuntu-20.04 - python_version: "3.6" + python_version: ["3.9", "3.10", "3.11", "3.12"] runs-on: ${{ matrix.os }} steps: From 81f7de12dad4d8c8912d08ff0f3f5510f96a5525 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 18 Jun 2024 10:32:39 +0200 Subject: [PATCH 3/8] Remove Python3.9 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 47cc3a4a..da1ff442 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python_version: ["3.9", "3.10", "3.11", "3.12"] + python_version: ["3.10", "3.11", "3.12"] runs-on: ${{ matrix.os }} steps: From 9de3b6be70ffc6b39e5495bf7b6e1606c10603b5 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 18 Jun 2024 10:37:29 +0200 Subject: [PATCH 4/8] Set macos 13 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da1ff442..ebdc3ec9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-13] python_version: ["3.10", "3.11", "3.12"] runs-on: ${{ matrix.os }} From dd3bf94a2fc4a7d0e08e95d2afa6d8ee940ba629 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 18 Jun 2024 10:51:37 +0200 Subject: [PATCH 5/8] Reenable 3.9 --- .github/workflows/tests.yml | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ebdc3ec9..e852d9e2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-13] - python_version: ["3.10", "3.11", "3.12"] + python_version: ["3.9", "3.10", "3.11", "3.12"] runs-on: ${{ matrix.os }} steps: diff --git a/setup.py b/setup.py index 8c42193e..d0944c92 100644 --- a/setup.py +++ b/setup.py @@ -368,6 +368,7 @@ def chdir(new_dir): "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", "Programming Language :: Cython", + "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", From 4bfbcc46e69653e49619c2213802a9d3f9565d5c Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 18 Jun 2024 11:40:22 +0200 Subject: [PATCH 6/8] Fix pyproject --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 90289ff2..be643e65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,8 +2,7 @@ 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" From b235a2b8d9621ba6d7395aaab5056f7f3cc0d44b Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 18 Jun 2024 12:02:27 +0200 Subject: [PATCH 7/8] Fix build constraint --- build-constraints.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build-constraints.txt b/build-constraints.txt index 5540d634..431ab34f 100644 --- a/build-constraints.txt +++ b/build-constraints.txt @@ -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' From a0e3e90172dc8e9f93911a4dac4705bf19c49d59 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 22 Jul 2024 09:34:34 +0200 Subject: [PATCH 8/8] 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 --- .github/workflows/cibuildwheel.yml | 66 ++++++++++++++++++++++++++++++ pyproject.toml | 54 +++++++++++++++++++++--- tests/test_dotv.py | 41 ++++++++++++------- 3 files changed, 141 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/cibuildwheel.yml diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml new file mode 100644 index 00000000..c0646bba --- /dev/null +++ b/.github/workflows/cibuildwheel.yml @@ -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/cibuildwheel@v2.19.1 + 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/ diff --git a/pyproject.toml b/pyproject.toml index be643e65..43bffe92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,10 +6,54 @@ requires = [ ] 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] diff --git a/tests/test_dotv.py b/tests/test_dotv.py index 018bc97e..b0b87feb 100644 --- a/tests/test_dotv.py +++ b/tests/test_dotv.py @@ -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) @@ -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