hapc 0.1.5__tar.gz → 0.2.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.
- {hapc-0.1.5 → hapc-0.2.0}/CMakeLists.txt +13 -2
- {hapc-0.1.5/python/hapc.egg-info → hapc-0.2.0}/PKG-INFO +1 -1
- {hapc-0.1.5 → hapc-0.2.0}/pyproject.toml +1 -1
- {hapc-0.1.5 → hapc-0.2.0}/python/hapc/__init__.py +1 -1
- {hapc-0.1.5 → hapc-0.2.0}/python/hapc/core.py +1 -13
- {hapc-0.1.5 → hapc-0.2.0/python/hapc.egg-info}/PKG-INFO +1 -1
- {hapc-0.1.5 → hapc-0.2.0}/python/hapc.egg-info/SOURCES.txt +1 -0
- hapc-0.2.0/python/hapc.egg-info/not-zip-safe +1 -0
- hapc-0.2.0/python/hapc.egg-info/top_level.txt +2 -0
- hapc-0.2.0/setup.py +89 -0
- hapc-0.1.5/python/hapc.egg-info/top_level.txt +0 -1
- hapc-0.1.5/setup.py +0 -123
- {hapc-0.1.5 → hapc-0.2.0}/LICENSE +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/MANIFEST.in +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/README.md +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/python/demo_single.py +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/python/hapc/cv.py +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/python/hapc/single.py +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/python/hapc.egg-info/dependency_links.txt +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/python/hapc.egg-info/requires.txt +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/python/test_install.py +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/setup.cfg +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/bindings.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/cross_kernel.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/cv_classi.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/cv_fast_pchal.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/cv_fast_pchal_python.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/fast_pchal.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/hapc_core.hpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/logistic_call.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/mkernel.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/pcghal_call.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/pcghal_classi_call.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/pcghal_cv.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/pcghal_cv_cpp.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/pchal_design.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/r_bindings.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/ridge_wrappers.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/single_pcghal.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/single_pcghal_cpp.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/src/single_pchar.cpp +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/tests/test_api.py +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/tests/test_core.py +0 -0
- {hapc-0.1.5 → hapc-0.2.0}/tests/test_r_vs_python_alpha.py +0 -0
|
@@ -4,6 +4,8 @@ project(hapc)
|
|
|
4
4
|
set(CMAKE_CXX_STANDARD 17)
|
|
5
5
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
6
|
|
|
7
|
+
include(FetchContent)
|
|
8
|
+
|
|
7
9
|
# Windows: Add vcpkg to CMAKE_PREFIX_PATH if it exists
|
|
8
10
|
if(WIN32 AND EXISTS "C:/vcpkg")
|
|
9
11
|
list(APPEND CMAKE_PREFIX_PATH "C:/vcpkg/installed/x64-windows")
|
|
@@ -12,8 +14,17 @@ endif()
|
|
|
12
14
|
# Find Python
|
|
13
15
|
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
|
|
14
16
|
|
|
15
|
-
# Find Eigen3
|
|
16
|
-
find_package(Eigen3
|
|
17
|
+
# Find Eigen3 with fallback to FetchContent for Windows
|
|
18
|
+
find_package(Eigen3 QUIET NO_MODULE)
|
|
19
|
+
if(NOT Eigen3_FOUND)
|
|
20
|
+
message(STATUS "Eigen3 not found, downloading via FetchContent...")
|
|
21
|
+
FetchContent_Declare(
|
|
22
|
+
Eigen3
|
|
23
|
+
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
|
|
24
|
+
URL_HASH SHA256=8586084f71f9bde545ee7fa6d00288b264a2b7ac3607b974e54d13e7162c1c72
|
|
25
|
+
)
|
|
26
|
+
FetchContent_MakeAvailable(Eigen3)
|
|
27
|
+
endif()
|
|
17
28
|
|
|
18
29
|
# Find pybind11 via Python
|
|
19
30
|
execute_process(
|
|
@@ -5,19 +5,7 @@ from typing import NamedTuple, Optional
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
try:
|
|
10
|
-
# This is the standard way for an installed package
|
|
11
|
-
from . import hapc_core
|
|
12
|
-
except ImportError:
|
|
13
|
-
# Fallback for development mode
|
|
14
|
-
try:
|
|
15
|
-
import hapc_core
|
|
16
|
-
except ImportError:
|
|
17
|
-
raise ImportError(
|
|
18
|
-
"hapc_core module not found. The C++ extension may not be built.\n"
|
|
19
|
-
"Try: pip install -e . --force-reinstall --no-cache-dir"
|
|
20
|
-
)
|
|
8
|
+
from . import hapc_core
|
|
21
9
|
|
|
22
10
|
class DesignOutput(NamedTuple):
|
|
23
11
|
"""Output from pchal_design."""
|
|
@@ -13,6 +13,7 @@ python/hapc/single.py
|
|
|
13
13
|
python/hapc.egg-info/PKG-INFO
|
|
14
14
|
python/hapc.egg-info/SOURCES.txt
|
|
15
15
|
python/hapc.egg-info/dependency_links.txt
|
|
16
|
+
python/hapc.egg-info/not-zip-safe
|
|
16
17
|
python/hapc.egg-info/requires.txt
|
|
17
18
|
python/hapc.egg-info/top_level.txt
|
|
18
19
|
src/bindings.cpp
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
hapc-0.2.0/setup.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Setup for HAPC package (root level for remote installation)."""
|
|
2
|
+
|
|
3
|
+
from setuptools import setup, find_packages, Extension
|
|
4
|
+
from setuptools.command.build_ext import build_ext
|
|
5
|
+
import os
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
class CMakeExtension(Extension):
|
|
11
|
+
def __init__(self, name, sourcedir=''):
|
|
12
|
+
Extension.__init__(self, name, sources=[])
|
|
13
|
+
self.sourcedir = os.path.abspath(sourcedir)
|
|
14
|
+
|
|
15
|
+
class CMakeBuild(build_ext):
|
|
16
|
+
def run(self):
|
|
17
|
+
try:
|
|
18
|
+
out = subprocess.check_output(['cmake', '--version'])
|
|
19
|
+
except OSError:
|
|
20
|
+
raise RuntimeError("CMake must be installed to build the following extensions: " +
|
|
21
|
+
", ".join(e.name for e in self.extensions))
|
|
22
|
+
|
|
23
|
+
for ext in self.extensions:
|
|
24
|
+
self.build_extension(ext)
|
|
25
|
+
|
|
26
|
+
def build_extension(self, ext):
|
|
27
|
+
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
|
|
28
|
+
# required for auto-detection of auxiliary "native" libs
|
|
29
|
+
if not extdir.endswith(os.path.sep):
|
|
30
|
+
extdir += os.path.sep
|
|
31
|
+
|
|
32
|
+
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
|
|
33
|
+
'-DPYTHON_EXECUTABLE=' + sys.executable]
|
|
34
|
+
|
|
35
|
+
cfg = 'Debug' if self.debug else 'Release'
|
|
36
|
+
build_args = ['--config', cfg]
|
|
37
|
+
|
|
38
|
+
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
|
|
39
|
+
# Add parallel build flag only on non-Windows platforms
|
|
40
|
+
# On Windows, MSBuild doesn't support -j flag and handles parallelization automatically
|
|
41
|
+
if sys.platform != 'win32':
|
|
42
|
+
build_args += ['--', '-j2']
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
env = os.environ.copy()
|
|
46
|
+
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
|
|
47
|
+
self.distribution.get_version())
|
|
48
|
+
if not os.path.exists(self.build_temp):
|
|
49
|
+
os.makedirs(self.build_temp)
|
|
50
|
+
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
|
|
51
|
+
subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
|
|
52
|
+
|
|
53
|
+
# Try to read version, fallback to default
|
|
54
|
+
version = "0.1.0"
|
|
55
|
+
init_file = Path(__file__).parent / "python" / "hapc" / "__init__.py"
|
|
56
|
+
if init_file.exists():
|
|
57
|
+
with open(init_file, "r") as f:
|
|
58
|
+
for line in f:
|
|
59
|
+
if line.startswith("__version__"):
|
|
60
|
+
version = line.split("=")[1].strip().strip('"').strip("'")
|
|
61
|
+
break
|
|
62
|
+
|
|
63
|
+
# Try to read README
|
|
64
|
+
readme_content = ""
|
|
65
|
+
readme_file = Path(__file__).parent / "README.md"
|
|
66
|
+
if readme_file.exists():
|
|
67
|
+
with open(readme_file, "r") as f:
|
|
68
|
+
readme_content = f.read()
|
|
69
|
+
|
|
70
|
+
setup(
|
|
71
|
+
name="hapc",
|
|
72
|
+
version=version,
|
|
73
|
+
description="Highly Adaptive Principal Components",
|
|
74
|
+
long_description=readme_content,
|
|
75
|
+
long_description_content_type="text/markdown",
|
|
76
|
+
author="Carlos García Meixide",
|
|
77
|
+
author_email="cgmeixide@gmail.com",
|
|
78
|
+
url="https://github.com/meixide/hapc",
|
|
79
|
+
license="MIT",
|
|
80
|
+
packages=find_packages(where="python"),
|
|
81
|
+
package_dir={"": "python"},
|
|
82
|
+
ext_modules=[CMakeExtension('hapc/hapc_core', sourcedir=os.path.dirname(os.path.abspath(__file__)))],
|
|
83
|
+
cmdclass=dict(build_ext=CMakeBuild),
|
|
84
|
+
python_requires=">=3.8",
|
|
85
|
+
# Dependencies are defined in pyproject.toml [project.dependencies]
|
|
86
|
+
# install_requires is omitted here to avoid conflicts with pyproject.toml
|
|
87
|
+
include_package_data=True,
|
|
88
|
+
zip_safe=False,
|
|
89
|
+
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hapc
|
hapc-0.1.5/setup.py
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"""Setup for HAPC package (root level for remote installation)."""
|
|
2
|
-
|
|
3
|
-
from setuptools import setup, find_packages, Extension
|
|
4
|
-
from setuptools.command.build_ext import build_ext
|
|
5
|
-
import subprocess
|
|
6
|
-
import sys
|
|
7
|
-
import os
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
class CMakeBuild(build_ext):
|
|
11
|
-
"""Custom build using CMake."""
|
|
12
|
-
def run(self):
|
|
13
|
-
try:
|
|
14
|
-
subprocess.check_output(["cmake", "--version"])
|
|
15
|
-
except OSError:
|
|
16
|
-
raise RuntimeError("CMake is required to build hapc. Install with: pip install cmake")
|
|
17
|
-
|
|
18
|
-
build_temp = Path(self.build_temp) / "cmake_build"
|
|
19
|
-
build_temp.mkdir(parents=True, exist_ok=True)
|
|
20
|
-
|
|
21
|
-
project_root = Path(__file__).parent
|
|
22
|
-
|
|
23
|
-
cmake_args = [
|
|
24
|
-
f"-DCMAKE_BUILD_TYPE=Release",
|
|
25
|
-
f"-DPYTHON_EXECUTABLE={sys.executable}",
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
subprocess.check_call(
|
|
29
|
-
["cmake", str(project_root)] + cmake_args,
|
|
30
|
-
cwd=str(build_temp)
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
subprocess.check_call(
|
|
34
|
-
["cmake", "--build", ".", "--config", "Release"],
|
|
35
|
-
cwd=str(build_temp)
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
# Copy library to package
|
|
39
|
-
lib_dir = project_root / "python" / "hapc"
|
|
40
|
-
lib_dir.mkdir(parents=True, exist_ok=True)
|
|
41
|
-
|
|
42
|
-
import glob
|
|
43
|
-
import shutil
|
|
44
|
-
import time
|
|
45
|
-
|
|
46
|
-
# Search recursively for the built library
|
|
47
|
-
# Try multiple patterns to ensure we find it on all platforms
|
|
48
|
-
search_patterns = [
|
|
49
|
-
os.path.join(str(build_temp), "**", "hapc_core.*"),
|
|
50
|
-
os.path.join(str(build_temp), "**", "*", "hapc_core.*"),
|
|
51
|
-
os.path.join(str(build_temp), "**", "*", "*", "hapc_core.*"),
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
found = False
|
|
55
|
-
for pattern in search_patterns:
|
|
56
|
-
for lib in glob.glob(pattern, recursive=True):
|
|
57
|
-
if lib.endswith(('.pyd', '.so', '.dylib')):
|
|
58
|
-
try:
|
|
59
|
-
dest = lib_dir / Path(lib).name
|
|
60
|
-
# Retry on Windows if file is locked
|
|
61
|
-
max_retries = 3
|
|
62
|
-
for attempt in range(max_retries):
|
|
63
|
-
try:
|
|
64
|
-
shutil.copy2(lib, dest)
|
|
65
|
-
print(f"[OK] Copied {lib} to {dest}")
|
|
66
|
-
found = True
|
|
67
|
-
break
|
|
68
|
-
except (OSError, PermissionError) as e:
|
|
69
|
-
if attempt < max_retries - 1:
|
|
70
|
-
time.sleep(0.5)
|
|
71
|
-
else:
|
|
72
|
-
raise
|
|
73
|
-
if found:
|
|
74
|
-
break
|
|
75
|
-
except Exception as e:
|
|
76
|
-
print(f"Warning: Failed to copy {lib}: {e}")
|
|
77
|
-
if found:
|
|
78
|
-
break
|
|
79
|
-
|
|
80
|
-
if not found:
|
|
81
|
-
print(f"ERROR: No compiled library found in build directory {build_temp}")
|
|
82
|
-
print(f" Searched for: hapc_core.pyd (Windows), hapc_core.so (Linux), hapc_core.dylib (macOS)")
|
|
83
|
-
raise RuntimeError("Failed to locate compiled hapc_core extension")
|
|
84
|
-
|
|
85
|
-
# Don't call parent run() to avoid setuptools trying to clean Windows locked files
|
|
86
|
-
# Just mark as complete
|
|
87
|
-
self.build_libs = []
|
|
88
|
-
|
|
89
|
-
# Try to read version, fallback to default
|
|
90
|
-
version = "0.1.0"
|
|
91
|
-
init_file = Path(__file__).parent / "python" / "hapc" / "__init__.py"
|
|
92
|
-
if init_file.exists():
|
|
93
|
-
with open(init_file, "r") as f:
|
|
94
|
-
for line in f:
|
|
95
|
-
if line.startswith("__version__"):
|
|
96
|
-
version = line.split("=")[1].strip().strip('"').strip("'")
|
|
97
|
-
break
|
|
98
|
-
|
|
99
|
-
# Try to read README
|
|
100
|
-
readme_content = ""
|
|
101
|
-
readme_file = Path(__file__).parent / "README.md"
|
|
102
|
-
if readme_file.exists():
|
|
103
|
-
with open(readme_file, "r") as f:
|
|
104
|
-
readme_content = f.read()
|
|
105
|
-
|
|
106
|
-
setup(
|
|
107
|
-
name="hapc",
|
|
108
|
-
version=version,
|
|
109
|
-
description="Highly Adaptive Principal Components",
|
|
110
|
-
long_description=readme_content,
|
|
111
|
-
long_description_content_type="text/markdown",
|
|
112
|
-
author="Carlos García Meixide",
|
|
113
|
-
author_email="cgmeixide@gmail.com",
|
|
114
|
-
url="https://github.com/meixide/hapc",
|
|
115
|
-
license="MIT",
|
|
116
|
-
packages=find_packages(where="python"),
|
|
117
|
-
package_dir={"": "python"},
|
|
118
|
-
# Correctly name the extension to be part of the 'hapc' package
|
|
119
|
-
ext_modules=[Extension("hapc.hapc_core", [])],
|
|
120
|
-
cmdclass={"build_ext": CMakeBuild},
|
|
121
|
-
python_requires=">=3.8",
|
|
122
|
-
include_package_data=True,
|
|
123
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|