Skip to content

Commit

Permalink
Merge pull request #1696 from cyclus/version-update
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke committed Mar 21, 2024
2 parents 08a8cd3 + 47a646c commit 68ef954
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 47 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["cyclus*.deb"]'

build-and-test-rocky-release:
runs-on: ubuntu-latest
permissions:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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:**

Expand Down
29 changes: 12 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -383,19 +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}")
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")
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("-- Cyclus version ($CYCLUS_PROJECT_VERSION) set to: ${CMAKE_PROJECT_VERSION}")

ADD_SUBDIRECTORY("${CYCLUS_SHARE_DIR}")
ADD_SUBDIRECTORY("${CYCLUS_SOURCE_DIR}")
Expand Down Expand Up @@ -482,9 +477,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 ${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)")
Expand Down
6 changes: 3 additions & 3 deletions cmake/SetupPyInstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Runs setup.py install
#
set(PYTHON_EXECUTABLE @Python3_EXECUTABLE@)
set(core_version @core_version@)
set(ENV{CYCLUS_CORE_VERSION} "${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}")
Expand Down
2 changes: 1 addition & 1 deletion cyclus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
"--data-model-version=${DATA_MODEL_VERSION}"
"--verbose"
RESULT_VARIABLE res_var)
IF(NOT "${res_var}" STREQUAL "0")
Expand Down
2 changes: 1 addition & 1 deletion cyclus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.5.5'
__version__ = 'x.x.x' # will be populated during build
import pymodule, eventhooks, pyinfile
8 changes: 4 additions & 4 deletions cyclus/gentypesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -150,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 999999.999999 --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

Expand Down
2 changes: 1 addition & 1 deletion docker/Rocky.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,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 999999.999999 -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

Expand Down
6 changes: 3 additions & 3 deletions install.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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',
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
]

Expand Down Expand Up @@ -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__':
Expand Down
2 changes: 1 addition & 1 deletion share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion src/version.cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace version {
static char h5version[15];

const char* describe() {
return "@core_version@";
return "@DATA_MODEL_VERSION@";
}

const char* core() {
Expand Down
6 changes: 3 additions & 3 deletions src/version.h → src/version.h.in
Original file line number Diff line number Diff line change
@@ -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 @CMAKE_PROJECT_VERSION_MAJOR@
#define CYCLUS_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@
#define CYCLUS_VERSION_MICRO @CMAKE_PROJECT_VERSION_PATCH@

namespace cyclus {
namespace version {
Expand Down
5 changes: 1 addition & 4 deletions tests/test_cycluslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 68ef954

Please sign in to comment.