Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Install python-build and twine
run: |
python -m pip install --upgrade pip "setuptools<=67"
python -m pip install --upgrade pip meson-python
python -m pip install build twine
python -m pip list

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pixi.lock
subprojects/array_api_compat
subprojects/.wraplock

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
7 changes: 4 additions & 3 deletions docs/dev/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@

- [ ] **Update the version.**

You must edit
You must edit both of

```
array_api_compat/__init__.py
pyproject.toml
Comment thread
lucascolley marked this conversation as resolved.
Comment thread
lucascolley marked this conversation as resolved.
meson.build
```

and update the version (the version is not computed from the tag because
that would break vendorability).
and update the version.

- [ ] **Update the [changelog](../changelog.md).**

Expand Down
78 changes: 78 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
project(
'array_api_compat',
version: '1.15.0.dev0',
license: 'MIT',
license_files: ['LICENSE']
)

py = import('python').find_installation()

sources_raw = {
'array_api_compat': [
'src/array_api_compat/__init__.py',
'src/array_api_compat/_internal.py',
],

'array_api_compat/common': [
'src/array_api_compat/common/__init__.py',
'src/array_api_compat/common/_aliases.py',
'src/array_api_compat/common/_fft.py',
'src/array_api_compat/common/_helpers.py',
'src/array_api_compat/common/_linalg.py',
'src/array_api_compat/common/_typing.py',
],

'array_api_compat/cupy': [
'src/array_api_compat/cupy/__init__.py',
'src/array_api_compat/cupy/_aliases.py',
'src/array_api_compat/cupy/_info.py',
'src/array_api_compat/cupy/_typing.py',
'src/array_api_compat/cupy/fft.py',
'src/array_api_compat/cupy/linalg.py',
],

'array_api_compat/dask': [
'src/array_api_compat/dask/__init__.py',
],

'array_api_compat/dask/array': [
'src/array_api_compat/dask/array/__init__.py',
'src/array_api_compat/dask/array/_aliases.py',
'src/array_api_compat/dask/array/_info.py',
'src/array_api_compat/dask/array/fft.py',
'src/array_api_compat/dask/array/linalg.py',
],

'array_api_compat/numpy': [
'src/array_api_compat/numpy/__init__.py',
'src/array_api_compat/numpy/_aliases.py',
'src/array_api_compat/numpy/_info.py',
'src/array_api_compat/numpy/_typing.py',
'src/array_api_compat/numpy/fft.py',
'src/array_api_compat/numpy/linalg.py',
],

'array_api_compat/torch': [
'src/array_api_compat/torch/__init__.py',
'src/array_api_compat/torch/_aliases.py',
'src/array_api_compat/torch/_info.py',
'src/array_api_compat/torch/_typing.py',
'src/array_api_compat/torch/fft.py',
'src/array_api_compat/torch/linalg.py',
],
}

sources = {}
foreach subdir, paths : sources_raw
sources += { subdir : files(paths) }
endforeach

foreach subdir, files : sources
py.install_sources(files, subdir: subdir)
endforeach

subdir('tests')

if get_option('vendor_tests')
subdir('vendor_test')
endif
6 changes: 6 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
option(
'vendor_tests',
type: 'boolean',
value: false,
description: 'Install vendoring tests.'
)
60 changes: 60 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["linux-64", "osx-arm64", "win-64"]
preview = ["pixi-build"]

### array-api-compat package definition ###

[package.build.backend]
name = "pixi-build-python"
version = "*"

[package.build.config]
extra-args = ["-Csetup-args=-Dvendor_tests=true"]

[package.host-dependencies]
uv = "*"
meson-python = "*"

### workspace environments ###

[environments]
docs = ["docs"]
tests = ["tests"]

### default feature definition ###

[dev]
# this pulls in array-api-compat's host dependencies
array-api-compat.path = "."

[dependencies]
array-api-compat.path = "."

### non-default feature definitions ###

[feature.tests.dependencies]
pytest = "*"
array-api-strict = "*"
numpy = "*"

[feature.tests.tasks.tests]
cmd = "pytest -v"
depends-on = ["setup_vendor_test"]
description = "Run tests"

[feature.tests.tasks.setup_vendor_test]
cmd = "mkdir -p subprojects/array_api_compat && cp meson.build subprojects/array_api_compat && sed -i '' '/^[[:space:]]*subdir/d' subprojects/array_api_compat/meson.build && cp meson_options.txt subprojects/array_api_compat && cp LICENSE subprojects/array_api_compat && cp -R src subprojects/array_api_compat/"
inputs = ["meson.build", "LICENSE", "src"]
outputs = ["subprojects/array_api_compat"]

[feature.docs.dependencies]
furo = "*"
linkify-it-py = "*"
myst-parser = "*"
sphinx = "*"
sphinx-copybutton = "*"
sphinx-autobuild = "*"

[feature.docs.tasks]
docs = { cmd = "make html", cwd = "docs", description = "Build docs" }
12 changes: 3 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
requires = ["meson-python"]
build-backend = "mesonpy"

[project]
name = "array-api-compat"
dynamic = ["version"]
version = "1.15.0.dev0"
description = "A wrapper around NumPy and other array libraries to make them compatible with the Array API standard"
readme = "README.md"
requires-python = ">=3.10"
Expand Down Expand Up @@ -55,12 +55,6 @@ dev = [
homepage = "https://data-apis.org/array-api-compat/"
repository = "https://github.com/data-apis/array-api-compat/"

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

[tool.setuptools.packages.find]
include = ["array_api_compat*"]
namespaces = false

[tool.ruff.lint]
preview = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions subprojects/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Meson subprojects directory, for use in vendoring tests.
17 changes: 17 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
py.install_sources([
'__init__.py',
'_helpers.py',
'test_all.py',
'test_array_namespace.py',
'test_common.py',
'test_copies_or_views.py',
'test_cupy.py',
'test_dask.py',
'test_isdtype.py',
'test_jax.py',
'test_no_dependencies.py',
'test_torch.py',
'test_vendoring.py',
],
subdir: 'array_api_compat/tests'
)
3 changes: 2 additions & 1 deletion tests/test_vendoring.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import pytest

pytest.importorskip("array_api_compat.vendor_test")

def test_vendoring_numpy():
from vendor_test import uses_numpy
from array_api_compat.vendor_test import uses_numpy

uses_numpy._test_numpy()

Expand Down
20 changes: 20 additions & 0 deletions vendor_test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
py.install_sources([
'__init__.py',
'uses_cupy.py',
'uses_dask.py',
'uses_numpy.py',
'uses_torch.py',
],
subdir: 'array_api_compat/vendor_test'
)

py.install_sources(
['__init__.py'],
subdir: 'vendored_array_api_compat'
)

vendored_compat = subproject('array_api_compat')
vendored_compat_sources = vendored_compat.get_variable('sources')
foreach prefix, files : vendored_compat_sources
py.install_sources(files, subdir: 'vendored_array_api_compat' / prefix)
endforeach
2 changes: 1 addition & 1 deletion vendor_test/uses_cupy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Basic test that vendoring works

from .vendored._compat import (
from vendored_array_api_compat.array_api_compat import (
cupy as cp_compat,
is_cupy_array,
is_cupy_namespace,
Expand Down
4 changes: 2 additions & 2 deletions vendor_test/uses_dask.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Basic test that vendoring works

from .vendored._compat.dask import array as dask_compat
from .vendored._compat import is_dask_array, is_dask_namespace
from vendored_array_api_compat.array_api_compat.dask import array as dask_compat
from vendored_array_api_compat.array_api_compat import is_dask_array, is_dask_namespace

import dask.array as da
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion vendor_test/uses_numpy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Basic test that vendoring works

from .vendored._compat import (
from vendored_array_api_compat.array_api_compat import (
is_numpy_array,
is_numpy_namespace,
numpy as np_compat,
Expand Down
2 changes: 1 addition & 1 deletion vendor_test/uses_torch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Basic test that vendoring works

from .vendored._compat import (
from vendored_array_api_compat.array_api_compat import (
is_torch_array,
is_torch_namespace,
torch as torch_compat,
Expand Down
Empty file removed vendor_test/vendored/__init__.py
Empty file.
1 change: 0 additions & 1 deletion vendor_test/vendored/_compat

This file was deleted.

Loading