Skip to content

Commit

Permalink
Merge pull request #15 from esa/revert-to-thrust-1_16
Browse files Browse the repository at this point in the history
Fix conda-forge v2.0 release
  • Loading branch information
schuhmaj authored Aug 1, 2023
2 parents 922d9b5 + f5d9a28 commit fa6c36b
Show file tree
Hide file tree
Showing 14 changed files with 694 additions and 621 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ option(BUILD_POLYHEDRAL_GRAVITY_TESTS "Set to on if the tests should be built (D
message(STATUS "BUILD_POLYHEDRAL_GRAVITY_TESTS = ${BUILD_POLYHEDRAL_GRAVITY_TESTS}")


IF(_LIBCPP_DISABLE_AVAILABILITY)
message(STATUS "Disabling availability macros for libc++")
add_definitions(-D_LIBCPP_DISABLE_AVAILABILITY)
endif ()

#######################################################
# Including dependencies needed across multiple targets
#######################################################
Expand Down
42 changes: 33 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

![Build and Test](https://github.com/schuhmaj/polyhedral-gravity-model-cpp/actions/workflows/ctest.yml/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/polyhedral-gravity-model-cpp/badge/?version=latest)](https://polyhedral-gravity-model-cpp.readthedocs.io/en/latest/?badge=latest)
![GitHub](https://img.shields.io/github/license/esa/polyhedral-gravity-model)

![PyPI](https://img.shields.io/pypi/v/polyhedral-gravity)
![Static Badge](https://img.shields.io/badge/platform-linux--64_%7C_windows--64_%7C_osx--64_%7C_linux--arm64_%7C_osx--arm64-lightgrey)
![PyPI - Downloads](https://img.shields.io/pypi/dm/polyhedral-gravity)

![Conda](https://img.shields.io/conda/v/conda-forge/polyhedral-gravity-model)
![Conda](https://img.shields.io/conda/pn/conda-forge/polyhedral-gravity-model)
![Conda](https://img.shields.io/conda/dn/conda-forge/polyhedral-gravity-model)


This code is a validated implementation in C++17 of the Polyhedral Gravity Model
by Tsoulis et al.. It was created in a collaborative project between
Expand Down Expand Up @@ -55,21 +65,35 @@ The python interface can be easily installed with

conda install -c conda-forge polyhedral-gravity-model

This is currently only supported for `x86-64` systems since
one of the dependencies is not available on conda for `aarch64`.
However, building from source with `pip` can also be done
on `aarch64` as shown below.

### pip

Use pip to install the python interface in your local python runtime.
The module will be build using CMake and the using the above
requirements. Just execute in repository root:
As a second option, you can also install the python interface with pip.

pip install polyhedral-gravity

Binaries for the most common platforms are available on PyPI including
Windows, Linux and macOS. For macOS and Linux, binaries for
`x86_64` and `aarch64` are provided.
In case `pip` uses the source distribution, please make sure that
you have a C++17 capable compiler, CMake and ninja-build installed.

### From source

The module will be build using a C++17 capable compiler,
CMake and ninja-build. Just execute the following command in
the repository root folder:

pip install .

To modify the build options (like parallelization) have a look
at the `setupy.py` and the [next paragraph](#build-c).
at the `setupy.py` and the [next paragraph](#build-c). The options
are modified by setting the environment variables before executing
the `pip install .` command, e.g.:

export POLYHEDRAL_GRAVITY_PARALLELIZATION="TBB"
pip install .


(Optional: For a faster build you can install all dependencies available
for your system in your local python environment. That way, they
won't be fetched from GitHub.)
Expand Down
6 changes: 3 additions & 3 deletions cmake/thrust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ set(THRUST_ENABLE_EXAMPLES "OFF")
# Set standard CPP Dialect to 17 (default of thrust would be 14)
set(THRUST_CPP_DIALECT 17)

find_package(Thrust 2.1.0 QUIET)
find_package(Thrust 1.16.0 QUIET)

if (${Thrust_FOUND})

message(STATUS "Using existing thrust installation")

else()
message(STATUS "Using thrust from git repository")
# Fetches the version 2.1.0 of the official NVIDIA Thrust repository
# Fetches the version 1.16.0 of the official NVIDIA Thrust repository
FetchContent_Declare(thrust
GIT_REPOSITORY https://github.com/NVIDIA/thrust.git
GIT_TAG 2.1.0
GIT_TAG 1.16.0
)
FetchContent_MakeAvailable(thrust)
endif()
2 changes: 1 addition & 1 deletion cmake/xsimd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(FetchContent)
message(STATUS "Setting up xsimd via CMake")


find_package(xsimd 11.1.0 QUIET)
find_package(xsimd 11.1 QUIET)

if (${xsimd_FOUND})

Expand Down
43 changes: 31 additions & 12 deletions docs/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The requirements (see below) are set-up automatically during
the build process. Use the instructions below to build the project, from the
repository's root directory:

.. code-block::
.. code-block:: bash
mkdir build
cd build
Expand All @@ -43,8 +43,34 @@ BUILD_POLYHEDRAL_GRAVITY_TESTS (:code:`ON`) Build the Tests
BUILD_POLYHEDRAL_PYTHON_INTERFACE (:code:`ON`) Build the Python interface
================================================ ===================================================================================================================================

Build & Installation with pip
-----------------------------
Installation with conda
-----------------------

The python interface can be easily installed with `conda <https://anaconda.org/conda-forge/polyhedral-gravity-model>`__:

.. code-block:: bash
conda install -c conda-forge polyhedral-gravity-model
Installation with pip
---------------------

As a second option, you can also install the python interface with pip from
`PyPi <https://pypi.org/project/polyhedral-gravity/>`__:

.. code-block:: bash
pip install polyhedral-gravity
Binaries for the most common platforms are available on PyPI including
Windows, Linux and macOS. For macOS and Linux, binaries for
:code:`x86_64` and :code:`aarch64` are provided.
In case :code:`pip` uses the source distribution, please make sure that
you have a C++17 capable compiler, CMake and ninja-build installed.


Build & Installation from source
--------------------------------

Use pip to install the python interface in your local python runtime.
The module will be build using CMake. Just execute in repository root:
Expand All @@ -54,19 +80,12 @@ The module will be build using CMake. Just execute in repository root:
pip install .
To modify the build options (like parallelization) have a look
at the :code:`setupy.py`. As simple example, to modify the parallelization,
just set the environment variable like below:
at the :code:`setupy.py`. The options are modified by setting the
environment variables before executing the :code:`pip install .` command, e.g.:

.. code-block::
export POLYHEDRAL_GRAVITY_PARALLELIZATION="TBB"
Installation with conda
-----------------------
The python interface can be easily installed with `conda <https://anaconda.org/conda-forge/polyhedral-gravity-model>`__:

.. code-block::
conda install -c conda-forge polyhedral-gravity-model
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def build_extension(self, ext):
f"-D{option_name}={final_value}"
]

# Disable availability of standard libc++ on macOS if requested
if os.environ.get("_LIBCPP_DISABLE_AVAILABILITY"):
cmake_args += [
"-D_LIBCPP_DISABLE_AVAILABILITY=ON"
]

# Sets the CMake Generator if specified (this is separate from the other variables since it is given to
# CMake vie the -G prefix
final_generator = os.environ.get("CMAKE_GENERATOR", CMAKE_GENERATOR)
Expand Down Expand Up @@ -152,6 +158,7 @@ def build_extension(self, ext):
""",
ext_modules=[CMakeExtension("polyhedral_gravity")],
cmdclass={"build_ext": CMakeBuild},
license="GPLv3",
license_file="LICENSE",
zip_safe=False,
python_requires=">=3.6",
Expand Down
4 changes: 2 additions & 2 deletions src/polyhedralGravity/calculation/GravityEvaluable.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include <sstream>

#include "thrust/transform.h"
#include "polyhedralGravity/calculation/GravityModel.h"
#include "thrust/execution_policy.h"

#include "polyhedralGravity/calculation/GravityModelDetail.h"
#include "polyhedralGravity/input/TetgenAdapter.h"
#include "polyhedralGravity/model/GravityModelData.h"
#include "polyhedralGravity/model/Polyhedron.h"
#include "thrust/execution_policy.h"


namespace polyhedralGravity {
Expand Down
Loading

0 comments on commit fa6c36b

Please sign in to comment.