hapc 0.1.3__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.
Files changed (44) hide show
  1. {hapc-0.1.3 → hapc-0.2.0}/CMakeLists.txt +13 -2
  2. {hapc-0.1.3/python/hapc.egg-info → hapc-0.2.0}/PKG-INFO +1 -1
  3. {hapc-0.1.3 → hapc-0.2.0}/pyproject.toml +1 -1
  4. {hapc-0.1.3 → hapc-0.2.0}/python/hapc/__init__.py +1 -1
  5. {hapc-0.1.3 → hapc-0.2.0}/python/hapc/core.py +1 -37
  6. {hapc-0.1.3 → hapc-0.2.0/python/hapc.egg-info}/PKG-INFO +1 -1
  7. {hapc-0.1.3 → hapc-0.2.0}/python/hapc.egg-info/SOURCES.txt +1 -0
  8. hapc-0.2.0/python/hapc.egg-info/not-zip-safe +1 -0
  9. hapc-0.2.0/python/hapc.egg-info/top_level.txt +2 -0
  10. hapc-0.2.0/setup.py +89 -0
  11. hapc-0.1.3/python/hapc.egg-info/top_level.txt +0 -1
  12. hapc-0.1.3/setup.py +0 -122
  13. {hapc-0.1.3 → hapc-0.2.0}/LICENSE +0 -0
  14. {hapc-0.1.3 → hapc-0.2.0}/MANIFEST.in +0 -0
  15. {hapc-0.1.3 → hapc-0.2.0}/README.md +0 -0
  16. {hapc-0.1.3 → hapc-0.2.0}/python/demo_single.py +0 -0
  17. {hapc-0.1.3 → hapc-0.2.0}/python/hapc/cv.py +0 -0
  18. {hapc-0.1.3 → hapc-0.2.0}/python/hapc/single.py +0 -0
  19. {hapc-0.1.3 → hapc-0.2.0}/python/hapc.egg-info/dependency_links.txt +0 -0
  20. {hapc-0.1.3 → hapc-0.2.0}/python/hapc.egg-info/requires.txt +0 -0
  21. {hapc-0.1.3 → hapc-0.2.0}/python/test_install.py +0 -0
  22. {hapc-0.1.3 → hapc-0.2.0}/setup.cfg +0 -0
  23. {hapc-0.1.3 → hapc-0.2.0}/src/bindings.cpp +0 -0
  24. {hapc-0.1.3 → hapc-0.2.0}/src/cross_kernel.cpp +0 -0
  25. {hapc-0.1.3 → hapc-0.2.0}/src/cv_classi.cpp +0 -0
  26. {hapc-0.1.3 → hapc-0.2.0}/src/cv_fast_pchal.cpp +0 -0
  27. {hapc-0.1.3 → hapc-0.2.0}/src/cv_fast_pchal_python.cpp +0 -0
  28. {hapc-0.1.3 → hapc-0.2.0}/src/fast_pchal.cpp +0 -0
  29. {hapc-0.1.3 → hapc-0.2.0}/src/hapc_core.hpp +0 -0
  30. {hapc-0.1.3 → hapc-0.2.0}/src/logistic_call.cpp +0 -0
  31. {hapc-0.1.3 → hapc-0.2.0}/src/mkernel.cpp +0 -0
  32. {hapc-0.1.3 → hapc-0.2.0}/src/pcghal_call.cpp +0 -0
  33. {hapc-0.1.3 → hapc-0.2.0}/src/pcghal_classi_call.cpp +0 -0
  34. {hapc-0.1.3 → hapc-0.2.0}/src/pcghal_cv.cpp +0 -0
  35. {hapc-0.1.3 → hapc-0.2.0}/src/pcghal_cv_cpp.cpp +0 -0
  36. {hapc-0.1.3 → hapc-0.2.0}/src/pchal_design.cpp +0 -0
  37. {hapc-0.1.3 → hapc-0.2.0}/src/r_bindings.cpp +0 -0
  38. {hapc-0.1.3 → hapc-0.2.0}/src/ridge_wrappers.cpp +0 -0
  39. {hapc-0.1.3 → hapc-0.2.0}/src/single_pcghal.cpp +0 -0
  40. {hapc-0.1.3 → hapc-0.2.0}/src/single_pcghal_cpp.cpp +0 -0
  41. {hapc-0.1.3 → hapc-0.2.0}/src/single_pchar.cpp +0 -0
  42. {hapc-0.1.3 → hapc-0.2.0}/tests/test_api.py +0 -0
  43. {hapc-0.1.3 → hapc-0.2.0}/tests/test_core.py +0 -0
  44. {hapc-0.1.3 → 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 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
+ )
26
+ FetchContent_MakeAvailable(Eigen3)
27
+ endif()
17
28
 
18
29
  # Find pybind11 via Python
19
30
  execute_process(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hapc
3
- Version: 0.1.3
3
+ Version: 0.2.0
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.3"
7
+ version = "0.2.0"
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.2"
3
+ __version__ = "0.2.0"
4
4
 
5
5
  from .core import (
6
6
  pchal_design,
@@ -5,43 +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
- hapc_core = None
10
-
11
- # Try direct import
12
- try:
13
- import hapc_core
14
- except ImportError:
15
- pass
16
-
17
- # Try relative import
18
- if hapc_core is None:
19
- try:
20
- from .. import hapc_core
21
- except ImportError:
22
- pass
23
-
24
- # Try to find it in known locations
25
- if hapc_core is None:
26
- search_paths = [
27
- Path(__file__).parent, # Same directory as this file
28
- Path(__file__).parent.parent.parent / "build", # Build directory
29
- ]
30
-
31
- for path in search_paths:
32
- if path.exists():
33
- sys.path.insert(0, str(path))
34
- try:
35
- import hapc_core
36
- break
37
- except ImportError:
38
- continue
39
-
40
- if hapc_core is None:
41
- raise ImportError(
42
- "hapc_core module not found. The C++ extension may not be built.\n"
43
- "Try: pip install -e . --force-reinstall --no-cache-dir"
44
- )
8
+ from . import hapc_core
45
9
 
46
10
  class DesignOutput(NamedTuple):
47
11
  """Output from pchal_design."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hapc
3
- Version: 0.1.3
3
+ Version: 0.2.0
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.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.3/setup.py DELETED
@@ -1,122 +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
- ext_modules=[Extension("hapc._core", [])],
119
- cmdclass={"build_ext": CMakeBuild},
120
- python_requires=">=3.8",
121
- include_package_data=True,
122
- )
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