hapc 0.1.5__tar.gz → 0.2.1__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.
Files changed (44) hide show
  1. {hapc-0.1.5 → hapc-0.2.1}/CMakeLists.txt +17 -2
  2. {hapc-0.1.5/python/hapc.egg-info → hapc-0.2.1}/PKG-INFO +1 -1
  3. {hapc-0.1.5 → hapc-0.2.1}/pyproject.toml +1 -1
  4. {hapc-0.1.5 → hapc-0.2.1}/python/hapc/__init__.py +1 -1
  5. {hapc-0.1.5 → hapc-0.2.1}/python/hapc/core.py +1 -13
  6. {hapc-0.1.5 → hapc-0.2.1/python/hapc.egg-info}/PKG-INFO +1 -1
  7. {hapc-0.1.5 → hapc-0.2.1}/python/hapc.egg-info/SOURCES.txt +1 -0
  8. hapc-0.2.1/python/hapc.egg-info/not-zip-safe +1 -0
  9. hapc-0.2.1/python/hapc.egg-info/top_level.txt +2 -0
  10. hapc-0.2.1/setup.py +93 -0
  11. hapc-0.1.5/python/hapc.egg-info/top_level.txt +0 -1
  12. hapc-0.1.5/setup.py +0 -123
  13. {hapc-0.1.5 → hapc-0.2.1}/LICENSE +0 -0
  14. {hapc-0.1.5 → hapc-0.2.1}/MANIFEST.in +0 -0
  15. {hapc-0.1.5 → hapc-0.2.1}/README.md +0 -0
  16. {hapc-0.1.5 → hapc-0.2.1}/python/demo_single.py +0 -0
  17. {hapc-0.1.5 → hapc-0.2.1}/python/hapc/cv.py +0 -0
  18. {hapc-0.1.5 → hapc-0.2.1}/python/hapc/single.py +0 -0
  19. {hapc-0.1.5 → hapc-0.2.1}/python/hapc.egg-info/dependency_links.txt +0 -0
  20. {hapc-0.1.5 → hapc-0.2.1}/python/hapc.egg-info/requires.txt +0 -0
  21. {hapc-0.1.5 → hapc-0.2.1}/python/test_install.py +0 -0
  22. {hapc-0.1.5 → hapc-0.2.1}/setup.cfg +0 -0
  23. {hapc-0.1.5 → hapc-0.2.1}/src/bindings.cpp +0 -0
  24. {hapc-0.1.5 → hapc-0.2.1}/src/cross_kernel.cpp +0 -0
  25. {hapc-0.1.5 → hapc-0.2.1}/src/cv_classi.cpp +0 -0
  26. {hapc-0.1.5 → hapc-0.2.1}/src/cv_fast_pchal.cpp +0 -0
  27. {hapc-0.1.5 → hapc-0.2.1}/src/cv_fast_pchal_python.cpp +0 -0
  28. {hapc-0.1.5 → hapc-0.2.1}/src/fast_pchal.cpp +0 -0
  29. {hapc-0.1.5 → hapc-0.2.1}/src/hapc_core.hpp +0 -0
  30. {hapc-0.1.5 → hapc-0.2.1}/src/logistic_call.cpp +0 -0
  31. {hapc-0.1.5 → hapc-0.2.1}/src/mkernel.cpp +0 -0
  32. {hapc-0.1.5 → hapc-0.2.1}/src/pcghal_call.cpp +0 -0
  33. {hapc-0.1.5 → hapc-0.2.1}/src/pcghal_classi_call.cpp +0 -0
  34. {hapc-0.1.5 → hapc-0.2.1}/src/pcghal_cv.cpp +0 -0
  35. {hapc-0.1.5 → hapc-0.2.1}/src/pcghal_cv_cpp.cpp +0 -0
  36. {hapc-0.1.5 → hapc-0.2.1}/src/pchal_design.cpp +0 -0
  37. {hapc-0.1.5 → hapc-0.2.1}/src/r_bindings.cpp +0 -0
  38. {hapc-0.1.5 → hapc-0.2.1}/src/ridge_wrappers.cpp +0 -0
  39. {hapc-0.1.5 → hapc-0.2.1}/src/single_pcghal.cpp +0 -0
  40. {hapc-0.1.5 → hapc-0.2.1}/src/single_pcghal_cpp.cpp +0 -0
  41. {hapc-0.1.5 → hapc-0.2.1}/src/single_pchar.cpp +0 -0
  42. {hapc-0.1.5 → hapc-0.2.1}/tests/test_api.py +0 -0
  43. {hapc-0.1.5 → hapc-0.2.1}/tests/test_core.py +0 -0
  44. {hapc-0.1.5 → hapc-0.2.1}/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,21 @@ endif()
12
14
  # Find Python
13
15
  find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
14
16
 
15
- # Find Eigen3
16
- find_package(Eigen3 REQUIRED NO_MODULE)
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
+ DOWNLOAD_EXTRACT_TIMESTAMP TRUE
26
+ )
27
+ # Disable Eigen tests and demos to speed up configuration
28
+ set(EIGEN_BUILD_TESTING OFF CACHE BOOL "" FORCE)
29
+ set(EIGEN_BUILD_DOC OFF CACHE BOOL "" FORCE)
30
+ FetchContent_MakeAvailable(Eigen3)
31
+ endif()
17
32
 
18
33
  # Find pybind11 via Python
19
34
  execute_process(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hapc
3
- Version: 0.1.5
3
+ Version: 0.2.1
4
4
  Summary: Highly Adaptive Principal Components
5
5
  Home-page: https://github.com/meixide/hapc
6
6
  Author: Carlos García Meixide
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hapc"
7
- version = "0.1.5"
7
+ version = "0.2.1"
8
8
  description = "Highly Adaptive Principal Components"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,6 +1,6 @@
1
1
  """HAPC: Highly Adaptive Principal Components."""
2
2
 
3
- __version__ = "0.1.5"
3
+ __version__ = "0.2.1"
4
4
 
5
5
  from .core import (
6
6
  pchal_design,
@@ -5,19 +5,7 @@ from typing import NamedTuple, Optional
5
5
  import sys
6
6
  from pathlib import Path
7
7
 
8
- # Try to import hapc_core module
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."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hapc
3
- Version: 0.1.5
3
+ Version: 0.2.1
4
4
  Summary: Highly Adaptive Principal Components
5
5
  Home-page: https://github.com/meixide/hapc
6
6
  Author: Carlos García Meixide
@@ -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,2 @@
1
+ hapc
2
+ hapc/hapc_core
hapc-0.2.1/setup.py ADDED
@@ -0,0 +1,93 @@
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
+ import time
9
+ from pathlib import Path
10
+
11
+ class CMakeExtension(Extension):
12
+ def __init__(self, name, sourcedir=''):
13
+ Extension.__init__(self, name, sources=[])
14
+ self.sourcedir = os.path.abspath(sourcedir)
15
+
16
+ class CMakeBuild(build_ext):
17
+ def run(self):
18
+ try:
19
+ out = subprocess.check_output(['cmake', '--version'])
20
+ except OSError:
21
+ raise RuntimeError("CMake must be installed to build the following extensions: " +
22
+ ", ".join(e.name for e in self.extensions))
23
+
24
+ for ext in self.extensions:
25
+ self.build_extension(ext)
26
+
27
+ def build_extension(self, ext):
28
+ extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
29
+ # required for auto-detection of auxiliary "native" libs
30
+ if not extdir.endswith(os.path.sep):
31
+ extdir += os.path.sep
32
+
33
+ cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
34
+ '-DPYTHON_EXECUTABLE=' + sys.executable]
35
+
36
+ cfg = 'Debug' if self.debug else 'Release'
37
+ build_args = ['--config', cfg]
38
+
39
+ cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
40
+ # Add parallel build flag only on non-Windows platforms
41
+ # On Windows, MSBuild doesn't support -j flag and handles parallelization automatically
42
+ if sys.platform != 'win32':
43
+ build_args += ['--', '-j2']
44
+
45
+
46
+ env = os.environ.copy()
47
+ env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''),
48
+ self.distribution.get_version())
49
+ if not os.path.exists(self.build_temp):
50
+ os.makedirs(self.build_temp)
51
+ subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
52
+ subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
53
+
54
+ # Try to read version, fallback to default
55
+ version = "0.1.0"
56
+ init_file = Path(__file__).parent / "python" / "hapc" / "__init__.py"
57
+ if init_file.exists():
58
+ with open(init_file, "r") as f:
59
+ for line in f:
60
+ if line.startswith("__version__"):
61
+ version = line.split("=")[1].strip().strip('"').strip("'")
62
+ break
63
+
64
+ # Try to read README
65
+ readme_content = ""
66
+ readme_file = Path(__file__).parent / "README.md"
67
+ if readme_file.exists():
68
+ with open(readme_file, "r") as f:
69
+ readme_content = f.read()
70
+
71
+ setup(
72
+ name="hapc",
73
+ version=version,
74
+ description="Highly Adaptive Principal Components",
75
+ long_description=readme_content,
76
+ long_description_content_type="text/markdown",
77
+ author="Carlos García Meixide",
78
+ author_email="cgmeixide@gmail.com",
79
+ url="https://github.com/meixide/hapc",
80
+ license="MIT",
81
+ packages=find_packages(where="python"),
82
+ package_dir={"": "python"},
83
+ ext_modules=[CMakeExtension('hapc/hapc_core', sourcedir=os.path.dirname(os.path.abspath(__file__)))],
84
+ cmdclass=dict(build_ext=CMakeBuild),
85
+ python_requires=">=3.8",
86
+ install_requires=[
87
+ "numpy>=1.24,<2.3",
88
+ "scipy>=1.7",
89
+ "scikit-learn>=0.24",
90
+ ],
91
+ include_package_data=True,
92
+ zip_safe=False,
93
+ )
@@ -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