-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from esa/fix-python-option
Small Fixes and Tidy Up
- Loading branch information
Showing
17 changed files
with
254 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ cmake-build-* | |
build | ||
polyhedral_gravity.egg-info | ||
dist | ||
docs/Doxyfile | ||
docs/Doxyfile | ||
src/polyhedralGravity/Info.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
find_package(Git QUIET REQUIRED) | ||
|
||
function(get_git_commit_hash OUTPUT_VAR) | ||
# Run a Git command to get the first 8 characters of the current commit hash | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE GIT_COMMIT_HASH | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_VARIABLE GIT_ERROR | ||
ERROR_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# Check if the Git command was successful | ||
if (NOT GIT_COMMIT_HASH OR GIT_ERROR) | ||
message(WARNING "Failed to retrieve Git commit hash: ${GIT_ERROR}") | ||
set(${OUTPUT_VAR} "UNKNOWN" PARENT_SCOPE) | ||
else() | ||
# Pass the short hash back to the calling scope | ||
set(${OUTPUT_VAR} "${GIT_COMMIT_HASH}" PARENT_SCOPE) | ||
endif() | ||
endfunction() | ||
|
||
function(is_git_working_tree_clean OUTPUT_VAR) | ||
# Run a Git command to check if the working tree is clean | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD -- | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
RESULT_VARIABLE GIT_STATUS_RESULT | ||
ERROR_VARIABLE GIT_ERROR | ||
ERROR_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# Check the result of the Git command | ||
if (NOT GIT_ERROR AND GIT_STATUS_RESULT EQUAL 0) | ||
# Working tree is clean | ||
set(${OUTPUT_VAR} TRUE PARENT_SCOPE) | ||
else() | ||
# Working tree has uncommitted changes or an error occurred | ||
set(${OUTPUT_VAR} FALSE PARENT_SCOPE) | ||
|
||
if (GIT_ERROR) | ||
message(WARNING "Error while checking Git working tree: ${GIT_ERROR}") | ||
endif() | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ set(SPDLOG_VERSION 1.14.1) | |
# If you install [email protected] via homebrew on ARM macOS, CMake will find spdlog | ||
# However, there is a version mismatch between the `fmt` library installed as dependency, and the one actually | ||
# being required leading to a linking error (i.e. missing symbols) while compiling! | ||
# Update 29.11.2024: We fixed this by using spdlog has header library (--> top-level CMake file) | ||
find_package(spdlog ${SPDLOG_VERSION} QUIET) | ||
|
||
if(${spdlog_FOUND}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
# Modify to change the parallelization (Default value: TBB) | ||
"POLYHEDRAL_GRAVITY_PARALLELIZATION": "TBB", | ||
# Default value (INFO=2) | ||
"LOGGING_LEVEL": "INFO", | ||
"POLYHEDRAL_GRAVITY_LOGGING_LEVEL": "INFO", | ||
# Not required for the python interface (--> OFF) | ||
"BUILD_POLYHEDRAL_GRAVITY_DOCS": "OFF", | ||
# Not required for the python interface (--> OFF) | ||
|
@@ -53,6 +53,27 @@ def get_cmake_generator(): | |
else: | ||
return None | ||
|
||
def get_version(): | ||
"""Returns the version of the polyhedral gravity package by reading the CMake file.""" | ||
# Path to the CMake file | ||
cmake_file = os.path.join(os.path.dirname(__file__), "version.cmake" ) | ||
|
||
# Check if the CMake file exists | ||
if not os.path.exists(cmake_file): | ||
raise FileNotFoundError(f"CMake file not found: {cmake_file}") | ||
|
||
# Open and read the file | ||
with open(cmake_file, "r") as file: | ||
content = file.read() | ||
|
||
# Use regex to extract the PROJECT_VERSION | ||
version_match = re.search(r'set\(PROJECT_VERSION\s+([^\s)]+)\)', content) | ||
if version_match: | ||
return version_match.group(1) | ||
else: | ||
raise ValueError("Version string not found in CMakeLists.txt") | ||
|
||
|
||
# ----------------------------------------------------------------------------------------- | ||
# The following is adapted from https://github.com/pybind/cmake_example/blob/master/setup.py | ||
# ----------------------------------------------------------------------------------------- | ||
|
@@ -173,7 +194,7 @@ def build_extension(self, ext): | |
# -------------------------------------------------------------------------------- | ||
setup( | ||
name="polyhedral_gravity", | ||
version="3.2.1", | ||
version=get_version(), | ||
author="Jonas Schuhmacher", | ||
author_email="[email protected]", | ||
description="Package to compute full gravity tensor of a given constant density polyhedron for arbitrary points " | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.