From caa02f60628f8730d68621dfe8388a570e9bde67 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Wed, 13 Mar 2024 13:42:19 -0500 Subject: [PATCH 1/9] Pass version to all src from build command --- .github/workflows/publish_release.yml | 7 +++++++ .gitignore | 1 + CMakeLists.txt | 8 +++++++- docker/Dockerfile | 3 ++- docker/Rocky.dockerfile | 3 ++- install.py | 7 +++++-- src/CMakeLists.txt | 1 + src/{version.h => version.h.in} | 6 +++--- 8 files changed, 28 insertions(+), 8 deletions(-) rename src/{version.h => version.h.in} (71%) diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index a2ea33de1d..f8384c0b73 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -32,12 +32,14 @@ jobs: run: | echo "version_tag=ci-image-cache" >> "$GITHUB_ENV" echo "stable_tag=ci-image-cache" >> "$GITHUB_ENV" + echo "core_version=999.999.999" >> "$GITHUB_ENV" - name: Tag as stable if: ${{ github.repository_owner == 'cyclus' && github.event_name == 'release' }} run: | echo "version_tag=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" echo "stable_tag=stable" >> "$GITHUB_ENV" + echo "core_version=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" - name: Log in to the Container registry uses: docker/login-action@v3 @@ -77,6 +79,7 @@ jobs: build-args: | pkg_mgr=${{ matrix.pkg_mgr }} ubuntu_version=${{ matrix.ubuntu_versions }} + core_version=${{ env.core_version }} - name: Upload .deb to release if: github.event_name == 'release' && matrix.pkg_mgr == 'apt' && matrix.ubuntu_versions == '22.04' @@ -85,6 +88,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} with: asset_paths: '["cyclus*.deb"]' + build-and-test-rocky-release: runs-on: ubuntu-latest permissions: @@ -105,12 +109,14 @@ jobs: run: | echo "version_tag=ci-image-cache" >> "$GITHUB_ENV" echo "stable_tag=ci-image-cache" >> "$GITHUB_ENV" + echo "core_version=999.999.999" >> "$GITHUB_ENV" - name: Tag as stable if: ${{ github.repository_owner == 'cyclus' && github.event_name == 'release' }} run: | echo "version_tag=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" echo "stable_tag=stable" >> "$GITHUB_ENV" + echo "core_version=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" - name: Log in to the Container registry uses: docker/login-action@v3 @@ -136,3 +142,4 @@ jobs: ghcr.io/cyclus/cyclus_rocky_${{ matrix.rocky_versions }}/cyclus:${{ env.stable_tag }} build-args: | rocky_version=${{ matrix.rocky_versions }} + core_version=${{ env.core_version }} diff --git a/.gitignore b/.gitignore index 1bf40c6478..63ee64e41b 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ src/cyclus_nuc_data.h5 stubs/stub_version.h src/env.cc src/version.cc +src/version.h share/cyclus_nuc_data.h5 src/pyne_decay.h src/pyne_decay.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 12e87a63e0..b2c5cb4f85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,7 +185,7 @@ IF(NOT CYCLUS_DOC_ONLY) ENDIF ( NOT LIBXMLXX_LIBRARIES ) SET(LIBS ${LIBS} ${LIBXMLXX_LIBRARIES}) message("-- LibXML++ Include Dir: ${LIBXMLXX_INCLUDE_DIRS}") - message("-- LibXML++ Librarires: ${LIBXMLXX_LIBRARIES}") + message("-- LibXML++ Libraries: ${LIBXMLXX_LIBRARIES}") # find lapack and link to it FIND_PACKAGE(LAPACK REQUIRED) @@ -397,6 +397,12 @@ IF(NOT CYCLUS_DOC_ONLY) SET(ENV{CYCLUS_CORE_VERSION} "${core_version}") MESSAGE("-- core version ($CYCLUS_CORE_VERSION) set to: ${core_version}") + STRING(REPLACE "." ";" CORE_VERSION_PARTS ${core_version}) + LIST(GET CORE_VERSION_PARTS 0 CYCLUS_MAJOR_VERSION) + LIST(GET CORE_VERSION_PARTS 1 CYCLUS_MINOR_VERSION) + LIST(GET CORE_VERSION_PARTS 2 CYCLUS_MICRO_VERSION) + MESSAGE("Major: ${CYCLUS_MAJOR_VERSION}, Minor: ${CYCLUS_MINOR_VERSION}, Micro ${CYCLUS_MICRO_VERSION}") + ADD_SUBDIRECTORY("${CYCLUS_SHARE_DIR}") ADD_SUBDIRECTORY("${CYCLUS_SOURCE_DIR}") ADD_SUBDIRECTORY("${CYCLUS_TEST_DIR}") diff --git a/docker/Dockerfile b/docker/Dockerfile index 30e3af08e0..7fdef80187 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -140,6 +140,7 @@ COPY --from=cyclus-coverage /cyclus / FROM ${pkg_mgr}-deps as cyclus ARG make_cores=2 +ARG core_version=999.999.999 COPY . /cyclus WORKDIR /cyclus @@ -150,7 +151,7 @@ WORKDIR /cyclus # You may add the option "--cmake-debug" to the following command # for further CMake debugging. -RUN python install.py -j ${make_cores} --build-type=Release --core-version 999999.999999 --allow-milps +RUN python install.py -j ${make_cores} --build-type=Release --core-version ${core_version} --allow-milps ENV PATH /root/.local/bin:$PATH ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus diff --git a/docker/Rocky.dockerfile b/docker/Rocky.dockerfile index 8b0b618a14..73c904ba68 100644 --- a/docker/Rocky.dockerfile +++ b/docker/Rocky.dockerfile @@ -65,6 +65,7 @@ RUN dnf install -y m4 doxygen perl-open perl-XML-Parser diffutils pcre-cpp pcre- FROM libxmlpp as cyclus ARG make_cores=2 +ARG core_version=999.999.999 COPY . /cyclus WORKDIR /cyclus @@ -75,7 +76,7 @@ WORKDIR /cyclus # You may add the option "--cmake-debug" to the following command # for further CMake debugging. -RUN python install.py -j ${make_cores} --build-type=Release --core-version 999999.999999 -D Python3_EXECUTABLE=/usr/bin/python3.11 +RUN python install.py -j ${make_cores} --build-type=Release --core-version ${core_version} -D Python3_EXECUTABLE=/usr/bin/python3.11 ENV PATH /root/.local/bin:$PATH ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus diff --git a/install.py b/install.py index 6c6c35e2b1..c567fe18c9 100755 --- a/install.py +++ b/install.py @@ -80,7 +80,10 @@ def install_cyclus(args): if args.build_type: cmake_cmd += ['-DCMAKE_BUILD_TYPE=' + args.build_type] if args.core_version: - cmake_cmd += ['-DCORE_VERSION=' + args.core_version] + core_version = args.core_version + while len(core_version.split('.')) < 3: # add minor/micro version number if missing + core_version += '.0' + cmake_cmd += ['-DCORE_VERSION=' + core_version] if args.D is not None: cmake_cmd += ['-D' + x for x in args.D] if args.cmake_debug: @@ -190,7 +193,7 @@ def main(): build_type = "the CMAKE_BUILD_TYPE" parser.add_argument('--build-type', '--build_type', help=build_type) - parser.add_argument('--core-version', dest='core_version', default=None, + parser.add_argument('--core-version', dest='core_version', default=None, required=True, help='Sets the core version number.') parser.add_argument('-D', metavar='VAR', action='append', diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7a37268df4..9f8ee1e238 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,7 @@ endif() CONFIGURE_FILE(platform.h.in "${CMAKE_CURRENT_SOURCE_DIR}/platform.h" @ONLY) CONFIGURE_FILE(version.cc.in "${CMAKE_CURRENT_SOURCE_DIR}/version.cc" @ONLY) +CONFIGURE_FILE(version.h.in "${CMAKE_CURRENT_SOURCE_DIR}/version.h" @ONLY) SET(cyclus_install_dir "${CMAKE_INSTALL_PREFIX}") SET(cyclus_build_dir "${CYCLUS_BINARY_DIR}") diff --git a/src/version.h b/src/version.h.in similarity index 71% rename from src/version.h rename to src/version.h.in index 92b28ba0c6..a9a6eb6ee9 100644 --- a/src/version.h +++ b/src/version.h.in @@ -1,9 +1,9 @@ #ifndef CYCLUS_SRC_VERSION_H_ #define CYCLUS_SRC_VERSION_H_ -#define CYCLUS_VERSION_MAJOR 1 -#define CYCLUS_VERSION_MINOR 5 -#define CYCLUS_VERSION_MICRO 5 +#define CYCLUS_VERSION_MAJOR @CYCLUS_MAJOR_VERSION@ +#define CYCLUS_VERSION_MINOR @CYCLUS_MINOR_VERSION@ +#define CYCLUS_VERSION_MICRO @CYCLUS_MICRO_VERSION@ namespace cyclus { namespace version { From 1d223f95450b2ff5ce11cae582877777c4da9565 Mon Sep 17 00:00:00 2001 From: Ben Nibbelink Date: Wed, 13 Mar 2024 14:11:36 -0500 Subject: [PATCH 2/9] fix version update in python setup.py --- CMakeLists.txt | 8 ++++---- setup.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2c5cb4f85..e271e73916 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -401,7 +401,7 @@ IF(NOT CYCLUS_DOC_ONLY) LIST(GET CORE_VERSION_PARTS 0 CYCLUS_MAJOR_VERSION) LIST(GET CORE_VERSION_PARTS 1 CYCLUS_MINOR_VERSION) LIST(GET CORE_VERSION_PARTS 2 CYCLUS_MICRO_VERSION) - MESSAGE("Major: ${CYCLUS_MAJOR_VERSION}, Minor: ${CYCLUS_MINOR_VERSION}, Micro ${CYCLUS_MICRO_VERSION}") + MESSAGE("-- Major: ${CYCLUS_MAJOR_VERSION}, Minor: ${CYCLUS_MINOR_VERSION}, Micro ${CYCLUS_MICRO_VERSION}") ADD_SUBDIRECTORY("${CYCLUS_SHARE_DIR}") ADD_SUBDIRECTORY("${CYCLUS_SOURCE_DIR}") @@ -488,9 +488,9 @@ IF(NOT CYCLUS_DOC_ONLY) SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.rst") # Version - SET(CPACK_PACKAGE_VERSION_MAJOR "1") - SET(CPACK_PACKAGE_VERSION_MINOR "5") - SET(CPACK_PACKAGE_VERSION_PATCH "5") + SET(CPACK_PACKAGE_VERSION_MAJOR ${CYCLUS_MAJOR_VERSION}) + SET(CPACK_PACKAGE_VERSION_MINOR ${CYCLUS_MINOR_VERSION}) + SET(CPACK_PACKAGE_VERSION_PATCH ${CYCLUS_MICRO_VERSION}) # Dependencies SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-all-dev (>= 1.71.0)") diff --git a/setup.py b/setup.py index 9fa131bba4..8e2c288b25 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def replace_in_file(pattern, new, fname): VERSION_UPDATE_PATTERNS = [ - ('__version__\s*=.*', (lambda ver: "__version__ = '{0}'".format(ver)), + ('__version__\s=*', (lambda ver: "__version__ = '{0}'".format(ver)), [PROJECT, '__init__.py']), ] From 1e182277f1ba191cefcb3f50a033fe4876ecc34b Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:21:49 -0500 Subject: [PATCH 3/9] update changelog --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 057933d153..da98a59d27 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -37,6 +37,7 @@ Since last release * Changed Json formatting for compatibility with current python standards (#1587) * Changed README.rst installation instructions, tested on fresh Ubuntu-22.04 system with Python 3.11 (#1617, #1644) * Resolved various compilation warnings due to use of deprecated APIs (#1671) +* Update version management in CMake build (#1696) **Removed:** From cc4c501b1570e3f84b94183cfae744e77ac97063 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:03:10 -0500 Subject: [PATCH 4/9] specify version in CMakeLists.txt, populate to appropriate places in build --- .github/workflows/publish_release.yml | 6 ------ CMakeLists.txt | 22 ++++++---------------- cmake/SetupPyInstall.cmake.in | 4 ++-- cyclus/__init__.py | 2 +- docker/Dockerfile | 5 ++--- install.py | 7 ++----- src/version.h.in | 6 +++--- 7 files changed, 16 insertions(+), 36 deletions(-) diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index f8384c0b73..4800fded31 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -32,14 +32,12 @@ jobs: run: | echo "version_tag=ci-image-cache" >> "$GITHUB_ENV" echo "stable_tag=ci-image-cache" >> "$GITHUB_ENV" - echo "core_version=999.999.999" >> "$GITHUB_ENV" - name: Tag as stable if: ${{ github.repository_owner == 'cyclus' && github.event_name == 'release' }} run: | echo "version_tag=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" echo "stable_tag=stable" >> "$GITHUB_ENV" - echo "core_version=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" - name: Log in to the Container registry uses: docker/login-action@v3 @@ -79,7 +77,6 @@ jobs: build-args: | pkg_mgr=${{ matrix.pkg_mgr }} ubuntu_version=${{ matrix.ubuntu_versions }} - core_version=${{ env.core_version }} - name: Upload .deb to release if: github.event_name == 'release' && matrix.pkg_mgr == 'apt' && matrix.ubuntu_versions == '22.04' @@ -109,14 +106,12 @@ jobs: run: | echo "version_tag=ci-image-cache" >> "$GITHUB_ENV" echo "stable_tag=ci-image-cache" >> "$GITHUB_ENV" - echo "core_version=999.999.999" >> "$GITHUB_ENV" - name: Tag as stable if: ${{ github.repository_owner == 'cyclus' && github.event_name == 'release' }} run: | echo "version_tag=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" echo "stable_tag=stable" >> "$GITHUB_ENV" - echo "core_version=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" - name: Log in to the Container registry uses: docker/login-action@v3 @@ -142,4 +137,3 @@ jobs: ghcr.io/cyclus/cyclus_rocky_${{ matrix.rocky_versions }}/cyclus:${{ env.stable_tag }} build-args: | rocky_version=${{ matrix.rocky_versions }} - core_version=${{ env.core_version }} diff --git a/CMakeLists.txt b/CMakeLists.txt index e271e73916..e8d02c1fcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) ENDIF() # This project name is cyclus. -PROJECT(CYCLUS) +PROJECT(CYCLUS VERSION 1.5.5) # check for and enable c++17 support (required for cyclus) INCLUDE(CheckCXXCompilerFlag) @@ -385,24 +385,14 @@ IF(NOT CYCLUS_DOC_ONLY) # set core version, one way or the other IF(NOT "${CORE_VERSION}" STREQUAL "") SET(core_version "${CORE_VERSION}") - ELSE(NOT "${CORE_VERSION}" STREQUAL "") - EXECUTE_PROCESS(COMMAND git describe --tags - OUTPUT_VARIABLE core_version - OUTPUT_STRIP_TRAILING_WHITESPACE) ENDIF(NOT "${CORE_VERSION}" STREQUAL "") IF("${core_version}" STREQUAL "") - MESSAGE(WARNING "Unable to read current core version, falling back to previous version. Core version will be set to -1") - SET(core_version "-1") + MESSAGE("No core version was specified... using version ${CMAKE_PROJECT_VERSION}") + SET(core_version ${CMAKE_PROJECT_VERSION}) ENDIF() SET(ENV{CYCLUS_CORE_VERSION} "${core_version}") MESSAGE("-- core version ($CYCLUS_CORE_VERSION) set to: ${core_version}") - STRING(REPLACE "." ";" CORE_VERSION_PARTS ${core_version}) - LIST(GET CORE_VERSION_PARTS 0 CYCLUS_MAJOR_VERSION) - LIST(GET CORE_VERSION_PARTS 1 CYCLUS_MINOR_VERSION) - LIST(GET CORE_VERSION_PARTS 2 CYCLUS_MICRO_VERSION) - MESSAGE("-- Major: ${CYCLUS_MAJOR_VERSION}, Minor: ${CYCLUS_MINOR_VERSION}, Micro ${CYCLUS_MICRO_VERSION}") - ADD_SUBDIRECTORY("${CYCLUS_SHARE_DIR}") ADD_SUBDIRECTORY("${CYCLUS_SOURCE_DIR}") ADD_SUBDIRECTORY("${CYCLUS_TEST_DIR}") @@ -488,9 +478,9 @@ IF(NOT CYCLUS_DOC_ONLY) SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.rst") # Version - SET(CPACK_PACKAGE_VERSION_MAJOR ${CYCLUS_MAJOR_VERSION}) - SET(CPACK_PACKAGE_VERSION_MINOR ${CYCLUS_MINOR_VERSION}) - SET(CPACK_PACKAGE_VERSION_PATCH ${CYCLUS_MICRO_VERSION}) + SET(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR}) + SET(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR}) + SET(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH}) # Dependencies SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-all-dev (>= 1.71.0)") diff --git a/cmake/SetupPyInstall.cmake.in b/cmake/SetupPyInstall.cmake.in index b99dda7b01..8d00ecbdde 100644 --- a/cmake/SetupPyInstall.cmake.in +++ b/cmake/SetupPyInstall.cmake.in @@ -2,8 +2,8 @@ # Runs setup.py install # set(PYTHON_EXECUTABLE @Python3_EXECUTABLE@) -set(core_version @core_version@) -set(ENV{CYCLUS_CORE_VERSION} "${core_version}") +set(CYCLUS_CORE_VERSION @CMAKE_PROJECT_VERSION@) +set(ENV{CYCLUS_CORE_VERSION} "${CYCLUS_CORE_VERSION}") message("############### Begin Python Install ###############") message("-- Python installer:") message(" PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") diff --git a/cyclus/__init__.py b/cyclus/__init__.py index df5c8f4ed4..50dc2d7b99 100644 --- a/cyclus/__init__.py +++ b/cyclus/__init__.py @@ -1,2 +1,2 @@ -__version__ = '1.5.5' +__version__ = 'x.x.x' # will be populated during build import pymodule, eventhooks, pyinfile \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 7fdef80187..c3c2c1ee27 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -125,7 +125,7 @@ ARG make_cores=2 COPY . /cyclus WORKDIR /cyclus -RUN python install.py -j ${make_cores} --build-type=Release --core-version 999999.999999 --allow-milps --code_coverage +RUN python install.py -j ${make_cores} --build-type=Release --allow-milps --code_coverage ENV PATH /root/.local/bin:$PATH ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus RUN lcov -c --rc lcov_branch_coverage=1 -d /cyclus -o initial_coverage.info --gcov-tool ${GCOV} --initial --no-external && \ @@ -140,7 +140,6 @@ COPY --from=cyclus-coverage /cyclus / FROM ${pkg_mgr}-deps as cyclus ARG make_cores=2 -ARG core_version=999.999.999 COPY . /cyclus WORKDIR /cyclus @@ -151,7 +150,7 @@ WORKDIR /cyclus # You may add the option "--cmake-debug" to the following command # for further CMake debugging. -RUN python install.py -j ${make_cores} --build-type=Release --core-version ${core_version} --allow-milps +RUN python install.py -j ${make_cores} --build-type=Release --allow-milps ENV PATH /root/.local/bin:$PATH ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus diff --git a/install.py b/install.py index c567fe18c9..6c6c35e2b1 100755 --- a/install.py +++ b/install.py @@ -80,10 +80,7 @@ def install_cyclus(args): if args.build_type: cmake_cmd += ['-DCMAKE_BUILD_TYPE=' + args.build_type] if args.core_version: - core_version = args.core_version - while len(core_version.split('.')) < 3: # add minor/micro version number if missing - core_version += '.0' - cmake_cmd += ['-DCORE_VERSION=' + core_version] + cmake_cmd += ['-DCORE_VERSION=' + args.core_version] if args.D is not None: cmake_cmd += ['-D' + x for x in args.D] if args.cmake_debug: @@ -193,7 +190,7 @@ def main(): build_type = "the CMAKE_BUILD_TYPE" parser.add_argument('--build-type', '--build_type', help=build_type) - parser.add_argument('--core-version', dest='core_version', default=None, required=True, + parser.add_argument('--core-version', dest='core_version', default=None, help='Sets the core version number.') parser.add_argument('-D', metavar='VAR', action='append', diff --git a/src/version.h.in b/src/version.h.in index a9a6eb6ee9..cdf1bfd8bd 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -1,9 +1,9 @@ #ifndef CYCLUS_SRC_VERSION_H_ #define CYCLUS_SRC_VERSION_H_ -#define CYCLUS_VERSION_MAJOR @CYCLUS_MAJOR_VERSION@ -#define CYCLUS_VERSION_MINOR @CYCLUS_MINOR_VERSION@ -#define CYCLUS_VERSION_MICRO @CYCLUS_MICRO_VERSION@ +#define CYCLUS_VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@ +#define CYCLUS_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@ +#define CYCLUS_VERSION_MICRO @CMAKE_PROJECT_VERSION_PATCH@ namespace cyclus { namespace version { From 7f728f119e95c4779507e19e0f010496d20ea774 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:05:45 -0500 Subject: [PATCH 5/9] remove core-version arg in Rocky dockerfile --- docker/Rocky.dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/Rocky.dockerfile b/docker/Rocky.dockerfile index 73c904ba68..8c783b2f27 100644 --- a/docker/Rocky.dockerfile +++ b/docker/Rocky.dockerfile @@ -65,7 +65,6 @@ RUN dnf install -y m4 doxygen perl-open perl-XML-Parser diffutils pcre-cpp pcre- FROM libxmlpp as cyclus ARG make_cores=2 -ARG core_version=999.999.999 COPY . /cyclus WORKDIR /cyclus @@ -76,7 +75,7 @@ WORKDIR /cyclus # You may add the option "--cmake-debug" to the following command # for further CMake debugging. -RUN python install.py -j ${make_cores} --build-type=Release --core-version ${core_version} -D Python3_EXECUTABLE=/usr/bin/python3.11 +RUN python install.py -j ${make_cores} --build-type=Release -D Python3_EXECUTABLE=/usr/bin/python3.11 ENV PATH /root/.local/bin:$PATH ENV LD_LIBRARY_PATH /root/.local/lib:/root/.local/lib/cyclus From 6c33868a1955b20e0ba93858e179cdb19381837e Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:47:22 -0500 Subject: [PATCH 6/9] change core_version to data_model_version --- CMakeLists.txt | 15 +++++++-------- cmake/SetupPyInstall.cmake.in | 6 +++--- cyclus/CMakeLists.txt | 2 +- install.py | 6 +++--- setup.py | 10 +++++----- share/CMakeLists.txt | 2 +- src/version.cc.in | 2 +- 7 files changed, 21 insertions(+), 22 deletions(-) mode change 100755 => 100644 install.py diff --git a/CMakeLists.txt b/CMakeLists.txt index e8d02c1fcd..b1324feca5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -383,15 +383,14 @@ IF(NOT CYCLUS_DOC_ONLY) INCLUDE_DIRECTORIES(AFTER "${Python3_INCLUDE_DIRS}" "${_Python3_NumPy_INCLUDE_DIR}") endif(Cython_FOUND) # set core version, one way or the other - IF(NOT "${CORE_VERSION}" STREQUAL "") - SET(core_version "${CORE_VERSION}") - ENDIF(NOT "${CORE_VERSION}" STREQUAL "") - IF("${core_version}" STREQUAL "") - MESSAGE("No core version was specified... using version ${CMAKE_PROJECT_VERSION}") - SET(core_version ${CMAKE_PROJECT_VERSION}) + IF(NOT "${DATA_MODEL_VERSION}" STREQUAL "") + MESSAGE("-- $DATA_MODEL_VERSION set to: ${DATA_MODEL_VERSION}") + ENDIF(NOT "${DATA_MODEL_VERSION}" STREQUAL "") + IF("${DATA_MODEL_VERSION}" STREQUAL "") + MESSAGE("No data model version was specified... using version ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}") + SET(DATA_MODEL_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}") ENDIF() - SET(ENV{CYCLUS_CORE_VERSION} "${core_version}") - MESSAGE("-- core version ($CYCLUS_CORE_VERSION) set to: ${core_version}") + MESSAGE("-- core version ($CYCLUS_PROJECT_VERSION) set to: ${CMAKE_PROJECT_VERSION}") ADD_SUBDIRECTORY("${CYCLUS_SHARE_DIR}") ADD_SUBDIRECTORY("${CYCLUS_SOURCE_DIR}") diff --git a/cmake/SetupPyInstall.cmake.in b/cmake/SetupPyInstall.cmake.in index 8d00ecbdde..78800d2c6e 100644 --- a/cmake/SetupPyInstall.cmake.in +++ b/cmake/SetupPyInstall.cmake.in @@ -2,12 +2,12 @@ # Runs setup.py install # set(PYTHON_EXECUTABLE @Python3_EXECUTABLE@) -set(CYCLUS_CORE_VERSION @CMAKE_PROJECT_VERSION@) -set(ENV{CYCLUS_CORE_VERSION} "${CYCLUS_CORE_VERSION}") +set(CYCLUS_PROJECT_VERSION @CMAKE_PROJECT_VERSION@) +set(ENV{CYCLUS_PROJECT_VERSION} "${CYCLUS_PROJECT_VERSION}") message("############### Begin Python Install ###############") message("-- Python installer:") message(" PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") -message(" CYCLUS_CORE_VERSION: $ENV{CYCLUS_CORE_VERSION}") +message(" CYCLUS_PROJECT_VERSION: ${CYCLUS_PROJECT_VERSION}") message(" CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") set(CMAKE_CURRENT_BINARY_DIR @CMAKE_CURRENT_BINARY_DIR@) message(" CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") diff --git a/cyclus/CMakeLists.txt b/cyclus/CMakeLists.txt index 6ec27ef90d..494e6d1890 100644 --- a/cyclus/CMakeLists.txt +++ b/cyclus/CMakeLists.txt @@ -10,7 +10,7 @@ INCLUDE_DIRECTORIES(${CYCLUS_CORE_INCLUDE_DIRS}) message(STATUS "Generating Type System API for Python") EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/gentypesystem.py "--src-dir=${CMAKE_CURRENT_SOURCE_DIR}" - "--cyclus-version=${core_version}" + "--cyclus-version=${DATA_MODEL_VERSION}" "--verbose" RESULT_VARIABLE res_var) IF(NOT "${res_var}" STREQUAL "0") diff --git a/install.py b/install.py old mode 100755 new mode 100644 index 6c6c35e2b1..1547d55c46 --- a/install.py +++ b/install.py @@ -79,8 +79,8 @@ def install_cyclus(args): ] if args.build_type: cmake_cmd += ['-DCMAKE_BUILD_TYPE=' + args.build_type] - if args.core_version: - cmake_cmd += ['-DCORE_VERSION=' + args.core_version] + if args.data_model_version: + cmake_cmd += ['-DDATA_MODEL_VERSION=' + args.data_model_version] if args.D is not None: cmake_cmd += ['-D' + x for x in args.D] if args.cmake_debug: @@ -190,7 +190,7 @@ def main(): build_type = "the CMAKE_BUILD_TYPE" parser.add_argument('--build-type', '--build_type', help=build_type) - parser.add_argument('--core-version', dest='core_version', default=None, + parser.add_argument('--data-model-version', dest='data_model_version', default=None, help='Sets the core version number.') parser.add_argument('-D', metavar='VAR', action='append', diff --git a/setup.py b/setup.py index 8e2c288b25..32cd3de4ad 100644 --- a/setup.py +++ b/setup.py @@ -72,14 +72,14 @@ def run_setup(ver): def main(argv=None): """The main installer for cyclus Python bindings.""" - core_version = os.environ.get('CYCLUS_CORE_VERSION', '') - if not core_version: - msg = "$CYCLUS_CORE_VERSION not set, this is needed to install cyclus. " + cyclus_version = os.environ.get('CYCLUS_PROJECT_VERSION', '') + if not cyclus_version: + msg = "$CYCLUS_PROJECT_VERSION not set, this is needed to install cyclus. " msg += "Normally this is set by the CMake build system, and you should " msg += "not be running setup.py directly." raise RuntimeError(msg) - version_update(core_version) - run_setup(core_version) + version_update(cyclus_version) + run_setup(cyclus_version) if __name__ == '__main__': diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index b06771be5e..9902efa71b 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -20,7 +20,7 @@ CONFIGURE_FILE( COPYONLY ) -EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/dbtypes_gen.py ${core_version} OUTPUT_VARIABLE DBTYPES_JSON_ENTRIES RESULT_VARIABLE res_var) +EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/dbtypes_gen.py ${DATA_MODEL_VERSION} OUTPUT_VARIABLE DBTYPES_JSON_ENTRIES RESULT_VARIABLE res_var) IF(NOT "${res_var}" STREQUAL "0") message(FATAL_ERROR "Process dbtypes_gen.py failed, res_var = '${res_var}'") ENDIF() diff --git a/src/version.cc.in b/src/version.cc.in index b025f5f52f..8f4a0bc359 100644 --- a/src/version.cc.in +++ b/src/version.cc.in @@ -32,7 +32,7 @@ namespace version { static char h5version[15]; const char* describe() { - return "@core_version@"; + return "@DATA_MODEL_VERSION@"; } const char* core() { From d8c2d0fb749102aa731380dc8675c3d3d07252d1 Mon Sep 17 00:00:00 2001 From: Ben Nibbelink Date: Thu, 21 Mar 2024 12:50:21 -0500 Subject: [PATCH 7/9] setup cyclus lib in tets --- tests/test_cycluslib.py | 5 +---- tests/tools.py | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_cycluslib.py b/tests/test_cycluslib.py index 12860b9a6f..dec24c2711 100644 --- a/tests/test_cycluslib.py +++ b/tests/test_cycluslib.py @@ -5,10 +5,7 @@ from cyclus import lib -from tools import libcyclus_setup, dbtest - - -setup = libcyclus_setup +from tools import dbtest @dbtest def test_name(db, fname, backend): diff --git a/tests/tools.py b/tests/tools.py index a3be48eefa..628ec2884d 100644 --- a/tests/tools.py +++ b/tests/tools.py @@ -167,6 +167,7 @@ def libcyclus_setup(): def dbtest(f): + libcyclus_setup() def wrapper(): for fname, oname, backend in DBS: if os.path.exists(fname): From e99347a69eb6f25563aea3733b7a553636f2dd34 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Thu, 21 Mar 2024 13:54:09 -0500 Subject: [PATCH 8/9] Change "core version" to "Cyclus version" Co-authored-by: Paul Wilson Signed-off-by: bennibbelink <79653949+bennibbelink@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1324feca5..d974fde905 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -390,7 +390,7 @@ IF(NOT CYCLUS_DOC_ONLY) MESSAGE("No data model version was specified... using version ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}") SET(DATA_MODEL_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}") ENDIF() - MESSAGE("-- core version ($CYCLUS_PROJECT_VERSION) set to: ${CMAKE_PROJECT_VERSION}") + MESSAGE("-- Cyclus version ($CYCLUS_PROJECT_VERSION) set to: ${CMAKE_PROJECT_VERSION}") ADD_SUBDIRECTORY("${CYCLUS_SHARE_DIR}") ADD_SUBDIRECTORY("${CYCLUS_SOURCE_DIR}") From 47a646c7a91152c4f0a358aa3d9e7d78168fdc6b Mon Sep 17 00:00:00 2001 From: Ben Nibbelink Date: Thu, 21 Mar 2024 13:56:35 -0500 Subject: [PATCH 9/9] change gentypesystem arg to --data-model-version --- cyclus/CMakeLists.txt | 2 +- cyclus/gentypesystem.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cyclus/CMakeLists.txt b/cyclus/CMakeLists.txt index 494e6d1890..4177e08b42 100644 --- a/cyclus/CMakeLists.txt +++ b/cyclus/CMakeLists.txt @@ -10,7 +10,7 @@ INCLUDE_DIRECTORIES(${CYCLUS_CORE_INCLUDE_DIRS}) message(STATUS "Generating Type System API for Python") EXECUTE_PROCESS(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/gentypesystem.py "--src-dir=${CMAKE_CURRENT_SOURCE_DIR}" - "--cyclus-version=${DATA_MODEL_VERSION}" + "--data-model-version=${DATA_MODEL_VERSION}" "--verbose" RESULT_VARIABLE res_var) IF(NOT "${res_var}" STREQUAL "0") diff --git a/cyclus/gentypesystem.py b/cyclus/gentypesystem.py index 6bd63a0dc2..fab269e931 100644 --- a/cyclus/gentypesystem.py +++ b/cyclus/gentypesystem.py @@ -2779,8 +2779,8 @@ def parse_args(argv): dest='dbtypes_json', help="the path to dbtypes.json file, " "default " + dbtd) - parser.add_argument('--cyclus-version', default=None, - dest='cyclus_version', + parser.add_argument('--data-model-version', default=None, + dest='data_model_version', help="The Cyclus API version to target." ) ns = parser.parse_args(argv) @@ -2802,7 +2802,7 @@ def setup(ns): with io.open(ns.dbtypes_json, 'r') as f: tab = json.load(f) # get cyclus version - verstr = ns.cyclus_version + verstr = ns.data_model_version if verstr is None: try: verstr = safe_output(['cyclus', '--version']).split()[2] @@ -2817,7 +2817,7 @@ def setup(ns): if verstr is not None: if isinstance(verstr, bytes): verstr = verstr.decode() - ns.cyclus_version = verstr + ns.data_model_version = verstr ver = tuple(map(int, verstr.partition('-')[0].split('.'))) if ns.verbose: print('Found cyclus version: ' + verstr, file=sys.stderr)