diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27343bb92..c1b995530 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,12 +40,15 @@ jobs: sudo apt-get install -y lcov - name: Build package + env: + CXXFLAGS: "-std=c++17 --coverage" + CFLAGS: "--coverage" run: | - CXXFLAGS="-std=c++17 --coverage" CFLAGS="--coverage" python scripts/build/install.py + spin build -v # coverage tests - name: Run tests run: | - python -m pytest --doctest-modules --cov=./ --cov-report=xml -s + spin test -v - name: Capture Coverage Data with lcov run: | @@ -101,12 +104,14 @@ jobs: python -m pip install -r docs/requirements.txt - name: Build package + env: + CXXFLAGS: "-std=c++17" run: | - CXXFLAGS="-std=c++17" python scripts/build/install.py + spin build -v - name: Run tests run: | - python -c "import pydatastructs; pydatastructs.test(only_benchmarks=True)" + spin test -v - name: Build Documentation run: | @@ -144,11 +149,12 @@ jobs: - name: Build package env: MACOSX_DEPLOYMENT_TARGET: 11.0 + CXXFLAGS: "-std=c++17" run: | - CXXFLAGS="-std=c++17" python scripts/build/install.py + spin build -v - name: Run tests run: | - python -c "import pydatastructs; pydatastructs.test()" + spin test -v - name: Build Documentation run: | @@ -194,11 +200,11 @@ jobs: env: CL: "/std:c++17" run: | - python scripts/build/install.py + spin build -v - name: Run tests run: | - python -c "import pydatastructs; pydatastructs.test()" + spin test -v - name: Build Documentation run: | diff --git a/environment.yml b/environment.yml index 2d2ce160d..f08245fbc 100644 --- a/environment.yml +++ b/environment.yml @@ -9,6 +9,8 @@ dependencies: - pip: - codecov - pytest-cov + - spin + - meson - sphinx==5.0 - sphinx-readable-theme==1.3.0 - myst_nb==0.17.2 diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..46b3a7b1d --- /dev/null +++ b/meson.build @@ -0,0 +1,7 @@ +project('pydatastructs', 'cpp', + version : '1.0.1-dev', + default_options : ['cpp_std=c++17']) + +python = import('python').find_installation(pure: false) + +subdir('pydatastructs') diff --git a/pydatastructs/graphs/__init__.py b/pydatastructs/graphs/__init__.py index c1a70574a..21e0a5f35 100644 --- a/pydatastructs/graphs/__init__.py +++ b/pydatastructs/graphs/__init__.py @@ -9,7 +9,6 @@ from . import algorithms from . import adjacency_list from . import adjacency_matrix -from . import _extensions from .algorithms import ( breadth_first_search, diff --git a/pydatastructs/graphs/meson.build b/pydatastructs/graphs/meson.build new file mode 100644 index 000000000..2878bc186 --- /dev/null +++ b/pydatastructs/graphs/meson.build @@ -0,0 +1,37 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'adjacency_list.py', + 'adjacency_matrix.py', + 'algorithms.py', + 'graph.py' + ], + subdir: 'pydatastructs/graphs' +) + +python.install_sources( + ['_backend/__init__.py', '_backend/cpp/__init__.py'], + subdir: 'pydatastructs/graphs/_backend' +) + +py_include = include_directories('../utils/_backend/cpp') + +python.extension_module( + '_graph', + '_backend/cpp/graph.cpp', + include_directories: py_include, + install: true, + subdir: 'pydatastructs/graphs/_backend/cpp' +) + +python.extension_module( + '_algorithms', + '_backend/cpp/algorithms.cpp', + include_directories: py_include, + install: true, + subdir: 'pydatastructs/graphs/_backend/cpp' +) + +subdir('tests') diff --git a/pydatastructs/graphs/tests/meson.build b/pydatastructs/graphs/tests/meson.build new file mode 100644 index 000000000..e887b63a9 --- /dev/null +++ b/pydatastructs/graphs/tests/meson.build @@ -0,0 +1,12 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'test_adjacency_list.py', + 'test_adjacency_matrix.py', + 'test_algorithms.py' + ], + subdir: 'pydatastructs/graphs/tests', + install_tag: 'tests' +) diff --git a/pydatastructs/linear_data_structures/__init__.py b/pydatastructs/linear_data_structures/__init__.py index de247b88e..c6b3341d2 100644 --- a/pydatastructs/linear_data_structures/__init__.py +++ b/pydatastructs/linear_data_structures/__init__.py @@ -4,7 +4,6 @@ arrays, linked_lists, algorithms, - _extensions ) from .arrays import ( diff --git a/pydatastructs/linear_data_structures/meson.build b/pydatastructs/linear_data_structures/meson.build new file mode 100644 index 000000000..fca4004cc --- /dev/null +++ b/pydatastructs/linear_data_structures/meson.build @@ -0,0 +1,32 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'algorithms.py', + 'arrays.py', + 'linked_lists.py' + ], + subdir: 'pydatastructs/linear_data_structures' +) + +python.install_sources( + ['_backend/__init__.py', '_backend/cpp/__init__.py'], + subdir: 'pydatastructs/linear_data_structures/_backend' +) + +python.extension_module( + '_arrays', + '_backend/cpp/arrays/arrays.cpp', + install: true, + subdir: 'pydatastructs/linear_data_structures/_backend/cpp' +) + +python.extension_module( + '_algorithms', + '_backend/cpp/algorithms/algorithms.cpp', + install: true, + subdir: 'pydatastructs/linear_data_structures/_backend/cpp' +) + +subdir('tests') diff --git a/pydatastructs/linear_data_structures/tests/meson.build b/pydatastructs/linear_data_structures/tests/meson.build new file mode 100644 index 000000000..343f068f4 --- /dev/null +++ b/pydatastructs/linear_data_structures/tests/meson.build @@ -0,0 +1,15 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'benchmarks/__init__.py', + 'benchmarks/test_algorithms.py', + 'benchmarks/test_arrays.py', + 'test_algorithms.py', + 'test_arrays.py', + 'test_linked_lists.py' + ], + subdir: 'pydatastructs/linear_data_structures/tests', + install_tag: 'tests' +) diff --git a/pydatastructs/meson.build b/pydatastructs/meson.build new file mode 100644 index 000000000..f7e116460 --- /dev/null +++ b/pydatastructs/meson.build @@ -0,0 +1,10 @@ +python = import('python').find_installation(pure: false) + +python.install_sources(['__init__.py'], subdir: 'pydatastructs') + +subdir('utils') +subdir('linear_data_structures') +subdir('miscellaneous_data_structures') +subdir('trees') +subdir('graphs') +subdir('strings') diff --git a/pydatastructs/miscellaneous_data_structures/__init__.py b/pydatastructs/miscellaneous_data_structures/__init__.py index 60754c413..6ed099769 100644 --- a/pydatastructs/miscellaneous_data_structures/__init__.py +++ b/pydatastructs/miscellaneous_data_structures/__init__.py @@ -6,7 +6,6 @@ queue, disjoint_set, sparse_table, - _extensions, ) from .binomial_trees import ( diff --git a/pydatastructs/miscellaneous_data_structures/meson.build b/pydatastructs/miscellaneous_data_structures/meson.build new file mode 100644 index 000000000..644ec7e3b --- /dev/null +++ b/pydatastructs/miscellaneous_data_structures/meson.build @@ -0,0 +1,30 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'algorithms.py', + 'multiset.py', + 'sparse_table.py', + 'disjoint_set.py', + 'queue.py', + 'binomial_trees.py', + 'segment_tree.py', + 'stack.py' + ], + subdir: 'pydatastructs/miscellaneous_data_structures' +) + +python.install_sources( + ['_backend/__init__.py', '_backend/cpp/__init__.py'], + subdir: 'pydatastructs/miscellaneous_data_structures/_backend' +) + +python.extension_module( + '_stack', + '_backend/cpp/stack/stack.cpp', + install: true, + subdir: 'pydatastructs/miscellaneous_data_structures/_backend/cpp' +) + +subdir('tests') diff --git a/pydatastructs/miscellaneous_data_structures/tests/meson.build b/pydatastructs/miscellaneous_data_structures/tests/meson.build new file mode 100644 index 000000000..9841338be --- /dev/null +++ b/pydatastructs/miscellaneous_data_structures/tests/meson.build @@ -0,0 +1,16 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'test_binomial_trees.py', + 'test_disjoint_set.py', + 'test_multiset.py', + 'test_queue.py', + 'test_range_query_dynamic.py', + 'test_range_query_static.py', + 'test_stack.py' + ], + subdir: 'pydatastructs/miscellaneous_data_structures/tests', + install_tag: 'tests' +) diff --git a/pydatastructs/strings/meson.build b/pydatastructs/strings/meson.build new file mode 100644 index 000000000..5a588232d --- /dev/null +++ b/pydatastructs/strings/meson.build @@ -0,0 +1,12 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'algorithms.py', + 'trie.py' + ], + subdir: 'pydatastructs/strings' +) + +subdir('tests') diff --git a/pydatastructs/strings/tests/meson.build b/pydatastructs/strings/tests/meson.build new file mode 100644 index 000000000..30f1da937 --- /dev/null +++ b/pydatastructs/strings/tests/meson.build @@ -0,0 +1,11 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'test_algorithms.py', + 'test_trie.py' + ], + subdir: 'pydatastructs/strings/tests', + install_tag: 'tests' +) diff --git a/pydatastructs/trees/__init__.py b/pydatastructs/trees/__init__.py index 1c99cca25..892730122 100644 --- a/pydatastructs/trees/__init__.py +++ b/pydatastructs/trees/__init__.py @@ -5,7 +5,6 @@ m_ary_trees, space_partitioning_trees, heaps, - _extensions ) from .binary_trees import ( diff --git a/pydatastructs/trees/_backend/__init__.py b/pydatastructs/trees/_backend/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pydatastructs/trees/_backend/cpp/__init__.py b/pydatastructs/trees/_backend/cpp/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pydatastructs/trees/meson.build b/pydatastructs/trees/meson.build new file mode 100644 index 000000000..bcaae16ae --- /dev/null +++ b/pydatastructs/trees/meson.build @@ -0,0 +1,26 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'binary_trees.py', + 'heaps.py', + 'm_ary_trees.py', + 'space_partitioning_trees.py' + ], + subdir: 'pydatastructs/trees' +) + +python.install_sources( + ['_backend/__init__.py', '_backend/cpp/__init__.py'], + subdir: 'pydatastructs/trees/_backend' +) + +python.extension_module( + '_trees', + '_backend/cpp/trees.cpp', + install: true, + subdir: 'pydatastructs/trees/_backend/cpp' +) + +subdir('tests') diff --git a/pydatastructs/trees/tests/meson.build b/pydatastructs/trees/tests/meson.build new file mode 100644 index 000000000..fcafdff37 --- /dev/null +++ b/pydatastructs/trees/tests/meson.build @@ -0,0 +1,14 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'benchmarks/test_binary_trees.py', + 'test_binary_trees.py', + 'test_heaps.py', + 'test_m_ary_trees.py', + 'test_space_partitioning_tree.py' + ], + subdir: 'pydatastructs/trees/tests', + install_tag: 'tests' +) diff --git a/pydatastructs/utils/__init__.py b/pydatastructs/utils/__init__.py index 20a8c750c..c4971be32 100644 --- a/pydatastructs/utils/__init__.py +++ b/pydatastructs/utils/__init__.py @@ -3,7 +3,6 @@ from . import ( misc_util, testing_util, - _extensions ) from .misc_util import ( diff --git a/pydatastructs/utils/_backend/__init__.py b/pydatastructs/utils/_backend/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pydatastructs/utils/_backend/cpp/__init__.py b/pydatastructs/utils/_backend/cpp/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pydatastructs/utils/meson.build b/pydatastructs/utils/meson.build new file mode 100644 index 000000000..cdc466028 --- /dev/null +++ b/pydatastructs/utils/meson.build @@ -0,0 +1,32 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'misc_util.py', + 'raises_util.py', + 'testing_util.py' + ], + subdir: 'pydatastructs/utils' +) + +python.install_sources( + ['_backend/__init__.py', '_backend/cpp/__init__.py'], + subdir: 'pydatastructs/utils/_backend' +) + +python.extension_module( + '_nodes', + '_backend/cpp/nodes.cpp', + install: true, + subdir: 'pydatastructs/utils/_backend/cpp' +) + +python.extension_module( + '_graph_utils', + '_backend/cpp/graph_utils.cpp', + install: true, + subdir: 'pydatastructs/utils/_backend/cpp' +) + +subdir('tests') diff --git a/pydatastructs/utils/tests/meson.build b/pydatastructs/utils/tests/meson.build new file mode 100644 index 000000000..880f40987 --- /dev/null +++ b/pydatastructs/utils/tests/meson.build @@ -0,0 +1,11 @@ +python = import('python').find_installation(pure: false) + +python.install_sources( + [ + '__init__.py', + 'test_misc_util.py', + 'test_code_quality.py' + ], + subdir: 'pydatastructs/utils/tests', + install_tag: 'tests' +) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..c2ee41443 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = ["meson-python"] +build-backend = "mesonpy" + +[project] +name = "pydatastructs" +version = "1.0.1.dev0" +description = "Data structures and algorithms implemented using Python and C++" +readme = "README.md" +requires-python = ">=3.8" + +[tool.spin] +package = "pydatastructs" + +[tool.spin.commands] +Build = ["spin.cmds.meson.build"] +Test = ["spin.cmds.meson.test"] diff --git a/requirements.txt b/requirements.txt index a8b867d7c..9855a419e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ codecov pytest pytest-cov +spin +meson