Skip to content

Commit 5116759

Browse files
committed
Switch packaging to meson
1 parent 5bf387c commit 5116759

5 files changed

Lines changed: 73 additions & 43 deletions

File tree

Makefile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.PHONY: clean clean-test clean-pyc clean-build docs help
22
.DEFAULT_GOAL := help
33

4+
MESON_BUILD_DIR ?= builddir
5+
46
define BROWSER_PYSCRIPT
57
import os, webbrowser, sys
68

@@ -32,11 +34,12 @@ help:
3234
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
3335

3436
clean-build: ## remove build artifacts
35-
rm -fr build/
36-
rm -fr dist/
37-
rm -fr .eggs/
38-
find . -name '*.egg-info' -exec rm -fr {} +
39-
find . -name '*.egg' -exec rm -f {} +
37+
rm -fr build/
38+
rm -fr dist/
39+
rm -fr $(MESON_BUILD_DIR)/
40+
rm -fr .eggs/
41+
find . -name '*.egg-info' -exec rm -fr {} +
42+
find . -name '*.egg' -exec rm -f {} +
4043

4144
clean-pyc: ## remove Python file artifacts
4245
find . -name '*.pyc' -exec rm -f {} +
@@ -60,7 +63,7 @@ test-all: ## run tests on every Python version with tox
6063
tox
6164

6265
coverage: ## check code coverage quickly with the default Python
63-
coverage run --source dtw setup.py test
66+
coverage run --source dtw -m pytest
6467
coverage report -m
6568
coverage html
6669
$(BROWSER) htmlcov/index.html
@@ -80,13 +83,12 @@ servedocs: docs ## compile the docs watching for changes
8083
release: dist ## package and upload a release
8184
twine upload dist/*
8285

83-
dist: clean ## builds source and wheel package
84-
python setup.py sdist
85-
python setup.py bdist_wheel
86-
ls -l dist
86+
dist: clean ## builds source and wheel package using the Meson backend
87+
python -m build
88+
ls -l dist
8789

8890
install: clean ## install the package to the active Python's site-packages
89-
python setup.py install
91+
python -m pip install .
9092

9193

9294
docstrings:

meson.build

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
project('dtw-python', ['c', 'cython'], version: '1.5.3', license: 'GPL-2.0-or-later', default_options: ['warning_level=1'])
2+
3+
py = import('python').find_installation(modules: ['cython', 'numpy'])
4+
5+
py.install_sources(
6+
'dtw/__init__.py',
7+
'dtw/__main__.py',
8+
'dtw/_backtrack.py',
9+
'dtw/_globalCostMatrix.py',
10+
'dtw/countPaths.py',
11+
'dtw/dtw.py',
12+
'dtw/dtwPlot.py',
13+
'dtw/dtw_test_data.py',
14+
'dtw/mvm.py',
15+
'dtw/stepPattern.py',
16+
'dtw/warp.py',
17+
'dtw/warpArea.py',
18+
'dtw/window.py',
19+
subdir: 'dtw',
20+
pure: true,
21+
)
22+
23+
py.install_sources(
24+
'dtw/data/README.txt',
25+
'dtw/data/aami3a.csv',
26+
'dtw/data/aami3b.csv',
27+
subdir: 'dtw/data',
28+
pure: true,
29+
)
30+
31+
dtw_include = include_directories('dtw')
32+
33+
numpy_inc_result = run_command(py, ['-c', 'import numpy; print(numpy.get_include())'], check: true)
34+
numpy_include_dir = numpy_inc_result.stdout().strip()
35+
numpy_c_args = ['-I' + numpy_include_dir]
36+
37+
py.extension_module(
38+
'dtw._dtw_utils',
39+
[
40+
'dtw/_dtw_utils.pyx',
41+
'dtw/dtw_core.c',
42+
],
43+
include_directories: [dtw_include],
44+
c_args: numpy_c_args,
45+
install: true,
46+
)

pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
[build-system]
55
# Minimum requirements for the build system to execute.
66
# PEP 508 specifications.
7-
requires = ["setuptools",
8-
"wheel",
7+
requires = [
8+
"meson-python>=0.15",
99
"Cython",
1010
'numpy>=2.0.0rc1; python_version>="3.9"',
1111
'numpy; python_version<"3.9"',
1212
]
13-
build-backend = "setuptools.build_meta"
13+
build-backend = "mesonpy"
1414

1515

1616
# https://numpy.org/devdocs/dev/depending_on_numpy.html#for-downstream-package-authors
1717

1818
[project]
1919
name = "dtw-python"
20-
dynamic = ["version"]
20+
version = "1.5.3"
2121
dependencies = [
2222
'numpy>=1.23.5; python_version>="3.9"',
2323
'numpy; python_version<"3.9"',
@@ -113,5 +113,8 @@ exclude = [
113113
[dependency-groups]
114114
dev = [
115115
"pytest>=7.0.1",
116+
"build>=1.2.1; python_version>='3.8'",
117+
"Cython>=3.0; python_version>='3.8'",
118+
"meson>=1.4.0; python_version>='3.8'",
116119
]
117120

setup.cfg

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ current_version = 1.5.3
33
commit = True
44
tag = True
55

6-
[bumpversion:file:setup.py]
7-
search = version="{current_version}"
8-
replace = version="{new_version}"
6+
[bumpversion:file:pyproject.toml]
7+
search = version = "{current_version}"
8+
replace = version = "{new_version}"
9+
10+
[bumpversion:file:meson.build]
11+
search = version: '{current_version}'
12+
replace = version: '{new_version}'
913

1014
[bumpversion:file:dtw/__init__.py]
1115
search = __version__ = '{current_version}'

setup.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)