From e631d2a2c16dbdb97405d7fff7d1d593c4ff6258 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Wed, 13 Mar 2024 13:06:10 +0000 Subject: [PATCH] bump major version, add backend metadata --- cuvec/CMakeLists.txt | 2 +- cuvec/__init__.py | 4 ++-- cuvec/cpython.py | 1 + cuvec/pybind11.py | 1 + cuvec/src/cpython.cu | 4 +--- cuvec/src/cuvec_swig.i | 9 +++++++++ cuvec/src/example_cpython/example_mod.cu | 2 +- cuvec/src/example_pybind11/example_pybind11.cu | 2 +- cuvec/src/example_swig/example_swig.cu | 2 +- cuvec/src/pybind11.cu | 5 +++-- cuvec/swig.py | 1 + pyproject.toml | 2 +- tests/test_common.py | 8 ++++++++ 13 files changed, 31 insertions(+), 12 deletions(-) diff --git a/cuvec/CMakeLists.txt b/cuvec/CMakeLists.txt index 153d5c3..d893d4c 100644 --- a/cuvec/CMakeLists.txt +++ b/cuvec/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.24 FATAL_ERROR) if(NOT DEFINED SKBUILD_PROJECT_VERSION) - set(SKBUILD_PROJECT_VERSION 4 CACHE STRING "version" FORCE) + set(SKBUILD_PROJECT_VERSION 6 CACHE STRING "version" FORCE) endif() string(REGEX REPLACE [[([0-9]+)\.([0-9]+)\.([0-9]+).*]] [[\1.\2.\3]] SKBUILD_PROJECT_VERSION "${SKBUILD_PROJECT_VERSION}") project(cuvec LANGUAGES C CXX VERSION "${SKBUILD_PROJECT_VERSION}") diff --git a/cuvec/__init__.py b/cuvec/__init__.py index e211d1d..493b6df 100644 --- a/cuvec/__init__.py +++ b/cuvec/__init__.py @@ -3,8 +3,8 @@ Python buffered array -> C++11 `std::vector` -> CUDA managed memory. """ -__author__ = "Casper O. da Costa-Luis" -__date__ = "2021" +__author__ = "Casper da Costa-Luis (https://github.com/casperdcl)" +__date__ = "2021-2024" # version detector. Precedence: installed dist, git, 'UNKNOWN' try: from ._dist_ver import __version__ diff --git a/cuvec/cpython.py b/cuvec/cpython.py index 0e9ad73..a6d53b3 100644 --- a/cuvec/cpython.py +++ b/cuvec/cpython.py @@ -11,6 +11,7 @@ __all__ = [ 'CuVec', 'zeros', 'ones', 'zeros_like', 'ones_like', 'copy', 'asarray', 'Shape', 'typecodes'] +__author__, __date__, __version__ = cu.__author__, cu.__date__, cu.__version__ log = logging.getLogger(__name__) vec_types = { diff --git a/cuvec/pybind11.py b/cuvec/pybind11.py index 8a108c6..c0f120e 100644 --- a/cuvec/pybind11.py +++ b/cuvec/pybind11.py @@ -15,6 +15,7 @@ __all__ = [ 'CuVec', 'zeros', 'ones', 'zeros_like', 'ones_like', 'copy', 'asarray', 'Shape', 'typecodes'] +__author__, __date__, __version__ = cu.__author__, cu.__date__, cu.__version__ log = logging.getLogger(__name__) vec_types = { diff --git a/cuvec/src/cpython.cu b/cuvec/src/cpython.cu index 3d77883..593fd6d 100644 --- a/cuvec/src/cpython.cu +++ b/cuvec/src/cpython.cu @@ -2,8 +2,6 @@ * Unifying Python/C++/CUDA memory. * * Python buffered array -> C++11 `std::vector` -> CUDA managed memory. - * - * Copyright (2021) Casper da Costa-Luis */ #include "cuvec_cpython.cuh" // PyCuVec, PyCuVec_tp #include @@ -84,7 +82,7 @@ PyMODINIT_FUNC PyInit_cuvec_cpython(void) { if (author == NULL) return NULL; PyModule_AddObject(m, "__author__", author); - PyObject *date = Py_BuildValue("s", "2021"); + PyObject *date = Py_BuildValue("s", "2021-2024"); if (date == NULL) return NULL; PyModule_AddObject(m, "__date__", date); diff --git a/cuvec/src/cuvec_swig.i b/cuvec/src/cuvec_swig.i index 6da7c73..9ca0d33 100644 --- a/cuvec/src/cuvec_swig.i +++ b/cuvec/src/cuvec_swig.i @@ -56,3 +56,12 @@ MKCUVEC(_CUVEC_HALF, e) #endif MKCUVEC(float, f) MKCUVEC(double, d) + +%{ +static const char __author__[] = "Casper da Costa-Luis (https://github.com/casperdcl)"; +static const char __date__[] = "2021-2024"; +static const char __version__[] = "4.0.0"; +%} +static const char __author__[]; +static const char __date__[]; +static const char __version__[]; diff --git a/cuvec/src/example_cpython/example_mod.cu b/cuvec/src/example_cpython/example_mod.cu index df3bec4..f50f335 100644 --- a/cuvec/src/example_cpython/example_mod.cu +++ b/cuvec/src/example_cpython/example_mod.cu @@ -1,7 +1,7 @@ /** * Example external extension module using CuVec. * - * Copyright (2021) Casper da Costa-Luis + * Copyright (2021-2024) Casper da Costa-Luis */ #include "Python.h" #include "cuvec_cpython.cuh" // PyCuVec diff --git a/cuvec/src/example_pybind11/example_pybind11.cu b/cuvec/src/example_pybind11/example_pybind11.cu index f26e086..99f2c94 100644 --- a/cuvec/src/example_pybind11/example_pybind11.cu +++ b/cuvec/src/example_pybind11/example_pybind11.cu @@ -1,7 +1,7 @@ /** * Example external pybind11 extension module using CuVec. * - * Copyright (2021) Casper da Costa-Luis + * Copyright (2024) Casper da Costa-Luis */ #include "cuvec.cuh" // NDCuVec #include // pybind11, PYBIND11_MODULE diff --git a/cuvec/src/example_swig/example_swig.cu b/cuvec/src/example_swig/example_swig.cu index e2e1486..4bfc202 100644 --- a/cuvec/src/example_swig/example_swig.cu +++ b/cuvec/src/example_swig/example_swig.cu @@ -1,7 +1,7 @@ /** * Example external SWIG extension module using CuVec. * - * Copyright (2021) Casper da Costa-Luis + * Copyright (2021-2024) Casper da Costa-Luis */ #include "cuvec.cuh" // NDCuVec #include // std::length_error diff --git a/cuvec/src/pybind11.cu b/cuvec/src/pybind11.cu index fcdd4e2..064c30b 100644 --- a/cuvec/src/pybind11.cu +++ b/cuvec/src/pybind11.cu @@ -2,8 +2,6 @@ * Unifying Python/C++/CUDA memory. * * pybind11 opaque vector -> C++11 `std::vector` -> CUDA managed memory. - * - * Copyright (2024) Casper da Costa-Luis */ #include "cuvec_pybind11.cuh" // PYBIND11_BIND_NDCUVEC #include // PYBIND11_MODULE @@ -27,4 +25,7 @@ PYBIND11_MODULE(cuvec_pybind11, m) { #endif PYBIND11_BIND_NDCUVEC(float, f); PYBIND11_BIND_NDCUVEC(double, d); + m.attr("__author__") = "Casper da Costa-Luis (https://github.com/casperdcl)"; + m.attr("__date__") = "2024"; + m.attr("__version__") = "2.0.0"; } diff --git a/cuvec/swig.py b/cuvec/swig.py index 55dfe06..449e84d 100644 --- a/cuvec/swig.py +++ b/cuvec/swig.py @@ -18,6 +18,7 @@ __all__ = [ 'CuVec', 'zeros', 'ones', 'zeros_like', 'ones_like', 'copy', 'asarray', 'retarray', 'Shape', 'typecodes'] +__author__, __date__, __version__ = sw.__author__, sw.__date__, sw.__version__ log = logging.getLogger(__name__) if hasattr(sw, 'NDCuVec_e_new'): diff --git a/pyproject.toml b/pyproject.toml index 072636f..900de9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ classifiers = [ dependencies = ['importlib_resources; python_version < "3.9"', "numpy"] [project.optional-dependencies] -dev = ["pytest>=6", "pytest-cov", "pytest-timeout", "pytest-xdist"] +dev = ["pytest>=6", "pytest-cov", "pytest-timeout", "pytest-xdist", "packaging"] [tool.mypy] [[tool.mypy.overrides]] diff --git a/tests/test_common.py b/tests/test_common.py index 6476a0f..875f427 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -2,6 +2,7 @@ import logging import numpy as np +from packaging import version from pytest import importorskip, mark, raises, skip import cuvec as cu @@ -42,6 +43,13 @@ def test_cmake_prefix(): for i in ('Config', 'ConfigVersion', 'Targets', 'Targets-relwithdebinfo')} +@mark.parametrize("cu", filter(None, [cp, py, sw])) +def test_metadata(cu): + assert isinstance(cu.__author__, str) + assert isinstance(cu.__date__, str) + assert version.parse(cu.__version__).release + + @mark.parametrize("spec,result", [("i", np.int32), ("d", np.float64)]) @mark.parametrize("init", ["zeros", "ones"]) @mark.parametrize("cu", filter(None, [cp, py, sw]))