Skip to content

new package: netcdf 4.7.4 #2060

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

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 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
4 changes: 4 additions & 0 deletions recipes/netcdf/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"4.7.4":
url: "https://github.com/Unidata/netcdf-c/archive/v4.7.4.tar.gz"
sha256: "99930ad7b3c4c1a8e8831fb061cb02b2170fc8e5ccaeda733bd99c3b9d31666b"
121 changes: 121 additions & 0 deletions recipes/netcdf/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import os
import glob
from conans import ConanFile, AutoToolsBuildEnvironment, tools


class NetcdfConan(ConanFile):
name = "netcdf"
description = ("NetCDF is a set of software libraries and "
"self-describing, machine-independent data "
"formats that support the creation, access, "
"and sharing of array-oriented scientific data.")
license = "BSD-3-Clause"
homepage = "https://www.unidata.ucar.edu/software/netcdf/"
url = "https://github.com/conan-io/conan-center-index"
topics = ("array", "dataset", "scientific")

settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_netcdf4": [True, False],
"with_dap": [True, False],
"with_utilities": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_netcdf4": True,
"with_dap": True,
"with_utilities": True,
}
_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def requirements(self):
if self.options.with_netcdf4:
self.requires("hdf5/1.12.0")
if self.options.with_dap:
self.requires("libcurl/7.70.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "netcdf-c-{}".format(self.version)
os.rename(extracted_dir, self._source_subfolder)

def _configure_autotools(self):
if not self._autotools:
args = [
"--prefix={}".format(self.package_folder),
]

if self.options.shared:
args.append("--enable-shared")
args.append("--disable-static")
else:
args.append("--disable-shared")
args.append("--enable-static")

if self.options.with_netcdf4:
args.append("--enable-netcdf4")
else:
args.append("--disable-netcdf4")

if self.options.with_dap:
args.append("--enable-dap")
else:
args.append("--disable-dap")

if self.options.with_utilities:
args.append("--enable-utilities")
else:
args.append("--disable-utilities")

if self.options.get_safe("fPIC"):
args.append('--with-pic')

self._autotools = AutoToolsBuildEnvironment(self)
self._autotools.configure(self._source_subfolder, args=args)
return self._autotools

def build(self):
autotools = self._configure_autotools()
autotools.make()

def package(self):
self.copy("COPYRIGHT", dst="licenses", src=self._source_subfolder)

autotools = self._configure_autotools()
autotools.install()

tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
for filename in glob.glob(
os.path.join(self.package_folder, "lib", "*.la")):
os.remove(filename)
for filename in glob.glob(
os.path.join(self.package_folder, "lib", "*.settings")):
os.remove(filename)
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.libs = ["netcdf"]
bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH env var with : {}".format(bin_path))
self.env_info.PATH.append(bin_path)
10 changes: 10 additions & 0 deletions recipes/netcdf/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
project (netcdf_example)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_executable(example
${CMAKE_SOURCE_DIR}/example.c
)
target_link_libraries(example CONAN_PKG::netcdf)
17 changes: 17 additions & 0 deletions recipes/netcdf/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class NetcdfTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "example")
self.run(bin_path, run_environment=True)
12 changes: 12 additions & 0 deletions recipes/netcdf/all/test_package/example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This is part of Unidata's netCDF package. Copyright 2018.
This is a test program for the nc-config utility. */
#include <netcdf.h>
#include <stdio.h>

int
main()
{
printf("NetCDF version: %s\n", nc_inq_libvers());
printf("*** SUCCESS!\n");
return 0;
}
3 changes: 3 additions & 0 deletions recipes/netcdf/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"4.7.4":
folder: all