From 84776198a053e7bb8d4c987de38756ba3cdb08d4 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 22 Jul 2024 19:38:47 +0100 Subject: [PATCH] fix conda version - work-around for https://github.com/pypa/setuptools_scm/issues/1059 --- Wrappers/Python/CMakeLists.txt | 9 +++++---- pyproject.toml | 5 +++++ recipe/bld.bat | 23 +++++------------------ recipe/build.sh | 22 +++++----------------- recipe/meta.yaml | 2 +- 5 files changed, 21 insertions(+), 40 deletions(-) diff --git a/Wrappers/Python/CMakeLists.txt b/Wrappers/Python/CMakeLists.txt index 7b6e064b3a..213709e4b4 100644 --- a/Wrappers/Python/CMakeLists.txt +++ b/Wrappers/Python/CMakeLists.txt @@ -63,10 +63,11 @@ if (BUILD_PYTHON_WRAPPER) file( REMOVE ${OUTPUT} ) add_custom_target(pythonsetup ALL - COMMAND ${CMAKE_COMMAND} -E env ${PYTHON_EXECUTABLE} -m pip install . -t ${PYTHON_DEST} --upgrade - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} - DEPENDS cilacc) + COMMAND ${CMAKE_COMMAND} -E env "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL=$ENV{SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL}" + ${PYTHON_EXECUTABLE} -m pip install . -t ${PYTHON_DEST} --upgrade + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilacc) # install the data if not a conda build. With conda the data is in the dependency package cil-data if (NOT CONDA_BUILD) diff --git a/pyproject.toml b/pyproject.toml index c0cf5502d4..5daa8ddbd8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,11 @@ minor = {version_tuple[1]} patch = {version_tuple[2]} commit_hash = '{scm_version.node}' num_commit = {scm_version.distance} +# work-around for https://github.com/pypa/setuptools_scm/issues/1059 +if (commit_hash, num_commit) == ('None', 0): + import re + if (_v := re.search(r'\\.dev(\\d+)\\+(\\w+)', version)): + num_commit, commit_hash = int(_v.group(1)), _v.group(2) """ [tool.setuptools] diff --git a/recipe/bld.bat b/recipe/bld.bat index b4f0b6d6d6..12dc7aa372 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -1,23 +1,10 @@ -REM Copyright 2019 United Kingdom Research and Innovation -REM Copyright 2019 The University of Manchester - -REM Licensed under the Apache License, Version 2.0 (the "License"); -REM you may not use this file except in compliance with the License. -REM You may obtain a copy of the License at - -REM http://www.apache.org/licenses/LICENSE-2.0 - -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. - -REM Authors: -REM CIL Developers, listed at: https://github.com/TomographicImaging/CIL/blob/master/NOTICE.txt - ROBOCOPY /E "%RECIPE_DIR%\.." "%SRC_DIR%" /XD .git /XD Wrappers\Python\build +set SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL="%PKG_VERSION%" +if not "%GIT_DESCRIBE_NUMBER%"=="0" ( + set SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL="%PKG_VERSION%.dev%GIT_DESCRIBE_NUMBER%+%GIT_DESCRIBE_HASH%" +) + cmake -S "%RECIPE_DIR%\.." -B "%SRC_DIR%\build_framework" -G "NMake Makefiles" -DCONDA_BUILD=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBRARY_LIB=%CONDA_PREFIX%\lib -DLIBRARY_INC=%CONDA_PREFIX% -DCMAKE_INSTALL_PREFIX=%PREFIX% if errorlevel 1 exit 1 diff --git a/recipe/build.sh b/recipe/build.sh index 836f4a4d1a..6795d42fd4 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -1,19 +1,4 @@ #!/usr/bin/env bash - -# Copyright 2019 United Kingdom Research and Innovation -# Copyright 2019 The University of Manchester -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Authors: -# CIL Developers, listed at: https://github.com/TomographicImaging/CIL/blob/master/NOTICE.txt - set -euxo pipefail if test $(python -c "from __future__ import print_function; import platform; print(platform.system())") = Darwin ; then @@ -24,11 +9,14 @@ else extra_args="" fi +export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL="${PKG_VERSION}" +if test "${GIT_DESCRIBE_NUMBER}" != "0"; then + export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CIL="${PKG_VERSION}.dev${GIT_DESCRIBE_NUMBER}+${GIT_DESCRIBE_HASH}" +fi cmake ${RECIPE_DIR}/../ $extra_args \ -DCONDA_BUILD=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DLIBRARY_LIB=$CONDA_PREFIX/lib \ -DLIBRARY_INC=$CONDA_PREFIX/include \ - -DCMAKE_INSTALL_PREFIX=$PREFIX \ - + -DCMAKE_INSTALL_PREFIX=$PREFIX cmake --build . --target install diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 1f35a41a9c..16d4850622 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -97,6 +97,6 @@ requirements: - ipywidgets about: - home: http://www.ccpi.ac.uk/cil + home: https://ccpi.ac.uk/cil license: Apache 2.0 License summary: 'CCPi Core Imaging Library'