Skip to content

Commit d059d49

Browse files
committed
extended pyproject.toml, removed most of setup.py
1 parent ad4b8fa commit d059d49

File tree

3 files changed

+218
-84
lines changed

3 files changed

+218
-84
lines changed

noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def do_build(session: nox.Session) -> None:
2828
# keep -v to see warnings; no build isolation to match your invoke cmd
2929
session.run(
3030
sys.executable, "-m", "pip",
31-
"--disable-pip-version-check", "-v",
32-
"install", "--no-build-isolation", ".",
31+
"--disable-pip-version-check",
32+
"install", "-v", "--no-build-isolation", ".",
3333
external=True
3434
)
3535

pyproject.toml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,68 @@ requires = [
77
build-backend = "setuptools.build_meta"
88

99

10+
[project]
11+
name = "arraykit"
12+
version = "1.2.0"
13+
description = "Array utilities for StaticFrame"
14+
readme = { file = "README.rst", content-type = "text/x-rst" }
15+
requires-python = ">=3.10"
16+
17+
authors = [
18+
{ name = "Christopher Ariza" },
19+
{ name = "Brandt Bucher" },
20+
{ name = "Charles Burkland" },
21+
]
22+
license = "MIT"
23+
keywords = ["numpy", "array"]
24+
dependencies = [
25+
"numpy>=1.24.3",
26+
]
27+
classifiers = [
28+
"Development Status :: 5 - Production/Stable",
29+
"Intended Audience :: Developers",
30+
"Topic :: Software Development",
31+
"Programming Language :: C",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Operating System :: MacOS :: MacOS X",
34+
"Operating System :: Microsoft :: Windows",
35+
"Operating System :: POSIX",
36+
"Programming Language :: Python :: 3.10",
37+
"Programming Language :: Python :: 3.11",
38+
"Programming Language :: Python :: 3.12",
39+
"Programming Language :: Python :: 3.13",
40+
"Programming Language :: Python :: 3.14",
41+
"Programming Language :: Python :: Free Threading",
42+
"Typing :: Typed",
43+
]
44+
45+
[project.urls]
46+
Homepage = "https://github.com/static-frame/arraykit"
47+
48+
[tool.setuptools]
49+
# Your src layout is already “src/” but package_dir currently maps the top-level
50+
# module "arraykit" to "src". Keep that mapping explicitly:
51+
package-dir = { "arraykit" = "src" }
52+
53+
[tool.setuptools.package-data]
54+
arraykit = ["__init__.pyi", "py.typed"]
55+
56+
# Define your C extension here. We'll add NumPy's include/lib paths dynamically
57+
# via a tiny setup.py shim (below).
58+
# [tool.setuptools.ext-modules."arraykit._arraykit"]
59+
# sources = [
60+
# "src/_arraykit.c",
61+
# "src/array_go.c",
62+
# "src/array_to_tuple.c",
63+
# "src/block_index.c",
64+
# "src/delimited_to_arrays.c",
65+
# "src/methods.c",
66+
# "src/tri_map.c",
67+
# "src/auto_map.c",
68+
# ]
69+
# include-dirs = ["src"]
70+
# define-macros = [["AK_VERSION", "1.2.0"]]
71+
72+
# # If you truly need to link to 'npymath', leave libraries empty here and let the
73+
# # setup.py shim add it only when/where it exists.
74+
# libraries = ["npymath"] # (we'll add dynamically in the shim if present)

setup.py

Lines changed: 151 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,8 @@
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

347
def 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

Comments
 (0)