Skip to content

Commit

Permalink
Merge branch 'ckhrulev/packaging' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ckhroulev committed Feb 27, 2024
2 parents bcbab6e + 714b4af commit 6cbfee2
Show file tree
Hide file tree
Showing 67 changed files with 493 additions and 108 deletions.
62 changes: 61 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
mkdir -p build
cmake -B build -S doc/
make -C build manual_html
mv build/sphinx/html ./manual_html
mv build/sphinx/manual_html ./manual_html
- persist_to_workspace:
root: .
paths: manual_html
Expand Down Expand Up @@ -271,6 +271,64 @@ jobs:
--message "Update the source code browser"
--dist doxygen
build-and-test-with-ubuntu-libs:
docker:
- image: ckhrulev/pism-ubuntu-deb-package:0.1.1

environment:
CC: mpicc
CXX: mpicxx
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1

steps:
- checkout
- run:
name: Configure PISM
command: >-
cmake -S . -B build
-DCMAKE_BUILD_TYPE=Debug
-DPism_BUILD_EXTRA_EXECS=YES
-DPism_USE_PROJ=YES
- run:
name: Build PISM
command: make --no-print-directory -C build -j ${N:-4} package
- run:
name: Test PISM
command: cd build && ctest -j ${N:-4} --output-on-failure

build-deb-package:
docker:
- image: ckhrulev/pism-ubuntu-deb-package:0.1.1

environment:
CC: mpicc
CXX: mpicxx

steps:
- checkout
- run:
name: Configure PISM
command: >-
cmake -S . -B build
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=/usr
-DPism_BUILD_DOCS=YES
-DPism_BUILD_EXTRA_EXECS=NO
-DPism_BUILD_PYTHON_BINDINGS=NO
-DPism_USE_PROJ=YES
- run:
name: Build PISM
command: make --no-print-directory -C build -j ${N:-4} package
- run:
name: Move the package
command: mkdir -p /tmp/package && mv build/*.deb /tmp/package/
- run:
name: Test the package
command: lintian /tmp/package/*.deb
- store_artifacts:
path: /tmp/package

workflows:
version: 2
build-and-test:
Expand Down Expand Up @@ -336,6 +394,8 @@ workflows:
- manual-html
- manual-pdf
- doxygen
- build-and-test-with-ubuntu-libs
- build-deb-package

- deploy-p:
requires:
Expand Down
44 changes: 9 additions & 35 deletions CMake/PISM_CMake_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ endmacro(pism_use_rpath)

# Set CMake variables to disable rpath
macro(pism_dont_use_rpath)
set (CMAKE_SKIP_BUILD_RPATH TRUE)
set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
set (CMAKE_SKIP_INSTALL_RPATH TRUE)
endmacro(pism_dont_use_rpath)

# Set CMake variables to ensure that everything is static
Expand All @@ -48,31 +45,16 @@ macro(pism_strictly_static)
pism_dont_use_rpath()
endmacro(pism_strictly_static)

# Set Pism_VERSION, Pism_VERSION_LONG
macro(pism_set_revision_tag)
# Set Pism_VERSION_LONG
macro(pism_set_full_version)
if (EXISTS ${Pism_SOURCE_DIR}/.git)
# get version information from the repository
find_program (GIT_EXECUTABLE git DOC "Git executable")
mark_as_advanced(GIT_EXECUTABLE)
# Get the current branch
execute_process (COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
execute_process (COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${Pism_SOURCE_DIR}
OUTPUT_VARIABLE Pism_BRANCH
OUTPUT_VARIABLE Pism_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${Pism_BRANCH} MATCHES "main")
# Get the latest tag
execute_process (COMMAND ${GIT_EXECUTABLE} describe --always --match v?.?*
WORKING_DIRECTORY ${Pism_SOURCE_DIR}
OUTPUT_VARIABLE Pism_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# remove "v" from vX.Y.Z:
string(REPLACE "v" "" Pism_VERSION ${Pism_VERSION})
else()
execute_process (COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${Pism_SOURCE_DIR}
OUTPUT_VARIABLE Pism_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
execute_process (COMMAND ${GIT_EXECUTABLE} --no-pager log -1 "--pretty=format:%an"
WORKING_DIRECTORY ${Pism_SOURCE_DIR}
OUTPUT_VARIABLE Pism_COMMIT_AUTHOR
Expand All @@ -81,21 +63,13 @@ macro(pism_set_revision_tag)
WORKING_DIRECTORY ${Pism_SOURCE_DIR}
OUTPUT_VARIABLE Pism_COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${Pism_BRANCH} MATCHES "main")
set(Pism_VERSION_LONG "${Pism_VERSION} committed by ${Pism_COMMIT_AUTHOR}")
else()
set(Pism_VERSION_LONG "${Pism_COMMIT_DATE}-${Pism_VERSION} committed by ${Pism_COMMIT_AUTHOR}")
endif()
elseif(EXISTS ${Pism_SOURCE_DIR}/VERSION)
# No repository info: we are probably building from a tarball
file(STRINGS ${Pism_SOURCE_DIR}/VERSION Pism_VERSION LIMIT_COUNT 1)
set(Pism_VERSION_LONG "${Pism_VERSION}")
set(Pism_VERSION_LONG "${Pism_VERSION}-${Pism_COMMIT_HASH} committed by ${Pism_COMMIT_AUTHOR} on ${Pism_COMMIT_DATE}")
else()
set (Pism_VERSION "unknown")
endif (EXISTS ${Pism_SOURCE_DIR}/.git)
set(Pism_VERSION_LONG "${Pism_VERSION}")
endif()

message(STATUS "PISM version: '${Pism_VERSION_LONG}'")
endmacro(pism_set_revision_tag)
endmacro(pism_set_full_version)

# Set pedantic compiler flags
macro(pism_set_pedantic_flags)
Expand Down
69 changes: 56 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
cmake_minimum_required (VERSION 3.16)
project (Pism C CXX)

# Get PISM's "short" X.Y.Z version from a file
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION Pism_VERSION LIMIT_COUNT 1)
else()
message(FATAL_ERROR "'VERSION' not found: cannot determine PISM's version")
endif()

project (Pism
VERSION ${Pism_VERSION}
HOMEPAGE_URL "https://www.pism.io"
LANGUAGES C CXX)

include ("CMake/PISM_CMake_macros.cmake")
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
pism_set_full_version()

include (GNUInstallDirs)
# doc directory: override capitalization ("pism" instead of "Pism" from the "project(...)"
# call above)
set(CMAKE_INSTALL_DOCDIR ${CMAKE_INSTALL_DATAROOTDIR}/doc/pism)

if ((EXISTS "/etc/debian_version") AND ("${CMAKE_INSTALL_PREFIX}" MATCHES "/usr"))
message(STATUS "Installing in /usr on Debian or Ubuntu (we are probably building a package)")
set(Pism_DEBIAN_SYSTEMWIDE YES)
else()
set(Pism_DEBIAN_SYSTEMWIDE NO)
endif()

# Deal with build types
mark_as_advanced(CLEAR CMAKE_BUILD_TYPE)
# Set the build type to "Release" so that users get optimized code by default:
Expand Down Expand Up @@ -39,11 +61,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-fstandalone-debug)
endif()

include ("CMake/PISM_CMake_macros.cmake")
list (APPEND CMAKE_MODULE_PATH "${Pism_SOURCE_DIR}/CMake")

pism_set_revision_tag()

# Put executables in the build directory:
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})

Expand Down Expand Up @@ -85,7 +102,11 @@ option (Pism_PEDANTIC_WARNINGS "Compile with pedantic warnings." ON)
option (Pism_GPROF_FLAGS "Add flags necessary to profile with gprof." OFF)

# Use rpath by default; this has to go first, because rpath settings may be overridden later.
pism_use_rpath()
if (Pism_DEBIAN_SYSTEMWIDE)
pism_dont_use_rpath()
else()
pism_use_rpath()
endif()

if (Pism_LINK_STATICALLY)
pism_strictly_static()
Expand Down Expand Up @@ -155,18 +176,31 @@ if (Pism_BUILD_PYTHON_BINDINGS)
mark_as_advanced (SWIG_DIR SWIG_EXECUTABLE SWIG_VERSION)

set (pism_python_path_py "${CMAKE_CURRENT_BINARY_DIR}/pism_python_path.py")
if (Pism_DEBIAN_SYSTEMWIDE)
set (pism_sysconfig_scheme "deb_system")
else()
set (pism_sysconfig_scheme "posix_prefix")
endif()
file (WRITE "${pism_python_path_py}" "
# Get module installation path from Python:
import sysconfig
print(sysconfig.get_path('platlib', 'posix_prefix', vars={'platbase': '${CMAKE_INSTALL_PREFIX}'}))
print(sysconfig.get_path('platlib', '${pism_sysconfig_scheme}', vars={'platbase': '${CMAKE_INSTALL_PREFIX}'}))
")
unset(pism_sysconfig_scheme)

execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${pism_python_path_py}
OUTPUT_VARIABLE PISM_INSTALL_PYTHON_MODULE_DIR
OUTPUT_VARIABLE PISM_FULL_PYTHON_MODULE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PISM_INSTALL_PYTHON_MODULE_DIR ${PISM_INSTALL_PYTHON_MODULE_DIR}
# convert to a path relative to the install prefix
file(RELATIVE_PATH PISM_PYTHON_MODULE_DIR
${CMAKE_INSTALL_PREFIX} ${PISM_FULL_PYTHON_MODULE_DIR})
unset(pism_python_path_py)
set(PISM_PYTHON_MODULE_DIR ${PISM_PYTHON_MODULE_DIR}
CACHE PATH "Python extension module installation directory." )
set(PISM_FULL_PYTHON_MODULE_DIR ${PISM_FULL_PYTHON_MODULE_DIR}
CACHE PATH "Python extension module installation directory (full path)." )
mark_as_advanced(PISM_PYTHON_MODULE_DIR PISM_FULL_PYTHON_MODULE_DIR)
endif ()

add_custom_target (etags
Expand Down Expand Up @@ -200,11 +234,18 @@ install(PROGRAMS
util/nc2cdo.py
util/nccmp.py
util/plot_profiling.py
DESTINATION ${CMAKE_INSTALL_BINDIR})
DESTINATION ${CMAKE_INSTALL_DATADIR}/pism/bin)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/examples
DESTINATION ${CMAKE_INSTALL_DATADIR}/pism
USE_SOURCE_PERMISSIONS)
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/pism
DIRECTORY_PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
PATTERN .gitignore EXCLUDE
PATTERN __pycache__ EXCLUDE
PATTERN "*.pyc" EXCLUDE
PATTERN "*.nc" EXCLUDE
PATTERN "*.npz" EXCLUDE
PATTERN "*~" EXCLUDE)

add_subdirectory (src)
add_subdirectory (site-packages)
Expand All @@ -224,3 +265,5 @@ add_subdirectory (test)
add_subdirectory (test/regression)

add_subdirectory (docker)

add_subdirectory (package)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2-dev
2.1.99
10 changes: 9 additions & 1 deletion doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ if (NOT Pism_SOURCE_DIR)

include ("${Pism_SOURCE_DIR}/CMake/PISM_CMake_macros.cmake")

pism_set_revision_tag()
if(EXISTS ${Pism_SOURCE_DIR}/VERSION)
file(STRINGS ${Pism_SOURCE_DIR}/VERSION Pism_VERSION LIMIT_COUNT 1)
else()
message(FATAL_ERROR "'VERSION' not found: cannot determine PISM's version")
endif()

pism_set_full_version()

include (GNUInstallDirs)
endif()
Expand All @@ -27,3 +33,5 @@ if (DOXYGEN_EXECUTABLE AND DOXYGEN_DOT_EXECUTABLE)
# Source code browser:
add_subdirectory (browser EXCLUDE_FROM_ALL)
endif ()

add_subdirectory(manpages)
26 changes: 26 additions & 0 deletions doc/manpages/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
find_program(RST2MAN_EXECUTABLE NAMES rst2man rst2man.py)
mark_as_advanced(RST2MAN_EXECUTABLE)

if (RST2MAN_EXECUTABLE)
find_package(UnixCommands)
macro(add_manpages names)
foreach(name ${names})
# Note the sed command: this fixes formatting of command-line options: rst2man
# cannot handle PISM's long options with one dash.
add_custom_command(OUTPUT ${name}.1.gz
COMMAND ${RST2MAN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${name}.rst ${name}.1
COMMAND sed -i -E -e "s/(-[a-zA-Z]+)\\\\fB /\\1/" ${name}.1
COMMAND ${GZIP} -n -9 ${name}.1
DEPENDS ${name}.rst
VERBATIM)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${name}.1.gz
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endforeach(name)
endmacro(add_manpages)

add_manpages("pismr;pismv")

add_custom_target(manpages ALL DEPENDS pismr.1.gz pismv.1.gz)
endif()
5 changes: 5 additions & 0 deletions doc/manpages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This directory contains very basic manpages for most important PISM executables.

To build manpages, make sure that your system has `rst2man` in the `PATH` (on
Debian/Ubuntu this requires `python3-docutils`) and set `Pism_BUILD_DOCS` to "on" using
CMake.
42 changes: 42 additions & 0 deletions doc/manpages/pismr.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
=====
pismr
=====

------------------------------------------------
Parallel Ice Sheet Model (PISM): prognostic runs
------------------------------------------------
:Author: [email protected]
:Date: 2024-2-21
:Copyright: Copyright (C) 2024 Constantine Khrulev
:Version: 0.1
:Manual section: 1
:Manual group: science

SYNOPSIS
========

| pismr -i *input_file.nc* ...
| pismr -boot_file *bootstrapping_file.nc* ...
DESCRIPTION
===========

``pismr`` performs an evolution run using PISM, a Parallel Ice Sheet Model. Please see the
*PISM User's Manual* for details.

OPTIONS
=======

-i input file
-bootstrap enables bootstrapping mode
-y run length, in model years
-o output file name
-help prints PISM and PETSc command-line option help; use with **grep**
-verbose selects stdout verbosity level, 1 -- minimal output, 2 -- normal, 3 -- more debugging info, ...

SEE ALSO
========

- The *User's Manual* and other documentation online at https://www.pism.io/docs/manual

- **pismv** to run some verification tests
Loading

0 comments on commit 6cbfee2

Please sign in to comment.