Skip to content

Commit 7d23493

Browse files
authored
CMake: Fix List of Pip Options (#377)
We were not yet able to pass lists of options to `pip` commands in our `pip` CMake helper targets. This fixes it. Follow-up to #22 X-ref: spack/spack#46765
1 parent 1ec98e1 commit 7d23493

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ endif()
274274
# pip helpers for the amrex package ###########################################
275275
#
276276
set(PY_PIP_OPTIONS "-v" CACHE STRING
277-
"Additional parameters to pass to `pip`")
277+
"Additional parameters to pass to `pip` as ; separated list")
278278
set(PY_PIP_INSTALL_OPTIONS "" CACHE STRING
279-
"Additional parameters to pass to `pip install`")
279+
"Additional parameters to pass to `pip install` as ; separated list")
280280

281281
# add a prefix to custom targets so we do not collide if used as a subproject
282282
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
@@ -292,7 +292,8 @@ add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_wheel
292292
${CMAKE_COMMAND} -E rm -f -r amrex-whl
293293
COMMAND
294294
${CMAKE_COMMAND} -E env PYAMREX_LIBDIR=${CMAKE_PYTHON_OUTPUT_DIRECTORY}/amrex/
295-
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} wheel --no-build-isolation --no-deps --wheel-dir=amrex-whl ${pyAMReX_SOURCE_DIR}
295+
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} wheel --no-build-isolation --no-deps --wheel-dir=amrex-whl "${pyAMReX_SOURCE_DIR}"
296+
COMMAND_EXPAND_LISTS VERBATIM
296297
WORKING_DIRECTORY
297298
${pyAMReX_BINARY_DIR}
298299
DEPENDS
@@ -302,6 +303,7 @@ add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_wheel
302303
# this will also upgrade/downgrade dependencies, e.g., when the version of numpy changes
303304
add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_install_requirements
304305
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} install ${PY_PIP_INSTALL_OPTIONS} -r "${pyAMReX_SOURCE_DIR}/requirements.txt"
306+
COMMAND_EXPAND_LISTS VERBATIM
305307
WORKING_DIRECTORY
306308
${pyAMReX_BINARY_DIR}
307309
)
@@ -312,6 +314,7 @@ add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_install_requirements
312314
add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_install
313315
${CMAKE_COMMAND} -E env AMREX_MPI=${AMReX_MPI}
314316
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} install --force-reinstall --no-index --no-deps ${PY_PIP_INSTALL_OPTIONS} --find-links=amrex-whl amrex
317+
COMMAND_EXPAND_LISTS VERBATIM
315318
WORKING_DIRECTORY
316319
${pyAMReX_BINARY_DIR}
317320
DEPENDS
@@ -323,7 +326,8 @@ add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_install
323326
# this is for package managers only
324327
add_custom_target(${pyAMReX_CUSTOM_TARGET_PREFIX}pip_install_nodeps
325328
${CMAKE_COMMAND} -E env AMREX_MPI=${AMReX_MPI}
326-
${Python_EXECUTABLE} -m pip install --force-reinstall --no-index --no-deps ${PY_PIP_INSTALL_OPTIONS} --find-links=amrex-whl amrex
329+
${Python_EXECUTABLE} -m pip ${PY_PIP_OPTIONS} install --force-reinstall --no-index --no-deps ${PY_PIP_INSTALL_OPTIONS} --find-links=amrex-whl amrex
330+
COMMAND_EXPAND_LISTS VERBATIM
327331
WORKING_DIRECTORY
328332
${pyAMReX_BINARY_DIR}
329333
DEPENDS

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ If you are using the pip-driven install, selected [AMReX CMake options](https://
181181
| `PYAMREX_LIBDIR` | *None* | If set, search for pre-built a pyAMReX library |
182182
| `PYAMREX_CCACHE` | **ON**/OFF | Search and use CCache to speed up rebuilds |
183183
| `PYAMREX_IPO` | **ON**/OFF | Compile with interprocedural/link optimization (IPO/LTO) |
184-
| `PY_PIP_OPTIONS` | `-v` | Additional options for ``pip``, e.g., ``-vvv`` |
185-
| `PY_PIP_INSTALL_OPTIONS` | *None* | Additional options for ``pip install``, e.g., ``--user`` |
184+
| `PY_PIP_OPTIONS` | `-v` | Additional options for ``pip``, e.g., ``-vvv;-q`` |
185+
| `PY_PIP_INSTALL_OPTIONS` | *None* | Additional options for ``pip install``, e.g., ``--user;-q`` |
186186

187187
Furthermore, pyAMReX adds a few selected CMake build options:
188188

docs/source/install/cmake.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ CMake Option Default & Values Des
9191
``AMReX_SPACEDIM`` ``3`` Dimension(s) of AMReX as a ``;``-separated list
9292
``AMReX_BUILD_SHARED_LIBS`` ON/**OFF** Build AMReX library as shared (required for app extensions)
9393
``pyAMReX_INSTALL`` **ON**/OFF Enable install targets for pyAMReX
94-
``PY_PIP_OPTIONS`` ``-v`` Additional options for ``pip``, e.g., ``-vvv``
95-
``PY_PIP_INSTALL_OPTIONS`` *None* Additional options for ``pip install``, e.g., ``--user``
94+
``PY_PIP_OPTIONS`` ``-v`` Additional options for ``pip``, e.g., ``-vvv;-q``
95+
``PY_PIP_INSTALL_OPTIONS`` *None* Additional options for ``pip install``, e.g., ``--user;-q``
9696
``Python_EXECUTABLE`` (newest found) Path to Python executable
9797
=============================== ============================================ ===========================================================
9898

0 commit comments

Comments
 (0)