Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version string #860

Merged
merged 10 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ $RECYCLE.BIN/
\#*
.#*


# files generated by CMake
Wrappers/Python/setup.py
Wrappers/Python/cil/version.py
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* 21.x.x
- add version string from git describe
- add CCPi-Regularisation toolkit in unittests
- show_geometry implemented to display AcquisitionGeometry objects, can be imported from utilities.display

Expand Down
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ endif(APPLE)

set(CMAKE_BUILD_TYPE "Release")

set(CIL_VERSION $ENV{CIL_VERSION})

# CIL version TAG is determined by git describe as for the conda package
# variable GIT_DESCRIBE_TAG
# https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#templating-with-jinja
# https://stackoverflow.com/questions/38919840/get-package-version-for-conda-meta-yaml-from-source-file


execute_process(COMMAND git describe
RESULT_VARIABLE worked
OUTPUT_VARIABLE CIL_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT worked EQUAL 0)
message(FATAL_ERROR "git describe returned ${worked}")
endif()

add_subdirectory(src/Core)
add_subdirectory(Wrappers/Python)
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
import sys


cil_version=os.environ['CIL_VERSION']
if cil_version == '':
print("Please set the environmental variable CIL_VERSION")
sys.exit(1)
cil_version='@CIL_VERSION@'

setup(
name="cil",
Expand All @@ -45,7 +42,7 @@
author="CCPi developers",
maintainer="Edoardo Pasca",
maintainer_email="edoardo.pasca@stfc.ac.uk",
description='CCPi Core Imaging Library - Python Framework Module',
description='CCPi Core Imaging Library',
license="Apache v2.0",
keywords="Python Framework",
url="http://www.ccpi.ac.uk/cil",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions Wrappers/Python/CMake/version.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = '@CIL_VERSION@'
37 changes: 23 additions & 14 deletions Wrappers/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (BUILD_PYTHON_WRAPPER)
set(PYTHON_DEST "${PYTHON_DEST_DIR}")
else()
message(STATUS "python version ${PYTHON_DEST}")
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/sp_dir.py
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/CMake/sp_dir.py
OUTPUT_VARIABLE SP_DIR)
# remove trailing newline
string(REGEX REPLACE "\n$" "" PYTHON_DEST ${SP_DIR})
Expand Down Expand Up @@ -37,38 +37,47 @@ if (BUILD_PYTHON_WRAPPER)
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/timestamp")
file(GLOB_RECURSE DEPS ${CMAKE_CURRENT_SOURCE_DIR}/cil/*.py )

# adds the CIL_VERSION to the setup.py
if (EXISTS ${SETUP_PY})
file(REMOVE ${SETUP_PY})
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/setup.py.in ${SETUP_PY})
# adds the version.py file to the source code with correct version string.
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cil/version.py)
file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/cil/version.py)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/version.py.in ${CMAKE_CURRENT_SOURCE_DIR}/cil/version.py)



# add to add_custom_command DEPENDS the list of python files of the project.
# as a hack I remove ${OUTPUT}. This should trigger the new build.
file( REMOVE ${OUTPUT} )


if (CONDA_BUILD)
add_custom_target(pythonsetup ALL
COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION}
${PYTHON_EXECUTABLE} ${SETUP_PY} -vv install

COMMAND ${CMAKE_COMMAND} -E ${PYTHON_EXECUTABLE} ${SETUP_PY} -vv install
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
DEPENDS cilacc)

else()
if (WIN32)
add_custom_target(pythonsetup ALL
COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION}
PREFIX=${CMAKE_SOURCE_DIR}/src/
LIBRARY_INC=${CMAKE_SOURCE_DIR}/src/include
LIBRARY_LIB=${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}
${PYTHON_EXECUTABLE} ${SETUP_PY} build_py
COMMAND ${CMAKE_COMMAND} -E env PREFIX=${CMAKE_SOURCE_DIR}/src/
LIBRARY_INC=${CMAKE_SOURCE_DIR}/src/include
LIBRARY_LIB=${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}
${PYTHON_EXECUTABLE} ${SETUP_PY} build_py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
DEPENDS cilacc)
else()
add_custom_target(pythonsetup ALL
COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION}
PREFIX=${CMAKE_SOURCE_DIR}/src/
LIBRARY_INC=${CMAKE_SOURCE_DIR}/src/include
LIBRARY_LIB=${CMAKE_BINARY_DIR}/
${PYTHON_EXECUTABLE} ${SETUP_PY} build_py --verbose --build-lib=${CMAKE_CURRENT_BINARY_DIR}/build/lib
COMMAND ${CMAKE_COMMAND} -E env PREFIX=${CMAKE_SOURCE_DIR}/src/
LIBRARY_INC=${CMAKE_SOURCE_DIR}/src/include
LIBRARY_LIB=${CMAKE_BINARY_DIR}/
${PYTHON_EXECUTABLE} ${SETUP_PY} build_py --verbose --build-lib=${CMAKE_CURRENT_BINARY_DIR}/build/lib
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}

COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
Expand Down
3 changes: 2 additions & 1 deletion recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ else
-DCMAKE_INSTALL_PREFIX=$PREFIX

fi
make install VERBOSE=1

cmake --build . --target install
14 changes: 6 additions & 8 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package:
name: cil
version: {{ environ['CIL_VERSION'] }}
version: {{ GIT_DESCRIBE_TAG }}

build:
skip: True # [py==38 and np==115]
preserve_egg_dir: False
script_env:
- CIL_VERSION
#number: 0
missing_dso_whitelist:
- /lib64/libc.so.6 # [linux]
Expand All @@ -18,11 +16,11 @@ test:
requires:
- {{ pin_compatible('numpy', min_pin='x.x', max_pin='x.x') }}
- python-wget
- cvxpy # [ unix and py36 and np115 ]
- scikit-image
- tomophantom # [ linux ]
- cil-astra # [ linux ]
- tigre # [ linux ]
- cvxpy # [ unix and py36 and np115 ]
- scikit-image
- tomophantom # [ linux ]
- cil-astra # [ linux ]
- tigre # [ linux ]
- numba
- packaging
- ccpi-regulariser
Expand Down