Skip to content

Commit

Permalink
Merge pull request #302 from ecmwf-ifs/nabr-setuptools-scm-without-git
Browse files Browse the repository at this point in the history
Fix installation without git checkout
  • Loading branch information
reuterbal authored Apr 30, 2024
2 parents 5673795 + 355471b commit 0e011a0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ if( NOT HAVE_NO_INSTALL )

endif()

# Determine whether this is a Git worktree or if we have to provide
# the version number to setuptools_scm
if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git )
set( ENV{SETUPTOOLS_SCM_PRETEND_VERSION} ${loki_VERSION} )
endif()

# Install Loki python package with dependencies
if( NOT ${CMAKE_VERBOSE_MAKEFILE} )
# Less verbose output
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.6
0.2.2
3 changes: 3 additions & 0 deletions cmake/python_venv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ function( find_python_venv VENV_PATH )
# Unset Python3_EXECUTABLE because it is also an input variable
# (see documentation, Artifacts Specification section)
unset( Python3_EXECUTABLE )
# To allow cmake to discover the newly created venv if Python3_ROOT_DIR
# was passed as an argument at build-time
set( Python3_ROOT_DIR "${VENV_PATH}" )

# Launch a new search
find_package( Python3 COMPONENTS Interpreter Development REQUIRED )
Expand Down
6 changes: 6 additions & 0 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ else
pip_opts=[${pip_opts:1}]
fi

# Supply pretend version if not a git worktree
if [ ! -e .git ]; then
export "SETUPTOOLS_SCM_PRETEND_VERSION=$(cat VERSION)"
fi


pip install $PIPPROXYOPTIONS --upgrade pip
pip install $PIPPROXYOPTIONS -e .$pip_opts # Installs Loki dev copy in editable mode
pip install $PIPPROXYOPTIONS -e ./transformations
Expand Down

0 comments on commit 0e011a0

Please sign in to comment.