Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .bumpversion.toml

This file was deleted.

15 changes: 12 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies = [

description = 'Python bindings for Atlas: a ECMWF library for parallel data-structures'
name = 'atlas4py'
version = '0.41.1.dev1'
version = '0.41.1.dev2' # <major>.<minor>.<patch>.dev<dev> : <atlas.major>.<atlas.minor>.<atlas.patch>.dev<atlas4py.dev>
license = {text = "Apache License 2.0"}
readme = {file = 'README.md', content-type = 'text/markdown'}
authors = [{email = '[email protected]'}, {name = 'Willem Deconinck'}]
Expand All @@ -41,15 +41,15 @@ test = ['pytest', 'pytest-cache']

[tool.scikit-build]
minimum-version = '0.5'
build-dir="build/{wheel_tag}"
cmake.minimum-version = '3.25'
cmake.verbose = true
cmake.source-dir = "src/atlas4py"
cmake.build-type = "Release"
cmake.args = [
"-DATLAS4PY_ECBUILD_VERSION=3.9.1",
"-DATLAS4PY_ECKIT_VERSION=1.28.6",
"-DATLAS4PY_ATLAS_VERSION=0.41.1",
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=build",
"-DATLAS4PY_ATLAS_VERSION=0.41.1"
]
wheel.expand-macos-universal-tags = true
wheel.install-dir = "atlas4py"
Expand All @@ -75,3 +75,12 @@ exclude = '''
| dist
)/
'''

[tool.bumpversion]
# To update atlas4py dev version:
# pip install bump-my-version
# bump-my-version bump dev
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\.dev(?P<dev>\\d+))?"
serialize = ["{major}.{minor}.{patch}.dev{dev}"]
[[tool.bumpversion.files]]
filename = "pyproject.toml"
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
black>=21.12b0
bump2version>=1.0
bump-my-version>=1.2.6
numpy>=1.17
pytest>=6.1
tox>=4.0
Expand Down
146 changes: 128 additions & 18 deletions src/atlas4py/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,64 +1,174 @@
cmake_minimum_required(VERSION 3.25.0)

project(atlas4py LANGUAGES CXX)
if (NOT SKBUILD)
set (PROJECT_ROOT_DIR "../..")
cmake_path(ABSOLUTE_PATH PROJECT_ROOT_DIR BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} NORMALIZE OUTPUT_VARIABLE PROJECT_ROOT_DIR)

message(FATAL_ERROR "\

This CMake file is meant to be executed using 'scikit-build'. Running
it directly will almost certainly not produce the desired result. If
you are a user trying to install this package, please use the command
below, which will install all necessary build dependencies, compile
the package in an isolated environment, and then install it.
=====================================================================
$ pip install ${PROJECT_ROOT_DIR}
=====================================================================
For development purposes, it is usually much more efficient to
install the build dependencies in your environment once and use the
following command that avoids a costly creation of a new virtual
environment at every compilation:
=====================================================================
$ pip install pybind11 scikit-build-core
$ pip install --no-build-isolation -ve ${PROJECT_ROOT_DIR}
=====================================================================
You may optionally add -Ceditable.rebuild=true to auto-rebuild when
the package is imported. Otherwise, you need to re-run the above
after editing C++ files.")
endif()

set( PROJECT_NAME ${SKBUILD_PROJECT_NAME} )
set( PROJECT_VERSION ${SKBUILD_PROJECT_VERSION} )
set( PROJECT_VERSION_FULL ${SKBUILD_PROJECT_VERSION_FULL} )
string( REPLACE "${PROJECT_VERSION}.dev" "" PROJECT_VERSION_DEV "${PROJECT_VERSION_FULL}" )

message( STATUS "[${PROJECT_NAME}] (${PROJECT_VERSION_FULL})" )
project(${PROJECT_NAME} LANGUAGES CXX VERSION ${PROJECT_VERSION})

# Policies
cmake_policy(SET CMP0074 NEW)
if (POLICY CMP0148)
cmake_policy(SET CMP0148 NEW)
endif()
if (POLICY CMP0168)
cmake_policy(SET CMP0168 NEW)
endif()

set(CMAKE_CXX_STANDARD 17)

include(FetchContent)

find_package(atlas QUIET PATHS $ENV{ATLAS_INSTALL_DIR})
if( atlas_FOUND )
message( "Found atlas: ${atlas_DIR} (found version \"${atlas_VERSION}\")" )
if (NOT build_atlas)
if (DEFINED ENV{ATLAS_INSTALL_DIR})
set( atlas_ROOT ${ENV{ATLAS_INSTALL_DIR}} )
endif()
find_package(atlas CONFIG QUIET)
if( atlas_FOUND )
message( STATUS "Found atlas: ${atlas_DIR} (found version \"${atlas_VERSION}\")" )
message( STATUS "Found eckit: ${eckit_DIR} (found version \"${eckit_VERSION}\")" )
if (NOT atlas_VERSION VERSION_EQUAL ATLAS4PY_ATLAS_VERSION)
message( WARNING "Found atlas version \"${atlas_VERSION}\", but configured version is \"${ATLAS4PY_ATLAS_VERSION}\"" )
endif()
if (NOT eckit_VERSION VERSION_EQUAL ATLAS4PY_ECKIT_VERSION)
message( WARNING "Found eckit version \"${eckit_VERSION}\", but configured version is \"${ATLAS4PY_ECKIT_VERSION}\"" )
endif()
else()
set(build_atlas TRUE CACHE INTERNAL "build atlas")
endif()
endif()

if(NOT atlas_FOUND)
find_package(ecbuild)
if(NOT ecbuild_FOUND)
FetchContent_Declare(
if(build_atlas)
if (NOT build_ecbuild)
find_package(ecbuild CONFIG QUIET)
if (ecbuild_FOUND)
message( STATUS "Found ecbuild: ${ecbuild_DIR} (found version \"${ecbuild_VERSION}\")" )
if (NOT ecbuild_VERSION VERSION_EQUAL ATLAS4PY_ECBUILD_VERSION)
message( WARNING "Found ecbuild version \"${ecbuild_VERSION}\", but configured version is \"${ATLAS4PY_ECBUILD_VERSION}\"" )
endif()
else()
set(build_ecbuild TRUE CACHE INTERNAL "build ecbuild")
endif()
endif()
if (build_ecbuild)
set ( ecbuild_SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/ecbuild )
message( STATUS "Downloading ecbuild version \"${ATLAS4PY_ECBUILD_VERSION}\" to ${ecbuild_SOURCE_DIR}" )
FetchContent_Populate(
ecbuild
GIT_REPOSITORY https://github.com/ecmwf/ecbuild.git
GIT_TAG ${ATLAS4PY_ECBUILD_VERSION}
SOURCE_DIR ${ecbuild_SOURCE_DIR}
QUIET
)
FetchContent_MakeAvailable(ecbuild)
set( ecbuild_ROOT ${ecbuild_SOURCE_DIR} CACHE INTERNAL "Found ecbuild" )
endif()
find_package(eckit)
if( eckit_FOUND )
message( "Found eckit: ${eckit_DIR} (found version \"${eckit_VERSION}\")" )

if (NOT build_eckit)
find_package(eckit CONFIG QUIET)
if( eckit_FOUND )
message( STATUS "Found eckit: ${eckit_DIR} (found version \"${eckit_VERSION}\")" )
if (NOT eckit_VERSION VERSION_EQUAL ATLAS4PY_ECKIT_VERSION)
message( WARNING "Found eckit version \"${eckit_VERSION}\", but configured version is \"${ATLAS4PY_ECKIT_VERSION}\"" )
endif()
else()
set(build_eckit TRUE CACHE INTERNAL "build eckit")
endif()
endif()
if (build_eckit)
message( STATUS "Downloading and building eckit version \"${ATLAS4PY_ECKIT_VERSION}\"" )

if(NOT eckit_FOUND)
# Disable unused features for faster compilation
set(ECKIT_ENABLE_TESTS OFF)
set(ECKIT_ENABLE_DOCS OFF)
set(ECKIT_ENABLE_PKGCONFIG OFF)
set(ECKIT_ENABLE_ECKIT_GEO OFF)
set(ECKIT_ENABLE_ECKIT_SQL OFF)
set(ECKIT_ENABLE_ECKIT_CMD OFF)
FetchContent_Declare(
eckit
GIT_REPOSITORY https://github.com/ecmwf/eckit.git
GIT_TAG ${ATLAS4PY_ECKIT_VERSION}
)
FetchContent_MakeAvailable(eckit)
set(_atlas4py_built_eckit ON)
set( eckit_ROOT ${eckit_BINARY_DIR} CACHE INTERNAL "Found eckit" )
endif()

message( STATUS "Downloading and building atlas version \"${ATLAS4PY_ATLAS_VERSION}\"" )

# Disable unused features for faster compilation
set(ATLAS_ENABLE_TESTS OFF)
set(ATLAS_ENABLE_DOCS OFF)
set(ATLAS_ENABLE_PKGCONFIG OFF)
set(ECKIT_ENABLE_ECKIT_GEO OFF)
set(ECKIT_ENABLE_ECKIT_SQL OFF)
set(ATLAS_ENABLE_ECKIT_CMD OFF)
FetchContent_Declare(
atlas
GIT_REPOSITORY https://github.com/ecmwf/atlas.git
GIT_TAG ${ATLAS4PY_ATLAS_VERSION}
)
set( ENABLE_GRIDTOOLS_STORAGE OFF CACHE BOOL "" FORCE )
FetchContent_MakeAvailable(atlas)
endif()

find_package(pybind11)
### Find pybind11

message( STATUS "${PROJECT_NAME}: find_package(pybind11 CONFIG)..." )
find_package(pybind11 CONFIG)
if (NOT pybind11_FOUND)
message( FATAL_ERROR "pybind11 not found. Please install pybind11 or use pip to install this package." )
endif()

### RPATH handling

include(GNUInstallDirs) # defines CMAKE_INSTALL_LIBDIR
if(APPLE)
set(rpath_origin_install_libdir "@loader_path/${CMAKE_INSTALL_LIBDIR}")
else()
set(rpath_origin_install_libdir "$ORIGIN/${CMAKE_INSTALL_LIBDIR}")
endif()
set( CMAKE_INSTALL_RPATH "${rpath_origin_install_libdir}" ) # A semicolon-separated list specifying the RPATH to use in installed targets
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) # add the automatic parts to RPATH which point to dirs outside build tree
set( CMAKE_SKIP_BUILD_RPATH FALSE ) # use RPATHs for the build tree
set( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE ) # build with *relative* rpaths by default

### Python bindings module atlas4py

pybind11_add_module(_atlas4py _atlas4py.cpp)
target_link_libraries(_atlas4py PUBLIC atlas)
install(TARGETS _atlas4py DESTINATION .)
set_target_properties(_atlas4py PROPERTIES INSTALL_RPATH "${rpath_origin_install_libdir}")
target_compile_definitions(_atlas4py PRIVATE ATLAS4PY_VERSION_STRING="${PROJECT_VERSION_FULL}")

### Installation

install(TARGETS _atlas4py DESTINATION .)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION .
FILES_MATCHING PATTERN "*.py"
Expand Down
2 changes: 1 addition & 1 deletion src/atlas4py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import atexit

from ._version import __version__
from ._atlas4py import __version__
from ._atlas4py import *

_atlas4py._initialise()
Expand Down
Loading
Loading