cea-external-tools 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,123 @@
1
+ cmake_minimum_required(VERSION 3.15)
2
+ project(cea_external_tools)
3
+
4
+ # Suppress common warnings for cleaner build output
5
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
6
+ add_compile_options(
7
+ -Wno-unused-variable
8
+ -Wno-unused-parameter
9
+ -Wno-sign-compare
10
+ -Wno-deprecated-declarations
11
+ )
12
+ endif()
13
+
14
+ # Force single architecture builds on macOS (no universal binaries)
15
+ if(APPLE)
16
+ # Auto-detect current architecture if not specified
17
+ if(NOT CMAKE_OSX_ARCHITECTURES)
18
+ execute_process(
19
+ COMMAND uname -m
20
+ OUTPUT_VARIABLE NATIVE_ARCH
21
+ OUTPUT_STRIP_TRAILING_WHITESPACE
22
+ )
23
+ set(CMAKE_OSX_ARCHITECTURES "${NATIVE_ARCH}" CACHE STRING "Target architecture" FORCE)
24
+ message(STATUS "Setting macOS architecture to: ${CMAKE_OSX_ARCHITECTURES}")
25
+ endif()
26
+ endif()
27
+
28
+ # Build options
29
+ option(BUILD_DAYSIM "Build DAYSIM component" ON)
30
+ option(BUILD_CRAX "Build CRAX component" ON)
31
+
32
+ # Include the separate configuration modules (only when needed)
33
+ if(BUILD_DAYSIM)
34
+ include(${CMAKE_CURRENT_SOURCE_DIR}/DaysimConfig.cmake OPTIONAL RESULT_VARIABLE _daysim_cfg)
35
+ if(NOT _daysim_cfg)
36
+ message(FATAL_ERROR "DaysimConfig.cmake not found but BUILD_DAYSIM=ON")
37
+ endif()
38
+ endif()
39
+
40
+ if(BUILD_CRAX)
41
+ include(${CMAKE_CURRENT_SOURCE_DIR}/CraxConfig.cmake OPTIONAL RESULT_VARIABLE _crax_cfg)
42
+ if(NOT _crax_cfg)
43
+ message(FATAL_ERROR "CraxConfig.cmake not found but BUILD_CRAX=ON")
44
+ endif()
45
+ endif()
46
+ # Configure and build DAYSIM
47
+ if(BUILD_DAYSIM)
48
+ message(STATUS "")
49
+ configure_daysim()
50
+
51
+ message(STATUS "")
52
+ install_daysim()
53
+ endif()
54
+
55
+ # Configure and build CRAX
56
+ if(BUILD_CRAX)
57
+ message(STATUS "")
58
+ configure_crax()
59
+
60
+ message(STATUS "")
61
+ install_crax()
62
+ endif()
63
+
64
+ # ============================================================================
65
+ # Custom Build Targets for CEA
66
+ # ============================================================================
67
+
68
+ # Create custom target that builds all CEA-required components
69
+ add_custom_target(cea_all)
70
+
71
+ # A function to add dependencies after targets are defined
72
+ function(setup_custom_target_dependencies)
73
+ message(STATUS "=== CEA External Tools Target Summary ===")
74
+
75
+ # DAYSIM targets
76
+ if(BUILD_DAYSIM)
77
+ set(CEA_DAYSIM_TARGETS ds_illum epw2wea gen_dc oconv radfiles2daysim rtrace_dc)
78
+ foreach(target ${CEA_DAYSIM_TARGETS})
79
+ if(TARGET ${target})
80
+ add_dependencies(cea_all ${target})
81
+ message(STATUS " ✓ Added DAYSIM target ${target} to cea_all")
82
+ else()
83
+ message(STATUS " ⚠ DAYSIM target ${target} not found")
84
+ endif()
85
+ endforeach()
86
+ endif()
87
+
88
+ # CRAX targets
89
+ if(BUILD_CRAX)
90
+ set(CEA_CRAX_TARGETS radiation mesh-generation)
91
+ foreach(target ${CEA_CRAX_TARGETS})
92
+ if(TARGET ${target})
93
+ add_dependencies(cea_all ${target})
94
+ message(STATUS " ✓ Added CRAX target ${target} to cea_all")
95
+ else()
96
+ message(STATUS " ⚠ CRAX target ${target} not found")
97
+ endif()
98
+ endforeach()
99
+ endif()
100
+ endfunction()
101
+
102
+ # Call the function after all subdirectories have been processed
103
+ if(BUILD_DAYSIM OR BUILD_CRAX)
104
+ message(STATUS "")
105
+ setup_custom_target_dependencies()
106
+ endif()
107
+
108
+ # Print build information
109
+ message(STATUS "")
110
+ message(STATUS "=== CEA External Tools Configuration Summary ===")
111
+ message(STATUS " Platform: ${CEA_PLATFORM_DIR}")
112
+ message(STATUS " Build DAYSIM: ${BUILD_DAYSIM}")
113
+ message(STATUS " Build CRAX: ${BUILD_CRAX}")
114
+ if(BUILD_DAYSIM)
115
+ message(STATUS " DAYSIM source: ${DAYSIM_FINAL_SOURCE_DIR}")
116
+ endif()
117
+ if(BUILD_CRAX)
118
+ message(STATUS " CRAX source: ${CRAX_FINAL_SOURCE_DIR}")
119
+ endif()
120
+ message(STATUS " Install prefix: ${CMAKE_INSTALL_PREFIX}")
121
+ message(STATUS "")
122
+ message(STATUS "Usage: cmake --build build --target cea_all")
123
+ message(STATUS "===============================================")
@@ -0,0 +1,90 @@
1
+ # CRAX Configuration Module for CEA External Tools
2
+ # This module handles fetching, building, and installing CRAX
3
+
4
+ # CRAX configuration options for Python wheel builds
5
+ option(CRAX_USE_DYNAMIC_ARROW "Enable dynamic Arrow linking for CRAX (saves space in wheels)" ON)
6
+ option(CRAX_USE_AUTOMATED_DEPENDENCIES "Use automated dependency fetching for CRAX" ON)
7
+
8
+ # Configurable CRAX source directory and repository
9
+ set(CRAX_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/crax" CACHE PATH "Path to CRAX source directory")
10
+ set(CRAX_GIT_REPOSITORY "https://github.com/wanglittlerain/CityRadiation-Accelerator-CRAX-V1.0.git" CACHE STRING "CRAX Git repository URL")
11
+ set(CRAX_GIT_TAG "f54f126eefd1578308c2b73e7096dc9705252303" CACHE STRING "CRAX Git tag/branch to use")
12
+
13
+ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
14
+ # Disable warning C4127 that causes build to fail in Windows
15
+ add_compile_options(
16
+ /wd4127
17
+ )
18
+ endif()
19
+
20
+ function(configure_crax)
21
+ message(STATUS "=== Configuring CRAX ===")
22
+
23
+ # Configure CRAX build options before adding to build
24
+ message(STATUS "Configuring CRAX with CEA-specific options:")
25
+ message(STATUS " Dynamic Arrow: ${CRAX_USE_DYNAMIC_ARROW}")
26
+ message(STATUS " Automated Dependencies: ${CRAX_USE_AUTOMATED_DEPENDENCIES}")
27
+
28
+ # Set CRAX CMake variables to pass our configuration
29
+ set(USE_DYNAMIC_ARROW ${CRAX_USE_DYNAMIC_ARROW} CACHE BOOL "Use dynamic Arrow linking" FORCE)
30
+ set(USE_AUTOMATED_DEPENDENCIES ${CRAX_USE_AUTOMATED_DEPENDENCIES} CACHE BOOL "Use automated dependencies" FORCE)
31
+
32
+ # Check if CRAX source exists locally
33
+ if(EXISTS "${CRAX_SOURCE_DIR}/CMakeLists.txt")
34
+ message(STATUS "Found local CRAX source at: ${CRAX_SOURCE_DIR}")
35
+ add_subdirectory(${CRAX_SOURCE_DIR} crax_build)
36
+ set(CRAX_FINAL_SOURCE_DIR "${CRAX_SOURCE_DIR}" PARENT_SCOPE)
37
+ else()
38
+ # Fetch CRAX from GitHub using FetchContent
39
+ message(STATUS "Local CRAX source not found, fetching from GitHub...")
40
+ message(STATUS "Repository: ${CRAX_GIT_REPOSITORY}")
41
+ message(STATUS "Tag/Branch: ${CRAX_GIT_TAG}")
42
+
43
+ include(FetchContent)
44
+
45
+ FetchContent_Declare(
46
+ crax_external
47
+ GIT_REPOSITORY ${CRAX_GIT_REPOSITORY}
48
+ GIT_TAG ${CRAX_GIT_TAG}
49
+ GIT_SHALLOW TRUE
50
+ )
51
+
52
+ # Try to fetch and build CRAX
53
+ FetchContent_MakeAvailable(crax_external)
54
+ set(CRAX_FINAL_SOURCE_DIR "${crax_external_SOURCE_DIR}" PARENT_SCOPE)
55
+ message(STATUS "CRAX fetched to: ${crax_external_SOURCE_DIR}")
56
+ endif()
57
+
58
+ # For Python wheel builds, set the Python executable to match the build environment
59
+ # if(CRAX_USE_DYNAMIC_ARROW)
60
+ # # Try to find the current Python executable being used for the build
61
+ # find_package(Python3 COMPONENTS Interpreter QUIET)
62
+ # if(Python3_FOUND)
63
+ # set(PYARROW_PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE STRING "Python executable for pyarrow detection" FORCE)
64
+ # message(STATUS " Setting PYARROW_PYTHON_EXECUTABLE to: ${Python3_EXECUTABLE}")
65
+ # endif()
66
+ # endif()
67
+ endfunction()
68
+
69
+ function(install_crax)
70
+ message(STATUS "=== Setting CRAX targets ===")
71
+
72
+ # Install CRAX executables
73
+ if(TARGET radiation)
74
+ message(STATUS "✓ Found radiation target")
75
+ install(TARGETS radiation
76
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
77
+ COMPONENT crax_targets)
78
+ else()
79
+ message(FATAL_ERROR "radiation target not found")
80
+ endif()
81
+
82
+ if(TARGET mesh-generation)
83
+ message(STATUS "✓ Found mesh-generation target")
84
+ install(TARGETS mesh-generation
85
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
86
+ COMPONENT crax_targets)
87
+ else()
88
+ message(FATAL_ERROR "mesh-generation target not found")
89
+ endif()
90
+ endfunction()
@@ -0,0 +1,71 @@
1
+ # DAYSIM Configuration Module for CEA External Tools
2
+ # This module handles fetching, building, and installing DAYSIM
3
+
4
+ # Configurable DAYSIM source directory and repository
5
+ set(DAYSIM_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/daysim" CACHE PATH "Path to DAYSIM source directory")
6
+ set(DAYSIM_GIT_REPOSITORY "https://github.com/reyery/Daysim.git" CACHE STRING "DAYSIM Git repository URL")
7
+ set(DAYSIM_GIT_TAG "b4fc6ba3a41e32c8b0d6a41d413aa10f067b6709" CACHE STRING "DAYSIM Git tag/branch to use")
8
+
9
+ function(configure_daysim)
10
+ message(STATUS "=== Configuring DAYSIM ===")
11
+
12
+ # Check if DAYSIM source exists locally
13
+ if(EXISTS "${DAYSIM_SOURCE_DIR}/CMakeLists.txt")
14
+ message(STATUS "Found local DAYSIM source at: ${DAYSIM_SOURCE_DIR}")
15
+ add_subdirectory(${DAYSIM_SOURCE_DIR} daysim_build)
16
+ set(DAYSIM_FINAL_SOURCE_DIR "${DAYSIM_SOURCE_DIR}" PARENT_SCOPE)
17
+ else()
18
+ # Fetch DAYSIM from GitHub using FetchContent
19
+ message(STATUS "Local DAYSIM source not found, fetching from GitHub...")
20
+ message(STATUS "Repository: ${DAYSIM_GIT_REPOSITORY}")
21
+ message(STATUS "Tag/Branch: ${DAYSIM_GIT_TAG}")
22
+
23
+ include(FetchContent)
24
+
25
+ FetchContent_Declare(
26
+ daysim_external
27
+ GIT_REPOSITORY ${DAYSIM_GIT_REPOSITORY}
28
+ GIT_TAG ${DAYSIM_GIT_TAG}
29
+ GIT_SHALLOW TRUE
30
+ )
31
+
32
+ # Try to fetch and build DAYSIM
33
+ FetchContent_MakeAvailable(daysim_external)
34
+ set(DAYSIM_FINAL_SOURCE_DIR "${daysim_external_SOURCE_DIR}" PARENT_SCOPE)
35
+ message(STATUS "DAYSIM fetched to: ${daysim_external_SOURCE_DIR}")
36
+ endif()
37
+ endfunction()
38
+
39
+ function(install_daysim)
40
+ message(STATUS "=== Setting DAYSIM targets ===")
41
+
42
+ # Verify cea_targets target exists (this is what we want to build)
43
+ if(TARGET cea_targets)
44
+ message(STATUS "✓ Found cea_targets custom target")
45
+
46
+ # Get the dependencies of cea_targets to see what executables it builds
47
+ get_target_property(CEA_TARGET_DEPS cea_targets MANUALLY_ADDED_DEPENDENCIES)
48
+ if(CEA_TARGET_DEPS)
49
+ message(STATUS " - cea_targets depends on: ${CEA_TARGET_DEPS}")
50
+ endif()
51
+
52
+ # PROBLEM: DAYSIM doesn't use the cea_targets COMPONENT in its install() commands
53
+ # We need to install the CEA-specific targets manually
54
+ # FIXME: Update DAYSIM CMakeLists.txt to use COMPONENT for CEA targets
55
+
56
+ # Install the specific executables that cea_targets depends on
57
+ set(CEA_EXECUTABLES ds_illum epw2wea gen_dc oconv radfiles2daysim rtrace_dc)
58
+ foreach(target ${CEA_EXECUTABLES})
59
+ if(TARGET ${target})
60
+ message(STATUS " - Installing ${target}")
61
+ install(TARGETS ${target}
62
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
63
+ COMPONENT cea_targets)
64
+ else()
65
+ message(WARNING " - Target ${target} not found")
66
+ endif()
67
+ endforeach()
68
+ else()
69
+ message(FATAL_ERROR "cea_targets target not found in DAYSIM build! Cannot proceed.")
70
+ endif()
71
+ endfunction()
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.2
2
+ Name: cea-external-tools
3
+ Version: 0.1.0
4
+ Summary: External tools for City Energy Analyst, mainly containing C++ components e.g. DAYSIM and CRAX
5
+ Author-Email: Reynold Mok <reynold.mok@arch.ethz.ch>
6
+ Project-URL: Homepage, https://cityenergyanalyst.com
7
+ Project-URL: Bug Reports, https://github.com/architecture-building-systems/CityEnergyAnalyst/issues
8
+ Project-URL: Source, https://github.com/architecture-building-systems/CityEnergyAnalyst
9
+ Requires-Python: <3.13,>=3.8
10
+ Description-Content-Type: text/markdown
11
+
12
+ # CEA External Tools Build Configuration
13
+
14
+ This directory contains the CMake configuration for building external tools required by the City Energy Analyst (CEA).
15
+
16
+ ## Structure
17
+
18
+ The build system has been modularized into separate configuration files:
19
+
20
+ - **`CMakeLists.txt`** - Main build configuration file
21
+ - **`DaysimConfig.cmake`** - DAYSIM-specific configuration and build logic
22
+ - **`CraxConfig.cmake`** - CRAX-specific configuration and build logic
23
+
24
+ ## Components
25
+
26
+ ### DAYSIM
27
+ Daylighting simulation tool that provides various radiation calculation utilities.
28
+
29
+ **Executables built:**
30
+ - `ds_illum` - Illuminance calculation
31
+ - `epw2wea` - Weather file conversion
32
+ - `gen_dc` - Daylight coefficient generation
33
+ - `oconv` - Octree conversion
34
+ - `radfiles2daysim` - Radiance file conversion
35
+ - `rtrace_dc` - Ray tracing for daylight coefficients
36
+
37
+ ### CRAX
38
+ City Radiation Accelerator for fast urban radiation simulations.
39
+
40
+ **Executables built:**
41
+ - `radiation` - Main radiation calculation engine
42
+ - `mesh-generation` - 3D mesh generation utility
43
+
44
+ ## Build Options
45
+
46
+ You can control which components to build using CMake options:
47
+
48
+ ```bash
49
+ # Build both components (default)
50
+ cmake -DBUILD_DAYSIM=ON -DBUILD_CRAX=ON ..
51
+
52
+ # Build only DAYSIM
53
+ cmake -DBUILD_DAYSIM=ON -DBUILD_CRAX=OFF ..
54
+
55
+ # Build only CRAX
56
+ cmake -DBUILD_DAYSIM=OFF -DBUILD_CRAX=ON ..
57
+ ```
58
+
59
+ ## CRAX-specific Options
60
+
61
+ CRAX has additional configuration options for Python wheel builds:
62
+
63
+ - `CRAX_USE_DYNAMIC_ARROW` (default: ON) - Enable dynamic Arrow linking to save space in wheels
64
+ - `CRAX_USE_AUTOMATED_DEPENDENCIES` (default: ON) - Use automated dependency fetching
65
+
66
+ ## Source Configuration
67
+
68
+ Both tools support local source directories or automatic fetching from GitHub:
69
+
70
+ ### DAYSIM
71
+ - `DAYSIM_SOURCE_DIR` - Path to local DAYSIM source (default: `./daysim`)
72
+ - `DAYSIM_GIT_REPOSITORY` - Git repository URL (default: `https://github.com/reyery/Daysim.git`)
73
+ - `DAYSIM_GIT_TAG` - Git tag/branch to use
74
+
75
+ ### CRAX
76
+ - `CRAX_SOURCE_DIR` - Path to local CRAX source (default: `./crax`)
77
+ - `CRAX_GIT_REPOSITORY` - Git repository URL (default: `https://github.com/wanglittlerain/CityRadiation-Accelerator-CRAX-V1.0.git`)
78
+ - `CRAX_GIT_TAG` - Git tag/branch to use
79
+
80
+ ## Installation
81
+
82
+ The built executables are installed to the CEA resources directory:
83
+
84
+ - DAYSIM tools: `cea/resources/radiation/bin`
85
+ - CRAX tools: `cea/resources/radiation/bin`
86
+
87
+ ## Build Targets
88
+
89
+ The build system includes a custom target `cea_all` that builds all required CEA components:
90
+
91
+ ```bash
92
+ # Configure build
93
+ cmake -B build -S .
94
+
95
+ # Build all CEA targets (recommended)
96
+ cmake --build build --target cea_all
97
+
98
+ # Or build all targets
99
+ cmake --build build
100
+
101
+ # Install to CEA resources
102
+ cmake --install build
103
+ ```
104
+
105
+ ## Compiler Warnings
106
+
107
+ The build system automatically suppresses common warnings for cleaner output:
108
+ - GNU/Clang: Suppresses missing prototypes, unused variables, sign comparison, and deprecated declarations
109
+ - MSVC: Suppresses warning C4127 to prevent build failures on Windows
@@ -0,0 +1,98 @@
1
+ # CEA External Tools Build Configuration
2
+
3
+ This directory contains the CMake configuration for building external tools required by the City Energy Analyst (CEA).
4
+
5
+ ## Structure
6
+
7
+ The build system has been modularized into separate configuration files:
8
+
9
+ - **`CMakeLists.txt`** - Main build configuration file
10
+ - **`DaysimConfig.cmake`** - DAYSIM-specific configuration and build logic
11
+ - **`CraxConfig.cmake`** - CRAX-specific configuration and build logic
12
+
13
+ ## Components
14
+
15
+ ### DAYSIM
16
+ Daylighting simulation tool that provides various radiation calculation utilities.
17
+
18
+ **Executables built:**
19
+ - `ds_illum` - Illuminance calculation
20
+ - `epw2wea` - Weather file conversion
21
+ - `gen_dc` - Daylight coefficient generation
22
+ - `oconv` - Octree conversion
23
+ - `radfiles2daysim` - Radiance file conversion
24
+ - `rtrace_dc` - Ray tracing for daylight coefficients
25
+
26
+ ### CRAX
27
+ City Radiation Accelerator for fast urban radiation simulations.
28
+
29
+ **Executables built:**
30
+ - `radiation` - Main radiation calculation engine
31
+ - `mesh-generation` - 3D mesh generation utility
32
+
33
+ ## Build Options
34
+
35
+ You can control which components to build using CMake options:
36
+
37
+ ```bash
38
+ # Build both components (default)
39
+ cmake -DBUILD_DAYSIM=ON -DBUILD_CRAX=ON ..
40
+
41
+ # Build only DAYSIM
42
+ cmake -DBUILD_DAYSIM=ON -DBUILD_CRAX=OFF ..
43
+
44
+ # Build only CRAX
45
+ cmake -DBUILD_DAYSIM=OFF -DBUILD_CRAX=ON ..
46
+ ```
47
+
48
+ ## CRAX-specific Options
49
+
50
+ CRAX has additional configuration options for Python wheel builds:
51
+
52
+ - `CRAX_USE_DYNAMIC_ARROW` (default: ON) - Enable dynamic Arrow linking to save space in wheels
53
+ - `CRAX_USE_AUTOMATED_DEPENDENCIES` (default: ON) - Use automated dependency fetching
54
+
55
+ ## Source Configuration
56
+
57
+ Both tools support local source directories or automatic fetching from GitHub:
58
+
59
+ ### DAYSIM
60
+ - `DAYSIM_SOURCE_DIR` - Path to local DAYSIM source (default: `./daysim`)
61
+ - `DAYSIM_GIT_REPOSITORY` - Git repository URL (default: `https://github.com/reyery/Daysim.git`)
62
+ - `DAYSIM_GIT_TAG` - Git tag/branch to use
63
+
64
+ ### CRAX
65
+ - `CRAX_SOURCE_DIR` - Path to local CRAX source (default: `./crax`)
66
+ - `CRAX_GIT_REPOSITORY` - Git repository URL (default: `https://github.com/wanglittlerain/CityRadiation-Accelerator-CRAX-V1.0.git`)
67
+ - `CRAX_GIT_TAG` - Git tag/branch to use
68
+
69
+ ## Installation
70
+
71
+ The built executables are installed to the CEA resources directory:
72
+
73
+ - DAYSIM tools: `cea/resources/radiation/bin`
74
+ - CRAX tools: `cea/resources/radiation/bin`
75
+
76
+ ## Build Targets
77
+
78
+ The build system includes a custom target `cea_all` that builds all required CEA components:
79
+
80
+ ```bash
81
+ # Configure build
82
+ cmake -B build -S .
83
+
84
+ # Build all CEA targets (recommended)
85
+ cmake --build build --target cea_all
86
+
87
+ # Or build all targets
88
+ cmake --build build
89
+
90
+ # Install to CEA resources
91
+ cmake --install build
92
+ ```
93
+
94
+ ## Compiler Warnings
95
+
96
+ The build system automatically suppresses common warnings for cleaner output:
97
+ - GNU/Clang: Suppresses missing prototypes, unused variables, sign comparison, and deprecated declarations
98
+ - MSVC: Suppresses warning C4127 to prevent build failures on Windows
@@ -0,0 +1,3 @@
1
+ # TODO: Add functions to help fetch external tools
2
+
3
+ __version__ = "0.1.0"