Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ dmypy.json

# macOS specific iles
.DS_Store

pixi.lock
Binary file added array-api-compat-1.15.0.dev0-pyh4616a5c_0.conda
Binary file not shown.
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
70 changes: 70 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
project(
'array_api_compat',
version: '1.15.0.dev0',
license: 'MIT',
license_files: ['LICENSE']
)

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

sources = {
'array_api_compat': files(
'src/array_api_compat/__init__.py',
'src/array_api_compat/_internal.py',
),

'array_api_compat/common': files(
'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': files(
'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': files(
'src/array_api_compat/dask/__init__.py',
),

'array_api_compat/dask/array': files(
'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': files(
'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': files(
'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',
),
}

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

subdir('tests')
subdir('vendor_test')
63 changes: 55 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 @@ -54,12 +54,59 @@ 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
# Pixi

[tool.pixi.workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["linux-64", "osx-arm64", "win-64"]
preview = ["pixi-build"]

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

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

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

### workspace environments ###

[tool.pixi.environments]
docs = ["docs"]
tests = ["tests"]

### default feature definition ###

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

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

### non-default feature definitions ###

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

[tool.pixi.feature.tests.tasks]
tests = { cmd = "pytest -v", description = "Run tests" }

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

[tool.pixi.feature.docs.tasks]
docs = { cmd = "make html", cwd = "docs", description = "Build docs" }


[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',
'test_vendoring.py',
],
subdir: 'array_api_compat/tests'
)
11 changes: 11 additions & 0 deletions vendor_test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
py.install_sources([
'__init__.py',
'uses_cupy.py',
'uses_dask.py',
'uses_numpy.py',
'uses_torch.py',
],
subdir: 'array_api_compat/vendor_test'
)

subdir('vendored')
11 changes: 11 additions & 0 deletions vendor_test/vendored/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
py.install_sources([
'__init__.py',
],
subdir: 'array_api_compat/vendor_test/vendored'
)

install_symlink(
'_compat',
install_dir: 'array_api_compat/vendor_test/vendored',
pointing_to: '../../',
)
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.

The problem was that I had a dodgy workaround for the symlink. Hopefully now this works.

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.

@rgommers can you see what I'm doing wrong with the symlink here? Logs like https://github.com/data-apis/array-api-compat/actions/runs/23195083314/job/67401163424?pr=373 seem to show that it is broken.

I've tried poking around with meson introspect but I can't figure it out.

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.

Symlinks aren't supported in wheels, so this looks unfamiliar and is probably not what you want.

It is possible to have a symlink in the source tree, but it gets replaced by a copy in an sdist/wheel.

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.

9120e06 (this PR) gets rid of the symlink. However, this does not seem to work for editable builds. Is there something in Meson's Python module that can mimic configure_file(copy: true) like this?

For context, it seems like pointing to the same file twice with py.install_sources means that it is only installed once.

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.

despite my sunk-cost into making this work for wheels only, we should probably just give up on the symlink and use a Pixi task to populate the directory at test-time, like https://github.com/data-apis/array-api-extra/blob/1c5bb9d65f75132196650de2ca966e2fc36ac15c/pyproject.toml#L146. I think we are pushing meson-python slightly past its limits by trying to mimic the symlink.

I had hoped that we could merge this without me having to convert CI over to using Pixi yet, but maybe not...

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.

I'm a little confused here about what triggered all this, because there's a lot going on in this PR:

  • The move to src/ layout, if desired, might be best to land standalone, together with a commit to not affect git blame
  • The vendor test is new, and is what seems to be the motivation for the symlink-like thing. Can't this be done inside the test itself, rather than in the source tree?
  • Switching over to meson-python, nice (for SciPy/scikit-learn and the vendoring use case)
  • Adding a Pixi config

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.

  • The vendor test is new, and is what seems to be the motivation for the symlink-like thing. Can't this be done inside the test itself, rather than in the source tree?

the vendor test is not new, you can see the symlink at https://github.com/data-apis/array-api-compat/tree/main/vendor_test/vendored. The challenge I was trying to get through was dealing with the symlink in meson-python. It would be nicer to just get rid of the symlink and copy things over at test-time, like https://github.com/data-apis/array-api-extra/blob/231b8a50d9baa22ccebdfee571472f0ce46a8a29/pyproject.toml#L145-L146.

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.

Ah never noticed (or, no longer remembering) - it's missing from the sdist, which is unsurprising but not ideal.

It would be nicer to just get rid of the symlink and copy things over at test-time

agreed

Loading