diff --git a/CMakeLists.txt b/CMakeLists.txt index 4067b1de..edafb052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,9 +167,9 @@ endif(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.17) # 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 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}/cmake/Spt3gConfigVersion.cmake + BYPRODUCTS ${CMAKE_BINARY_DIR}/spt3g/version.py ${CMAKE_BINARY_DIR}/pyproject.toml ${CMAKE_BINARY_DIR}/cmake/Spt3gConfigVersion.cmake COMMENT "Regenerating VCS version information" ) diff --git a/cmake/getvers.sh b/cmake/getvers.sh index e161caad..937f4214 100755 --- a/cmake/getvers.sh +++ b/cmake/getvers.sh @@ -1,12 +1,22 @@ #!/bin/sh -# Usage: getvers.sh +# Usage: getvers.sh 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 @@ -119,14 +129,14 @@ elif [ -d .git ]; then echo localdiffs=False fi echo versionname=\"$(git tag -l --points-at HEAD 2>/dev/null)\" - echo fullversion=\"$(git describe --always --tags --dirty 2>/dev/null)\" + echo fullversion=\"$fullversion_pep440\" else echo upstream_url=\"UNKNOWN VCS\" echo upstream_branch=\"UNKNOWN VCS\" 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 diff --git a/cmake/pyproject.toml.in b/cmake/pyproject.toml.in new file mode 100644 index 00000000..b9268b9e --- /dev/null +++ b/cmake/pyproject.toml.in @@ -0,0 +1,17 @@ +[tool.poetry] +name = "spt3g" +version = "$Version$" +description = "SPT3G Analysis and DAQ Software" +authors = ["SPT Collaboration"] + +[tool.poetry.dependencies] +python = "^3.7" +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" diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 8fc464a4..13a1c07e 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -83,12 +83,14 @@ Passing ``-jN`` to ``make``, where N is the number of cores you wish to use duri By default, this will use the system's standard Python installation (whatever you get if you just run ``python``). If you want a different python, you can specify that python through passing the argument ``-DPYTHON_EXECUTABLE=`` to cmake. For example, to use Python 3 if Python 3 is not the default, replace the cmake command above with ``cmake -DPYTHON_EXECUTABLE=`which python3```. Note that, if you do this, make *sure* that a Boost library built for the version of Python you are using exists -- generally, installing everything from the system package manager will ensure this. -Once that is complete, you can use the ``env-shell.sh`` script in the build directory to set up the appropriate environment variables (PYTHONPATH, etc.): +Once that is complete, you can either use the ``env-shell.sh`` script in the build directory to set up the appropriate environment variables (PYTHONPATH, etc.): .. code-block:: sh ./env-shell.sh +or you can ``pip install -e /path/to/spt3g_software/build`` (needs pip>=22) or ``poetry add -e /path/to/spt3g_software/build`` to partially install spt3g_software and all of its Python dependencies in "editable mode" into whatever Python environment you'd like. In either case 1) the ``build`` directory should be kept around, since the installation will read directly from this folder, and 2) the version of Python in the environment you are using should be the same as the one used to build spt3g_software. Note that this method does not install the headers and compiled binaries for use by downstream projects; the installation instructions below provide a more complete method for this. + Installation ============