arborenum 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: arborenum
3
+ Version: 0.1.0
4
+ Summary: Exact, approximate, and anytime decision tree Rashomon sets over binary and continuous features
5
+ Requires-Python: >=3.9
6
+ Requires-Dist: numpy
@@ -0,0 +1,10 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel", "pybind11>=2.10"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "arborenum"
7
+ version = "0.1.0"
8
+ description = "Exact, approximate, and anytime decision tree Rashomon sets over binary and continuous features"
9
+ requires-python = ">=3.9"
10
+ dependencies = ["numpy"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,158 @@
1
+ import os
2
+ import platform
3
+
4
+ from setuptools import setup, Extension, find_packages
5
+ from setuptools.command.build_ext import build_ext
6
+
7
+ import pybind11
8
+
9
+
10
+ def is_truthy_env(name: str) -> bool:
11
+ return os.environ.get(name, "").lower() in ("1", "true", "yes", "on")
12
+
13
+
14
+ class BuildExt(build_ext):
15
+ c_opts = {
16
+ "msvc": [
17
+ "/O2",
18
+ "/std:c++20",
19
+ "/DNDEBUG",
20
+ ],
21
+ "unix": [
22
+ "-O3",
23
+ "-DNDEBUG",
24
+ "-funroll-loops",
25
+ ],
26
+ }
27
+
28
+ l_opts = {
29
+ "msvc": [],
30
+ "unix": [],
31
+ }
32
+
33
+ def build_extensions(self):
34
+ ct = self.compiler.compiler_type
35
+ system = platform.system().lower() # linux, darwin, windows
36
+ machine = platform.machine().lower() # x86_64, amd64, arm64, aarch64
37
+
38
+ opts = self.c_opts.get(ct, []).copy()
39
+ link_opts = self.l_opts.get(ct, []).copy()
40
+
41
+ native = is_truthy_env("NATIVE")
42
+ zen4 = is_truthy_env("ZEN4")
43
+ avx512 = is_truthy_env("AVX512")
44
+ aggressive = is_truthy_env("AGGRESSIVE")
45
+
46
+ if ct == "unix":
47
+ opts += [
48
+ "-std=c++20",
49
+ "-fPIC",
50
+ ]
51
+
52
+ # LTO is usually helpful on Linux, but often annoying on macOS.
53
+ if system != "darwin":
54
+ opts += ["-flto"]
55
+ link_opts += ["-flto", "-lm"]
56
+
57
+ if machine in ("x86_64", "amd64"):
58
+ if native:
59
+ opts += [
60
+ "-march=native",
61
+ "-mtune=native",
62
+ ]
63
+ print("** Building ArborEnum with -march=native -mtune=native")
64
+
65
+ elif zen4:
66
+ opts += [
67
+ "-march=znver4",
68
+ "-mtune=znver4",
69
+ ]
70
+ print("** Building ArborEnum for AMD Zen 4 / EPYC Genoa")
71
+
72
+ elif avx512:
73
+ opts += [
74
+ "-mpopcnt",
75
+ "-mbmi",
76
+ "-mbmi2",
77
+ "-mlzcnt",
78
+ "-mavx512f",
79
+ "-mavx512dq",
80
+ "-mavx512bw",
81
+ "-mavx512vl",
82
+ "-mavx512vpopcntdq",
83
+ ]
84
+ print("** Building ArborEnum with explicit AVX-512 VPOPCNTDQ flags")
85
+
86
+ elif aggressive:
87
+ opts += [
88
+ "-mpopcnt",
89
+ "-mbmi",
90
+ "-mbmi2",
91
+ "-mlzcnt",
92
+ "-mavx2",
93
+ ]
94
+ print("** Building ArborEnum with aggressive x86 AVX2/BMI flags")
95
+
96
+ else:
97
+ opts += [
98
+ "-mpopcnt",
99
+ ]
100
+ print("** Building ArborEnum with x86 POPCNT support")
101
+
102
+ elif machine in ("arm64", "aarch64"):
103
+ # ARM64 has efficient bit operations through compiler codegen / NEON.
104
+ if native:
105
+ opts += [
106
+ "-mcpu=native",
107
+ ]
108
+ print("** Building ArborEnum on ARM64 with -mcpu=native")
109
+ elif aggressive:
110
+ print("** AGGRESSIVE requested on ARM64; no extra portable flags added")
111
+ else:
112
+ print("** Building ArborEnum on ARM64; skipping x86-specific flags")
113
+
114
+ else:
115
+ print(
116
+ f"** Building ArborEnum on unknown Unix arch {machine}; "
117
+ "skipping architecture-specific flags"
118
+ )
119
+
120
+ elif ct == "msvc":
121
+ # MSVC maps __popcnt64 through <intrin.h>
122
+ if native or zen4 or avx512 or aggressive:
123
+ print("** SIMD env flag requested with MSVC; using safe MSVC flags")
124
+ else:
125
+ print("** Building ArborEnum with MSVC safe optimized flags")
126
+
127
+ for ext in self.extensions:
128
+ ext.extra_compile_args = opts
129
+ ext.extra_link_args = link_opts
130
+
131
+ print("** extra_compile_args:", " ".join(opts))
132
+ print("** extra_link_args:", " ".join(link_opts))
133
+
134
+ build_ext.build_extensions(self)
135
+
136
+
137
+ ext_modules = [
138
+ Extension(
139
+ "arborenum._core",
140
+ sources=[
141
+ "src/arborenum/_core.cpp",
142
+ ],
143
+ include_dirs=[
144
+ pybind11.get_include(),
145
+ "src/arborenum",
146
+ "src/arborenum/cpp",
147
+ ],
148
+ language="c++",
149
+ ),
150
+ ]
151
+
152
+
153
+ setup(
154
+ packages=find_packages(where="src"),
155
+ package_dir={"": "src"},
156
+ ext_modules=ext_modules,
157
+ cmdclass={"build_ext": BuildExt},
158
+ )