Skip to content

Commit

Permalink
fix conda version
Browse files Browse the repository at this point in the history
- work-around for pypa/setuptools-scm#1059
  • Loading branch information
casperdcl committed Jul 26, 2024
1 parent c40da91 commit 8477619
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 40 deletions.
9 changes: 5 additions & 4 deletions Wrappers/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 5 additions & 18 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -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

Expand Down
22 changes: 5 additions & 17 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 8477619

Please sign in to comment.