1- import site
2- import os
3- from os import path
4- import typing as tp
5- from setuptools import Extension # type: ignore
6- from setuptools import setup
7-
8- AK_VERSION = '1.2.0'
9-
10- ROOT_DIR_FP = path .abspath (path .dirname (__file__ ))
11-
12- def get_long_description () -> str :
13- with open (path .join (ROOT_DIR_FP , 'README.rst' ), encoding = 'utf-8' ) as f :
14- msg = []
15- collect = False
16- start = - 1
17- for i , line in enumerate (f ):
18- if line .startswith ('arraykit' ):
19- start = i + 2 # skip this line and the next
20- if i == start :
21- collect = True
22- if collect :
23- msg .append (line )
24- return '' .join (msg ).strip ()
25-
26-
27- # NOTE: we do this to avoid importing numpy: https://stackoverflow.com/questions/54117786/add-numpy-get-include-argument-to-setuptools-without-preinstalled-numpy
28- # we used to import the following to get directories:
29- # from numpy.distutils.misc_util import get_info
30- # import numpy as np # type: ignore
31- # get_info('npymath')['library_dirs']
32- # get_info('npymath')['libraries']
1+ from setuptools import setup , Extension
2+ from setuptools .command .build_ext import build_ext
3+ import site , os
4+
5+ AK_VERSION = "1.2.0"
336
347def get_ext_dir (* components : tp .Iterable [str ]) -> tp .Sequence [str ]:
358 dirs = []
@@ -39,58 +12,154 @@ def get_ext_dir(*components: tp.Iterable[str]) -> tp.Sequence[str]:
3912 dirs .append (fp )
4013 return dirs
4114
42- ak_extension = Extension (
43- name = 'arraykit._arraykit' , # build into module
15+ # subclass build_ext to append NumPy's include path at build time
16+ # class build_ext_numpy(build_ext):
17+ # def finalize_options(self):
18+ # super().finalize_options()
19+ # import numpy # available thanks to [build-system].requires
20+ # self.include_dirs.append(numpy.get_include())
21+
22+ # # If (and only if) you truly need to link npymath, try to discover it.
23+ # # Many extensions don't need this anymore. Safe to remove if unused.
24+ # try:
25+ # import os
26+ # import numpy.core as npcore
27+ # get_lib = getattr(npcore, "get_lib", None)
28+ # if callable(get_lib):
29+ # libdir = get_lib()
30+ # if libdir and os.path.isdir(libdir):
31+ # self.library_dirs.append(libdir)
32+ # # add once
33+ # libs = set(self.libraries or [])
34+ # if "npymath" not in libs:
35+ # self.libraries = list(libs | {"npymath"})
36+ # except Exception:
37+ # pass
38+
39+ ext_modules = [
40+ Extension (
41+ name = "arraykit._arraykit" ,
4442 sources = [
45- ' src/_arraykit.c' ,
46- ' src/array_go.c' ,
47- ' src/array_to_tuple.c' ,
48- ' src/block_index.c' ,
49- ' src/delimited_to_arrays.c' ,
50- ' src/methods.c' ,
51- ' src/tri_map.c' ,
52- ' src/auto_map.c' ,
43+ " src/_arraykit.c" ,
44+ " src/array_go.c" ,
45+ " src/array_to_tuple.c" ,
46+ " src/block_index.c" ,
47+ " src/delimited_to_arrays.c" ,
48+ " src/methods.c" ,
49+ " src/tri_map.c" ,
50+ " src/auto_map.c" ,
5351 ],
52+
5453 include_dirs = get_ext_dir ('numpy' , '_core' , 'include' ) + ['src' ],
5554 library_dirs = get_ext_dir ('numpy' , '_core' , 'lib' ),
5655 define_macros = [("AK_VERSION" , AK_VERSION )],
57- libraries = ['npymath' ], # not including mlib at this time
58- )
59-
60- setup (
61- name = 'arraykit' ,
62- version = AK_VERSION ,
63- description = 'Array utilities for StaticFrame' ,
64- long_description = get_long_description (),
65- long_description_content_type = 'text/x-rst' , # use text/x-rst
66- python_requires = '>=3.10' ,
67- install_requires = ['numpy>=1.24.3' ],
68- url = 'https://github.com/static-frame/arraykit' ,
69- author = 'Christopher Ariza, Brandt Bucher, Charles Burkland' ,
70- license = 'MIT' ,
71- # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
72- classifiers = [
73- 'Development Status :: 5 - Production/Stable' ,
74- 'Intended Audience :: Developers' ,
75- 'Topic :: Software Development' ,
76- "Programming Language :: C" ,
77- "Programming Language :: Python :: Implementation :: CPython" ,
78- 'License :: OSI Approved :: MIT License' ,
79- 'Operating System :: MacOS :: MacOS X' ,
80- 'Operating System :: Microsoft :: Windows' ,
81- 'Operating System :: POSIX' ,
82- 'Programming Language :: Python :: 3.10' ,
83- 'Programming Language :: Python :: 3.11' ,
84- 'Programming Language :: Python :: 3.12' ,
85- 'Programming Language :: Python :: 3.13' ,
86- 'Programming Language :: Python :: 3.14' ,
87- 'Programming Language :: Python :: Free Threading' ,
88- 'Typing :: Typed' ,
89- ],
90- keywords = 'numpy array' ,
91- packages = ['arraykit' ],
92- package_dir = {'arraykit' : 'src' },
93- package_data = {'arraykit' : ['__init__.pyi' , 'py.typed' ]},
94- include_package_data = True ,
95- ext_modules = [ak_extension ],
96- )
56+ libraries = ["npymath" ],
57+ )
58+ ]
59+
60+
61+ setup (ext_modules = ext_modules )
62+
63+
64+ # no metadata here—keep that in pyproject.toml
65+ # setup(ext_modules=ext_modules, cmdclass={"build_ext": build_ext_numpy})
66+
67+
68+
69+
70+ # import site
71+ # import os
72+ # from os import path
73+ # import typing as tp
74+ # from setuptools import Extension # type: ignore
75+ # from setuptools import setup
76+
77+ # AK_VERSION = '1.2.0'
78+
79+ # ROOT_DIR_FP = path.abspath(path.dirname(__file__))
80+
81+ # def get_long_description() -> str:
82+ # with open(path.join(ROOT_DIR_FP, 'README.rst'), encoding='utf-8') as f:
83+ # msg = []
84+ # collect = False
85+ # start = -1
86+ # for i, line in enumerate(f):
87+ # if line.startswith('arraykit'):
88+ # start = i + 2 # skip this line and the next
89+ # if i == start:
90+ # collect = True
91+ # if collect:
92+ # msg.append(line)
93+ # return ''.join(msg).strip()
94+
95+
96+ # # NOTE: we do this to avoid importing numpy: https://stackoverflow.com/questions/54117786/add-numpy-get-include-argument-to-setuptools-without-preinstalled-numpy
97+ # # we used to import the following to get directories:
98+ # # from numpy.distutils.misc_util import get_info
99+ # # import numpy as np # type: ignore
100+ # # get_info('npymath')['library_dirs']
101+ # # get_info('npymath')['libraries']
102+
103+ # def get_ext_dir(*components: tp.Iterable[str]) -> tp.Sequence[str]:
104+ # dirs = []
105+ # for sp in site.getsitepackages():
106+ # fp = os.path.join(sp, *components)
107+ # if os.path.exists(fp):
108+ # dirs.append(fp)
109+ # return dirs
110+
111+ # ak_extension = Extension(
112+ # name='arraykit._arraykit', # build into module
113+ # sources=[
114+ # 'src/_arraykit.c',
115+ # 'src/array_go.c',
116+ # 'src/array_to_tuple.c',
117+ # 'src/block_index.c',
118+ # 'src/delimited_to_arrays.c',
119+ # 'src/methods.c',
120+ # 'src/tri_map.c',
121+ # 'src/auto_map.c',
122+ # ],
123+ # include_dirs=get_ext_dir('numpy', '_core', 'include') + ['src'],
124+ # library_dirs=get_ext_dir('numpy', '_core', 'lib'),
125+ # define_macros=[("AK_VERSION", AK_VERSION)],
126+ # libraries=['npymath'], # not including mlib at this time
127+ # )
128+
129+ # setup(
130+ # name='arraykit',
131+ # version=AK_VERSION,
132+ # description='Array utilities for StaticFrame',
133+ # long_description=get_long_description(),
134+ # long_description_content_type='text/x-rst', # use text/x-rst
135+ # python_requires='>=3.10',
136+ # install_requires=['numpy>=1.24.3'],
137+ # url='https://github.com/static-frame/arraykit',
138+ # author='Christopher Ariza, Brandt Bucher, Charles Burkland',
139+ # license='MIT',
140+ # # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
141+ # classifiers=[
142+ # 'Development Status :: 5 - Production/Stable',
143+ # 'Intended Audience :: Developers',
144+ # 'Topic :: Software Development',
145+ # "Programming Language :: C",
146+ # "Programming Language :: Python :: Implementation :: CPython",
147+ # 'License :: OSI Approved :: MIT License',
148+ # 'Operating System :: MacOS :: MacOS X',
149+ # 'Operating System :: Microsoft :: Windows',
150+ # 'Operating System :: POSIX',
151+ # 'Programming Language :: Python :: 3.10',
152+ # 'Programming Language :: Python :: 3.11',
153+ # 'Programming Language :: Python :: 3.12',
154+ # 'Programming Language :: Python :: 3.13',
155+ # 'Programming Language :: Python :: 3.14',
156+ # 'Programming Language :: Python :: Free Threading',
157+ # 'Typing :: Typed',
158+ # ],
159+ # keywords='numpy array',
160+ # packages=['arraykit'],
161+ # package_dir={'arraykit': 'src'},
162+ # package_data={'arraykit': ['__init__.pyi', 'py.typed']},
163+ # include_package_data=True,
164+ # ext_modules=[ak_extension],
165+ # )
0 commit comments