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
3 changes: 3 additions & 0 deletions .github/workflows/array-api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ jobs:
python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt
python -m pip install pytest-xdist

- name: Install array-api-compat
run: python -m pip install ${GITHUB_WORKSPACE}/array-api-compat

- name: Dump pip environment
run: pip freeze

Expand Down
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
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ jobs:

- name: Run Tests
run: pytest -v

- name: Run vendoring tests
run: |
rm -rf vendor_tests/array_api_compat
cp -r src/array_api_compat vendor_tests/
pytest -v vendor_tests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
pixi.lock
vendor_tests/array_api_compat
Comment thread
ev-br marked this conversation as resolved.

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

- [ ] **Update the version.**

You must edit
You must edit the version in:

```
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).

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

Edit
Expand Down
75 changes: 75 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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')
subdir('vendor_tests')
65 changes: 65 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["linux-64", "osx-arm64", "win-64"]
preview = ["pixi-build"]
requires-pixi = ">=0.68.1"

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

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

[package.host-dependencies]
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"
description = "Run tests"

[feature.tests.tasks.clean-vendor-compat]
cmd = "rm -rf vendor_tests/array_api_compat"
description = "Delete the existing vendored version of array-api-compat"

[feature.tests.tasks.copy-vendor-compat]
cmd = "cp -r src/array_api_compat vendor_tests/"
depends-on = ["clean-vendor-compat"]
description = "Vendor a clean copy of array-api-extra"

[feature.tests.tasks.tests-vendor]
cmd = "pytest -v vendor_tests"
depends-on = ["copy-vendor-compat"]
description = "Run vendoring tests"

[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" }
14 changes: 6 additions & 8 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,10 @@ 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.pytest.ini_options]
testpaths = ["tests"]


[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.
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',
],
subdir: 'array_api_compat/tests',
install_tag: 'tests'
)
Empty file removed vendor_test/vendored/__init__.py
Empty file.
1 change: 0 additions & 1 deletion vendor_test/vendored/_compat

This file was deleted.

File renamed without changes.
11 changes: 11 additions & 0 deletions vendor_tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
py.install_sources([
'__init__.py',
'test_vendoring.py',
'uses_cupy.py',
'uses_dask.py',
'uses_numpy.py',
'uses_torch.py',
],
subdir: 'array_api_compat/vendor_tests',
install_tag: 'tests'
)
9 changes: 5 additions & 4 deletions tests/test_vendoring.py → vendor_tests/test_vendoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@


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

uses_numpy._test_numpy()


def test_vendoring_cupy():
pytest.importorskip("cupy")

from vendor_test import uses_cupy
from . import uses_cupy

uses_cupy._test_cupy()


def test_vendoring_torch():
pytest.importorskip("torch")
from vendor_test import uses_torch
from . import uses_torch

uses_torch._test_torch()


def test_vendoring_dask():
pytest.importorskip("dask")
from vendor_test import uses_dask
from . import uses_dask
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this and related changes please?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_vendoring was moved from the tests directory to the vendor_tests directory, and this line is updated with the appropriate relative import. This matches what works well for us at https://github.com/data-apis/array-api-extra/tree/main/vendor_tests.


uses_dask._test_dask()
2 changes: 1 addition & 1 deletion vendor_test/uses_cupy.py → vendor_tests/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 .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 → vendor_tests/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 .array_api_compat.dask import array as dask_compat
from .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 → vendor_tests/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 .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 → vendor_tests/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 .array_api_compat import (
is_torch_array,
is_torch_namespace,
torch as torch_compat,
Expand Down
Loading