Skip to content

Commit

Permalink
bump major version, add backend metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Mar 13, 2024
1 parent 788e73d commit e631d2a
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cuvec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")
Expand Down
4 changes: 2 additions & 2 deletions cuvec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
1 change: 1 addition & 0 deletions cuvec/cpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions cuvec/pybind11.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 1 addition & 3 deletions cuvec/src/cpython.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Python.h>
Expand Down Expand Up @@ -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);

Expand Down
9 changes: 9 additions & 0 deletions cuvec/src/cuvec_swig.i
Original file line number Diff line number Diff line change
Expand Up @@ -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__[];
2 changes: 1 addition & 1 deletion cuvec/src/example_cpython/example_mod.cu
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion cuvec/src/example_pybind11/example_pybind11.cu
Original file line number Diff line number Diff line change
@@ -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.h> // pybind11, PYBIND11_MODULE
Expand Down
2 changes: 1 addition & 1 deletion cuvec/src/example_swig/example_swig.cu
Original file line number Diff line number Diff line change
@@ -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 <stdexcept> // std::length_error
Expand Down
5 changes: 3 additions & 2 deletions cuvec/src/pybind11.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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/pybind11.h> // PYBIND11_MODULE
Expand All @@ -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";
}
1 change: 1 addition & 0 deletions cuvec/swig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
8 changes: 8 additions & 0 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]))
Expand Down

0 comments on commit e631d2a

Please sign in to comment.