Skip to content

Commit

Permalink
CMake: Fix List of Pip Options
Browse files Browse the repository at this point in the history
We were not yet able to pass lists of options to `pip`
commands in our `pip` CMake helper targets. This fixes it.
  • Loading branch information
ax3l committed Oct 9, 2024
1 parent 085925c commit 1cfb747
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ install(CODE "file(CREATE_LINK
#
if(ImpactX_PYTHON)
set(PY_PIP_OPTIONS "-v" CACHE STRING
"Additional parameters to pass to `pip`")
"Additional parameters to pass to `pip` as ; separated list")
set(PY_PIP_INSTALL_OPTIONS "" CACHE STRING
"Additional parameters to pass to `pip install`")
"Additional parameters to pass to `pip install` as ; separated list")

# add a prefix to custom targets so we do not collide if used as a subproject
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
Expand All @@ -412,7 +412,8 @@ if(ImpactX_PYTHON)
${CMAKE_COMMAND} -E rm -f -r impactx-whl
COMMAND
${CMAKE_COMMAND} -E env PYIMPACTX_LIBDIR=$<TARGET_FILE_DIR:pyImpactX>
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} wheel --no-build-isolation --no-deps --wheel-dir=impactx-whl ${ImpactX_SOURCE_DIR}
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} wheel --no-build-isolation --no-deps --wheel-dir=impactx-whl "${ImpactX_SOURCE_DIR}"
COMMAND_EXPAND_LISTS VERBATIM
WORKING_DIRECTORY
${ImpactX_BINARY_DIR}
DEPENDS
Expand All @@ -427,6 +428,7 @@ if(ImpactX_PYTHON)
endif()
add_custom_target(${ImpactX_CUSTOM_TARGET_PREFIX}pip_install_requirements
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} install ${PY_PIP_INSTALL_OPTIONS} -r "${ImpactX_SOURCE_DIR}/${pyImpactX_REQUIREMENT_FILE}"
COMMAND_EXPAND_LISTS VERBATIM
WORKING_DIRECTORY
${ImpactX_BINARY_DIR}
)
Expand All @@ -444,6 +446,7 @@ if(ImpactX_PYTHON)
add_custom_target(${ImpactX_CUSTOM_TARGET_PREFIX}pip_install
${CMAKE_COMMAND} -E env IMPACTX_MPI=${ImpactX_MPI}
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} install --force-reinstall --no-index --no-deps ${PY_PIP_INSTALL_OPTIONS} --find-links=impactx-whl impactx
COMMAND_EXPAND_LISTS VERBATIM
WORKING_DIRECTORY
${ImpactX_BINARY_DIR}
DEPENDS
Expand All @@ -456,6 +459,7 @@ if(ImpactX_PYTHON)
add_custom_target(${ImpactX_CUSTOM_TARGET_PREFIX}pip_install_nodeps
${CMAKE_COMMAND} -E env IMPACTX_MPI=${ImpactX_MPI}
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} install --force-reinstall --no-index --no-deps ${PY_PIP_INSTALL_OPTIONS} --find-links=impactx-whl impactx
COMMAND_EXPAND_LISTS VERBATIM
WORKING_DIRECTORY
${ImpactX_BINARY_DIR}
DEPENDS
Expand Down
4 changes: 2 additions & 2 deletions docs/source/install/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ CMake Option Default & Values Des
``ImpactX_PRECISION`` SINGLE/**DOUBLE** Floating point precision (single/double)
``ImpactX_PYTHON`` ON/**OFF** Python bindings
``Python_EXECUTABLE`` (newest found) Path to Python executable
``PY_PIP_OPTIONS`` ``-v`` Additional options for ``pip``, e.g., ``-vvv``
``PY_PIP_INSTALL_OPTIONS`` Additional options for ``pip install``, e.g., ``--user``
``PY_PIP_OPTIONS`` ``-v`` Additional options for ``pip``, e.g., ``-vvv;-q``
``PY_PIP_INSTALL_OPTIONS`` Additional options for ``pip install``, e.g., ``--user;-q``
=============================== ============================================ ===========================================================

ImpactX can be configured in further detail with options from AMReX, which are `documented in the AMReX manual <https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html#customization-options>`_.
Expand Down

0 comments on commit 1cfb747

Please sign in to comment.