Skip to content

Commit

Permalink
Merge branch 'hotfix/0.13.3'
Browse files Browse the repository at this point in the history
* hotfix/0.13.3:
  Version 0.13.3
  FCKIT_VENV: make Python3 check optional if feature is not enabled
  FCKIT_VENV: simplify caching procedure for cross-platform builds
  FCKIT_VENV: remove redundant editable build option
  FCKIT_VENV: only install dependencies from requirements file for offline mode
  YAML_READER: switch ruamel.yaml.clib to build from source
  FCKIT_VENV: downgrade setuptools version
  FCKIT_VENV: enable offline install option
  YAML_READER: split installation into dependencies and installation from source
  YAML_READER: remove pytest dependency
  FCKIT_VENV: only enable if python < 3.12
  YAML_READER: only do pip upgrade for python3.8
  FYPP: propagate dependencies of fypp files (#50)
  add_fctest requires cmake 3.12; This disables cmake deprecation warnings
  • Loading branch information
wdeconinck committed Dec 19, 2024
2 parents 9e93eae + 90a461f commit 7a5e72b
Show file tree
Hide file tree
Showing 51 changed files with 64 additions and 17,757 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ set( install_permissions OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_E

# Discover only system install Python 3
set( Python3_FIND_VIRTUALENV STANDARD )
find_package( Python3 COMPONENTS Interpreter REQUIRED )
find_package( Python3 COMPONENTS Interpreter )

ecbuild_add_option( FEATURE FCKIT_VENV
DEFAULT OFF
DESCRIPTION "Install Python virtual environment with fypp and a yaml parser"
CONDITION Python3_VERSION VERSION_GREATER_EQUAL 3.8 )
CONDITION Python3_VERSION VERSION_GREATER_EQUAL 3.8 AND Python3_VERSION VERSION_LESS 3.12 )

ecbuild_add_option( FEATURE FCKIT_VENV_EDITABLE
ecbuild_add_option( FEATURE FCKIT_VENV_OFFLINE
DEFAULT OFF
DESCRIPTION "Install editable packages in fckit Python virtual environment"
CONDITION HAVE_FCKIT_VENV )
DESCRIPTION "Offline install of fckit Python virtual environment"
CONDITION DEFINED FCKIT_VENV_WHEEL_DIR )

if( HAVE_FCKIT_VENV )
fckit_install_venv()
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@ Various Fortran modules helpful to create mixed-language applications
- MPI
- Logging

### Offline build of fckit Python virtual environment

An offline build/installation of the fckit Python virtual environment can be completed as follows:

1. Download all necessary Python dependencies listed in fckit/requirements.txt. `ruamel.yaml.clib`
is not a pure Python package, so we have to ensure a wheel compatible with the target platform is
downloaded. pip compatibility tags for any system can be displayed using `python3 -m pip debug --verbose`,
and buit-distributions (i.e. wheels) for ruamel.yaml.clib can be found [here](https://pypi.org/project/ruamel.yaml.clib/#files).
For a linux installation based on an x86 architecture using Python3.10, the following command can be used:

```
python3 -m pip download -r requirements.txt -d <dir-to-store-dependencies> \
--only-binary=:all: --python-version 310 --platform manylinux_2_17_x86_64
```

2. scp/rsync/copy the directory containing the dependencies to the offline system.

3. Add the following two arguments to the fckit CMake configuration step:

```
-DENABLE_FCKIT_VENV_OFFLINE=ON -DFCKIT_VENV_WHEEL_DIR=<dir-containing-dependencies>
```

### License

Please read LICENSE.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.13.2
0.13.3

2 changes: 1 addition & 1 deletion cmake/add_fctest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ endfunction()

function( add_fctest )

cmake_minimum_required( VERSION 3.6 )
cmake_minimum_required( VERSION 3.12 )
cmake_policy( SET CMP0064 NEW ) # Recognize ``TEST`` as operator for the ``if()`` command. (introduced in CMake version 3.4)

ecbuild_add_test( ${ARGV} )
Expand Down
36 changes: 18 additions & 18 deletions cmake/fckit_install_venv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

macro( fckit_install_venv )

list( APPEND PIP_OPTIONS "--disable-pip-version-check" )

# Create a virtualenv
set( VENV_PATH ${CMAKE_CURRENT_BINARY_DIR}/fckit_venv )
ecbuild_info( "Create Python virtual environment ${VENV_PATH}" )
Expand All @@ -36,31 +34,33 @@ macro( fckit_install_venv )
# Find newly created python venv
find_package( Python3 COMPONENTS Interpreter REQUIRED )

set( _pkg_name "fckit_yaml_reader")
if( HAVE_TESTS )
set( _pkg_name "fckit_yaml_reader/[tests]")
if( Python3_VERSION VERSION_EQUAL 3.8 )
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip --disable-pip-version-check
install --upgrade ${PIP_OPTIONS} pip OUTPUT_QUIET ERROR_QUIET )
endif()

execute_process( COMMAND ${Python3_EXECUTABLE} -m pip install --upgrade ${PIP_OPTIONS} pip OUTPUT_QUIET )

if( HAVE_FCKIT_VENV_EDITABLE )
# Use checked-out source instead of installing into venv
list( APPEND PIP_OPTIONS "-e" )
# install pip dependencies
if( HAVE_FCKIT_VENV_OFFLINE )
ecbuild_info( "Install fckit_yaml_reader dependencies in virtual environment ${VENV_PATH}" )
list( APPEND PIP_OPTIONS "--no-build-isolation;--no-index;--find-links=${FCKIT_VENV_WHEEL_DIR}" )
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip --disable-pip-version-check
install -r ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt
${PIP_OPTIONS} OUTPUT_QUIET )
endif()


# install virtual environment from requirements
set( _pkg_name "fckit_yaml_reader")
ecbuild_info( "Install fckit_yaml_reader in virtual environment ${VENV_PATH}" )
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip install ${PIP_OPTIONS} ${CMAKE_CURRENT_SOURCE_DIR}/src/fckit/${_pkg_name} OUTPUT_QUIET )
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip --disable-pip-version-check
install ${PIP_OPTIONS} ${CMAKE_CURRENT_SOURCE_DIR}/src/fckit/${_pkg_name} OUTPUT_QUIET )

# install ruamel
ecbuild_info( "Install ruamel.yaml in virtual environment ${VENV_PATH}" )
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip install ${PIP_OPTIONS} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/ruamel.yaml-0.18.6 OUTPUT_QUIET )

# install fypp
if( NOT HAVE_FCKIT_VENV_EDITABLE )
list( APPEND PIP_OPTIONS "--use-pep517" )
endif()
list( APPEND PIP_OPTIONS "--use-pep517" )
ecbuild_info( "Install fypp in virtual environment ${VENV_PATH}" )
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip install ${PIP_OPTIONS} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/fypp-3.2-b8dd58b-20230822 OUTPUT_QUIET )
execute_process( COMMAND ${Python3_EXECUTABLE} -m pip --disable-pip-version-check
install ${PIP_OPTIONS} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/fypp-3.2-b8dd58b-20230822 OUTPUT_QUIET )

if( ECBUILD_INSTALL_LIBRARY_HEADERS )
install( DIRECTORY ${VENV_PATH} DESTINATION . PATTERN "bin/*" PERMISSIONS ${install_permissions} )
Expand Down
9 changes: 8 additions & 1 deletion cmake/fckit_preprocess_fypp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,17 @@ function( fckit_preprocess_fypp_sources output )
set( short_outfile "${base}.F90")
endif()

get_source_file_property( _depends ${filename} OBJECT_DEPENDS )

unset( ${filename}_depends )
if( _depends )
set( ${filename}_depends ${_depends} )
endif()

add_custom_command(
OUTPUT ${outfile}
COMMAND ${CMAKE_COMMAND} -E env FCKIT_EVAL_ARGS_EXCLUDE="${_PAR_FYPP_ARGS_EXCLUDE}" ${FYPP} ${args} ${CMAKE_CURRENT_SOURCE_DIR}/${filename} ${outfile}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${filename} ${_PAR_DEPENDS}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${filename} ${_PAR_DEPENDS} ${${filename}_depends}
COMMENT "[fypp] Preprocessor generating ${short_outfile}" )

set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
Expand Down
Loading

0 comments on commit 7a5e72b

Please sign in to comment.