From bf1cc2241b8ca0bf1cf9786aa5d7db735e9c704c Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:01:58 -0400 Subject: [PATCH 1/5] Made a number of changes. Versioning is now controlled via the pyproject.toml file. The swiftest_driver executable is now packaged in the wheel. Ready for first official release! --- version.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 version.txt diff --git a/version.txt b/version.txt deleted file mode 100644 index 882e30299..000000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -2023.9.0 \ No newline at end of file From a13c4661877dcedc1103cf12778f898f350458de Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:02:30 -0400 Subject: [PATCH 2/5] Made a number of changes. Versioning is now controlled via the pyproject.toml file. The swiftest_driver executable is now packaged in the wheel. Ready for first official release! --- .gitignore | 2 +- CMakeLists.txt | 4 +++- README.md | 5 +++-- buildscripts/set_environment.sh | 33 +++++++++++++++++++++++++++++++++ pyproject.toml | 9 +++++++-- src/CMakeLists.txt | 3 +++ src/globals/globals_module.f90 | 2 +- 7 files changed, 51 insertions(+), 7 deletions(-) create mode 100755 buildscripts/set_environment.sh diff --git a/.gitignore b/.gitignore index 8135a42d5..f3351109d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ dump* !tests/** *ipynb_checkpoints **/.DS_Store -!version.txt +version.txt !LICENSE.txt !requirements.txt !pyproject.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a21a2d07..96d7733c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ # Define the project and the depencies that it has ################################################## CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0...3.27.1) +SET(SKBUILD_PROJECT_NAME "swiftest" CACHE STRING "Name of project set by scikit-build") +SET(SKBUILD_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/bin" CACHE STRING "Install location of binary executable") # Get version stored in text file FILE(READ "version.txt" VERSION) @@ -29,7 +31,7 @@ ENDIF () OPTION(USE_COARRAY "Use Coarray Fortran for parallelization of test particles" OFF) OPTION(USE_OPENMP "Use OpenMP for parallelization" ON) OPTION(USE_SIMD "Use SIMD vectorization" ON) -OPTION(BUILD_SHARED_LIBS "Build using shared libraries" OFF) +OPTION(BUILD_SHARED_LIBS "Build using shared libraries" ON) # The following section is modified from Numpy f2py documentation IF(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) diff --git a/README.md b/README.md index 4a7577922..9d414b765 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,8 @@ The Swiftest CMake configuration comes with several customization options: | Set Fortran compiler path | \-DCMAKE_Fortran_COMPILER=/path/to/fortran/compiler | | Set path to make program | \-DCMAKE_MAKE_PROGRAM=/path/to/make | | Enable/Disable shared libraries (Intel only) | \-DBUILD_SHARED_LIBS=[**ON\|OFF] | -| Add additional include path | \-DCMAKE_Fortran_FLAGS="-I/path/to/libries | +| Add additional include path | \-DCMAKE_Fortran_FLAGS="-I/path/to/libraries | +| Install prefix | \-DCMAKE_INSTALL_PREFIX=["/path/to/install"\|**"/usr/local"**] | To see a list of all possible options available to CMake: @@ -137,7 +138,7 @@ To see a list of all possible options available to CMake: $ cmake -B build -S . -LA ``` -The Swiftest executable, called ```swiftest_driver```, should now be created in the ```bin/``` directory. +The Swiftest executable, called `swiftest_driver`, should now be created in the `bin/` directory. **Download the `swiftest_driver` as a Docker or Singularity container.** diff --git a/buildscripts/set_environment.sh b/buildscripts/set_environment.sh new file mode 100755 index 000000000..956057fee --- /dev/null +++ b/buildscripts/set_environment.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Sets environment flags on MacOS +set -a +SCRIPT_DIR=$(realpath $(dirname $0)) +ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) +MACOSX_DEPLOYMENT_TARGET="$(sw_vers -productVersion)" +PREFIX="/usr/local" +HOMEBREW_PREFIX="$(brew --prefix)" +LD_LIBRARY_PATH="/usr/local/lib:${PREFIX}/lib:${HOMEBREW_PREFIX}/lib" +LDFLAGS="-Wl,-rpath,${ROOT_DIR}/lib -Wl,-no_compact_unwind -L${PREFIX}/lib -L${HOMEBREW_PREFIX}/lib" +CPATH="/usr/local/include:${PREFIX}/include:${HOMEBREW_PREFIX}/include:${ROOT_DIR}/include" +CPPFLAGS="-isystem ${PREFIX}/include -isystem /usr/local/include" +LIBS="-lomp" +FCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" +FFFLAGS="${FCFLAGS}" +CFLAGS="${FCFLAGS} -Wno-deprecated-non-prototype" +CXXFLAGS="${CFLAGS}" +HDF5_ROOT="${PREFIX}" +HDF5_LIBDIR="${HDF5_ROOT}/lib" +HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" +NETCDF_FORTRAN_HOME="${PREFIX}" +NETCDF_INCLUDE="${PREFIX}" +NCDIR="${PREFIX}" +NFDIR="${PREFIX}" +FC="$(command -v gfortran-12)" +F77="${FC}" +CC="/usr/bin/clang" +CXX="/usr/bin/clang++" +CPP="/usr/bin/cpp" +AR="/usr/bin/ar" +NM="/usr/bin/nm" +RANLIB="/usr/bin/ranlib" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 052b2ac32..f829a3577 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "swiftest" -version = "2023.9.0" +version = "2023.9.1" authors=[ {name = 'David A. Minton', email='daminton@purdue.edu'}, {name = 'Carlisle Wishard'}, @@ -51,7 +51,7 @@ requires = [ build-backend = "scikit_build_core.build" [tool.scikit-build] -cmake.args = ["-DBUILD_SHARED_LIBS=ON","-DUSE_SIMD=OFF"] +cmake.args = ["-DUSE_SIMD=OFF"] sdist.include = ["src/globals/globals_module.f90.in","swiftest/*.py","swiftest/*.pyx","swiftest/*.h"] [tool.cibuildwheel] @@ -108,3 +108,8 @@ NETCDF_FORTRAN_HOME="/usr/local" NETCDF_INCLUDE="/usr/local/include" LD_LIBRARY_PATH="/usr/local/lib:/project/lib" CPATH="/usr/local/include:/project/include" + +[[tool.scikit-build.generate]] +path = "version.txt" +location = "source" +template = '''${version}''' \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 661c72cb8..1a4dc45d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -136,6 +136,9 @@ ENDIF() SET(SWIFTEST_DRIVER swiftest_driver) ADD_EXECUTABLE(${SWIFTEST_DRIVER} ${DRIVER_src}) +# Be sure the executable gets packaged with the wheel +SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${SKBUILD_SCRIPTS_DIR}) + ##################################################### # Add the needed libraries ##################################################### diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index a12c018ce..490c8ab00 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -48,7 +48,7 @@ module globals integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper !! conversion - offset between upper and lower - character(*), parameter :: VERSION = "2023.9.0" !! Swiftest version + character(*), parameter :: VERSION = "2023.9.1" !! Swiftest version !> Symbolic name for integrator types character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR" From 64922a35eadcf1f7b6bb446b8c3094898c532bdb Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:01:58 -0400 Subject: [PATCH 3/5] Versioning controlled via pyproject.toml file. not tracked any more --- version.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 version.txt diff --git a/version.txt b/version.txt deleted file mode 100644 index 882e30299..000000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -2023.9.0 \ No newline at end of file From ddbdf0bf10e961a6963901feb256ce73b438a06c Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:02:30 -0400 Subject: [PATCH 4/5] Made a number of changes. Versioning is now controlled via the pyproject.toml file. The swiftest_driver executable is now packaged in the wheel. Ready for first official release! --- .gitignore | 2 +- CMakeLists.txt | 4 +++- README.md | 5 +++-- buildscripts/set_environment.sh | 33 +++++++++++++++++++++++++++++++++ pyproject.toml | 9 +++++++-- src/CMakeLists.txt | 3 +++ src/globals/globals_module.f90 | 2 +- 7 files changed, 51 insertions(+), 7 deletions(-) create mode 100755 buildscripts/set_environment.sh diff --git a/.gitignore b/.gitignore index 8135a42d5..f3351109d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ dump* !tests/** *ipynb_checkpoints **/.DS_Store -!version.txt +version.txt !LICENSE.txt !requirements.txt !pyproject.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a21a2d07..96d7733c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ # Define the project and the depencies that it has ################################################## CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0...3.27.1) +SET(SKBUILD_PROJECT_NAME "swiftest" CACHE STRING "Name of project set by scikit-build") +SET(SKBUILD_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/bin" CACHE STRING "Install location of binary executable") # Get version stored in text file FILE(READ "version.txt" VERSION) @@ -29,7 +31,7 @@ ENDIF () OPTION(USE_COARRAY "Use Coarray Fortran for parallelization of test particles" OFF) OPTION(USE_OPENMP "Use OpenMP for parallelization" ON) OPTION(USE_SIMD "Use SIMD vectorization" ON) -OPTION(BUILD_SHARED_LIBS "Build using shared libraries" OFF) +OPTION(BUILD_SHARED_LIBS "Build using shared libraries" ON) # The following section is modified from Numpy f2py documentation IF(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) diff --git a/README.md b/README.md index 4a7577922..9d414b765 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,8 @@ The Swiftest CMake configuration comes with several customization options: | Set Fortran compiler path | \-DCMAKE_Fortran_COMPILER=/path/to/fortran/compiler | | Set path to make program | \-DCMAKE_MAKE_PROGRAM=/path/to/make | | Enable/Disable shared libraries (Intel only) | \-DBUILD_SHARED_LIBS=[**ON\|OFF] | -| Add additional include path | \-DCMAKE_Fortran_FLAGS="-I/path/to/libries | +| Add additional include path | \-DCMAKE_Fortran_FLAGS="-I/path/to/libraries | +| Install prefix | \-DCMAKE_INSTALL_PREFIX=["/path/to/install"\|**"/usr/local"**] | To see a list of all possible options available to CMake: @@ -137,7 +138,7 @@ To see a list of all possible options available to CMake: $ cmake -B build -S . -LA ``` -The Swiftest executable, called ```swiftest_driver```, should now be created in the ```bin/``` directory. +The Swiftest executable, called `swiftest_driver`, should now be created in the `bin/` directory. **Download the `swiftest_driver` as a Docker or Singularity container.** diff --git a/buildscripts/set_environment.sh b/buildscripts/set_environment.sh new file mode 100755 index 000000000..956057fee --- /dev/null +++ b/buildscripts/set_environment.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Sets environment flags on MacOS +set -a +SCRIPT_DIR=$(realpath $(dirname $0)) +ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) +MACOSX_DEPLOYMENT_TARGET="$(sw_vers -productVersion)" +PREFIX="/usr/local" +HOMEBREW_PREFIX="$(brew --prefix)" +LD_LIBRARY_PATH="/usr/local/lib:${PREFIX}/lib:${HOMEBREW_PREFIX}/lib" +LDFLAGS="-Wl,-rpath,${ROOT_DIR}/lib -Wl,-no_compact_unwind -L${PREFIX}/lib -L${HOMEBREW_PREFIX}/lib" +CPATH="/usr/local/include:${PREFIX}/include:${HOMEBREW_PREFIX}/include:${ROOT_DIR}/include" +CPPFLAGS="-isystem ${PREFIX}/include -isystem /usr/local/include" +LIBS="-lomp" +FCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" +FFFLAGS="${FCFLAGS}" +CFLAGS="${FCFLAGS} -Wno-deprecated-non-prototype" +CXXFLAGS="${CFLAGS}" +HDF5_ROOT="${PREFIX}" +HDF5_LIBDIR="${HDF5_ROOT}/lib" +HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" +NETCDF_FORTRAN_HOME="${PREFIX}" +NETCDF_INCLUDE="${PREFIX}" +NCDIR="${PREFIX}" +NFDIR="${PREFIX}" +FC="$(command -v gfortran-12)" +F77="${FC}" +CC="/usr/bin/clang" +CXX="/usr/bin/clang++" +CPP="/usr/bin/cpp" +AR="/usr/bin/ar" +NM="/usr/bin/nm" +RANLIB="/usr/bin/ranlib" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 052b2ac32..f829a3577 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "swiftest" -version = "2023.9.0" +version = "2023.9.1" authors=[ {name = 'David A. Minton', email='daminton@purdue.edu'}, {name = 'Carlisle Wishard'}, @@ -51,7 +51,7 @@ requires = [ build-backend = "scikit_build_core.build" [tool.scikit-build] -cmake.args = ["-DBUILD_SHARED_LIBS=ON","-DUSE_SIMD=OFF"] +cmake.args = ["-DUSE_SIMD=OFF"] sdist.include = ["src/globals/globals_module.f90.in","swiftest/*.py","swiftest/*.pyx","swiftest/*.h"] [tool.cibuildwheel] @@ -108,3 +108,8 @@ NETCDF_FORTRAN_HOME="/usr/local" NETCDF_INCLUDE="/usr/local/include" LD_LIBRARY_PATH="/usr/local/lib:/project/lib" CPATH="/usr/local/include:/project/include" + +[[tool.scikit-build.generate]] +path = "version.txt" +location = "source" +template = '''${version}''' \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 661c72cb8..1a4dc45d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -136,6 +136,9 @@ ENDIF() SET(SWIFTEST_DRIVER swiftest_driver) ADD_EXECUTABLE(${SWIFTEST_DRIVER} ${DRIVER_src}) +# Be sure the executable gets packaged with the wheel +SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${SKBUILD_SCRIPTS_DIR}) + ##################################################### # Add the needed libraries ##################################################### diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index a12c018ce..490c8ab00 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -48,7 +48,7 @@ module globals integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper !! conversion - offset between upper and lower - character(*), parameter :: VERSION = "2023.9.0" !! Swiftest version + character(*), parameter :: VERSION = "2023.9.1" !! Swiftest version !> Symbolic name for integrator types character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR" From 331a52e752b58d28cd21c135122c1c1a2652c93f Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:26:11 -0400 Subject: [PATCH 5/5] Switched to only build wheels on release to prevent wheels from being constantly built --- .github/workflows/build_wheels.yml | 4 +++- src/globals/globals_module.f90 | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 5285629d2..a607e1741 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -1,6 +1,8 @@ name: swiftest -on: [push, pull_request] +on: + release: + types: [published] jobs: build_wheels: diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index 490c8ab00..ffc1854ab 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -48,7 +48,7 @@ module globals integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper !! conversion - offset between upper and lower - character(*), parameter :: VERSION = "2023.9.1" !! Swiftest version + character(*), parameter :: VERSION = "" !! Swiftest version !> Symbolic name for integrator types character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR"