Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit 0ee0cc9

Browse files
committed
added AM_VERSION constant, added to module
1 parent b8b917e commit 0ee0cc9

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

arraymap.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,20 +2105,21 @@ PyInit_arraymap(void)
21052105
return NULL;
21062106
}
21072107

2108-
PyObject *arraymap = PyModule_Create(&arraymap_module);
2108+
PyObject *m = PyModule_Create(&arraymap_module);
21092109
if (
2110-
!arraymap
2110+
!m
2111+
|| PyModule_AddStringConstant(m, "__version__", Py_STRINGIFY(AM_VERSION))
21112112
|| PyType_Ready(&AMType)
21122113
|| PyType_Ready(&FAMIType)
21132114
|| PyType_Ready(&FAMVType)
21142115
|| PyType_Ready(&FAMType)
2115-
|| PyModule_AddObject(arraymap, "AutoMap", (PyObject *)&AMType)
2116-
|| PyModule_AddObject(arraymap, "FrozenAutoMap", (PyObject *)&FAMType)
2117-
|| PyModule_AddObject(arraymap, "NonUniqueError", NonUniqueError)
2116+
|| PyModule_AddObject(m, "AutoMap", (PyObject *)&AMType)
2117+
|| PyModule_AddObject(m, "FrozenAutoMap", (PyObject *)&FAMType)
2118+
|| PyModule_AddObject(m, "NonUniqueError", NonUniqueError)
21182119
) {
2119-
Py_XDECREF(arraymap);
2120+
Py_XDECREF(m);
21202121
return NULL;
21212122
}
2122-
return arraymap;
2123+
return m;
21232124
}
21242125

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import site
44
import os
55

6+
7+
AM_VERSION = "0.1.1"
8+
9+
610
with open("README.md") as file:
711
LONG_DESCRIPTION = file.read()
812

@@ -21,12 +25,14 @@ def get_ext_dir(*components: tp.Iterable[str]) -> tp.Sequence[str]:
2125
["arraymap.c"],
2226
include_dirs=get_ext_dir("numpy", "core", "include"),
2327
library_dirs=get_ext_dir("numpy", "core", "lib"),
28+
define_macros=[("AM_VERSION", AM_VERSION)],
2429
libraries=["npymath"], # not including mlib at this time
2530
)
2631

2732

2833
setuptools.setup(
2934
author="Christopher Ariza, Brandt Bucher",
35+
version=AM_VERSION,
3036
description="Dictionary-like lookup from NumPy array values to their integer positions",
3137
ext_modules=[extension],
3238
license="MIT",
@@ -35,5 +41,4 @@ def get_ext_dir(*components: tp.Iterable[str]) -> tp.Sequence[str]:
3541
name="arraymap",
3642
python_requires=">=3.7.0",
3743
url="https://github.com/static-frame/arraymap",
38-
version="0.1.0",
3944
)

tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ def build(context):
2828

2929
@invoke.task(build)
3030
def test(context):
31-
run(context, f"{sys.executable} -m pytest -v")
31+
run(context, f"{sys.executable} -m pytest")

test/test_unit.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
from arraymap import FrozenAutoMap
99
from arraymap import NonUniqueError
1010

11+
def test_version():
12+
import arraymap
13+
assert isinstance(arraymap.__version__, str)
14+
15+
16+
# ------------------------------------------------------------------------------
17+
1118

1219
def test_am_extend():
1320
am1 = AutoMap(("a", "b"))

0 commit comments

Comments
 (0)