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

Partial installation with poetry/pip #97

Merged
merged 12 commits into from
Aug 16, 2023
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ configure_file(${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake.in ${CMAKE_BINARY_DIR

# Target for version string
add_custom_target(version ALL
COMMAND sh ${CMAKE_SOURCE_DIR}/cmake/getvers.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/spt3g/version.py
COMMAND cmake -P ${CMAKE_SOURCE_DIR}/cmake/Spt3gVersion.cmake ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
BYPRODUCTS ${CMAKE_BINARY_DIR}/spt3g/version.py ${CMAKE_BINARY_DIR}/cmake/Spt3gConfigVersion.cmake
COMMAND sh ${CMAKE_SOURCE_DIR}/cmake/getvers.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/Spt3gVersion.cmake ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
BYPRODUCTS ${CMAKE_BINARY_DIR}/spt3g/version.py ${CMAKE_BINARY_DIR}/pyproject.toml ${CMAKE_BINARY_DIR}/cmake/Spt3gConfigVersion.cmake
COMMENT "Regenerating VCS version information"
)

Expand Down
11 changes: 9 additions & 2 deletions cmake/Spt3gBoostPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ else()
endif()

# suppress configuration warnings in newer cmake / boost versions
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
if (NOT DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
endif()

if(NOT DEFINED Boost_PYTHON_TYPE)
set(Boost_PYTHON_TYPE python)
Expand All @@ -65,4 +67,9 @@ if(NOT DEFINED Boost_PYTHON_TYPE)
endif()
endif()

find_package(Boost COMPONENTS system iostreams filesystem ${Boost_PYTHON_TYPE} REQUIRED)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
find_package(Boost REQUIRED COMPONENTS system iostreams filesystem ${Boost_PYTHON_TYPE} OPTIONAL_COMPONENTS bzip2)
else(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
find_package(Boost COMPONENTS system iostreams filesystem ${Boost_PYTHON_TYPE} REQUIRED)
set(Boost_BZIP2_FOUND TRUE)
endif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
18 changes: 14 additions & 4 deletions cmake/getvers.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#!/bin/sh

# Usage: getvers.sh <tree to get version info from> <output file>
# Usage: getvers.sh <tree to get version info from> <build directory>

set -e
cd $1

exec 1>$2
# PEP440-compliant version number for pyproject.toml
if [ -d .git ]; then
# replaces first - with .dev and second - with +, so e.g. 0.3-154-gd36baf4a becomes 0.3.dev154+gd36baf4a
fullversion_pep440=$(echo $(git describe --always --tags 2>/dev/null) | sed 's/-/.dev/' | sed 's/-/+/')
fi
fullversion_pep440="${fullversion_pep440:-0.1.0+unknown}" # fallback for SVN or error above
sed "s/\\\$Version\\\$/$fullversion_pep440/" $1/cmake/pyproject.toml.in > $2/pyproject.toml


# version.py version info
exec 1>"$2/spt3g/version.py"

cd $1

echo '# AUTO-GENERATED FILE: DO NOT EDIT'
echo
Expand Down Expand Up @@ -126,7 +136,7 @@ else
echo revision=\"UNKNOWN VCS\"
echo gitrevision=\"UNKNOWN\"
echo versionname=\"UNKNOWN\"
if [ "$(cat VERSION)" == "\$Version\$" ]; then
if [ "$(cat VERSION)" = '$Version$' ]; then
echo localdiffs=True
echo fullversion=\"UNKNOWN\"
else
Expand Down
17 changes: 17 additions & 0 deletions cmake/pyproject.toml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.poetry]
name = "spt3g"
version = "$Version$"
description = "SPT3G Analysis and DAQ Software"
authors = ["SPT Collaboration"]

[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.15"
astropy = "^5"
scipy = "^1.4.1"
pandas = "^1"
healpy = "^1.13"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
4 changes: 4 additions & 0 deletions core/src/dataio.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ g3_istream_from_path(boost::iostreams::filtering_istream &stream,
if (boost::algorithm::ends_with(path, ".gz"))
stream.push(boost::iostreams::gzip_decompressor());
if (boost::algorithm::ends_with(path, ".bz2"))
#ifdef Boost_BZIP2_FOUND
stream.push(boost::iostreams::bzip2_decompressor());
#else
log_fatal("Boost not compiled with bzip2 support.");
#endif

int fd = -1;

Expand Down
3 changes: 3 additions & 0 deletions dfmux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ add_spt3g_library(dfmux SHARED
${DFMUX_LIB_EXTRA_SRC}
)
target_link_libraries(dfmux core ${DFMUX_LIB_EXTRA_LIB})
if (NETCDF_FOUND)
target_include_directories(dfmux PRIVATE ${NETCDF_INCLUDES})
endif()

if (NETCDF_FOUND)
add_spt3g_program(bin/ledgerman.py ledgerman)
Expand Down