Skip to content

Commit

Permalink
(#4032) [cnpy-1.0] upload lib
Browse files Browse the repository at this point in the history
* create cnpy package

* change python indention

* Update recipes/cnpy/all/test_package/CMakeLists.txt

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Update recipes/cnpy/all/test_package/conanfile.py

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Update recipes/cnpy/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/cnpy/all/conanfile.py

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Update recipes/cnpy/all/conanfile.py

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Update recipes/cnpy/all/conanfile.py

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Update recipes/cnpy/all/conanfile.py

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Fix package version

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Fix Windows build

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Export all symbols

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* cnpy: Update Conan conventions

Automatically created by bincrafters-conventions 0.30.1

* fix windows problem

* Update recipes/cnpy/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* update example test

* add new line

* update remove exampletest

* update remove exampletest

* Update recipes/cnpy/all/test_package/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Update recipes/cnpy/all/test_package/example1.cpp

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* windows

* update

* Update recipes/cnpy/all/conanfile.py

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: bincrafters-user <bincrafters@gmail.com>
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
  • Loading branch information
5 people authored Jan 5, 2021
1 parent 27954d6 commit 93a325c
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 0 deletions.
9 changes: 9 additions & 0 deletions recipes/cnpy/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.4)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

add_subdirectory("source_subfolder")
8 changes: 8 additions & 0 deletions recipes/cnpy/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
"cci.20180601":
url: "https://github.com/rogersce/cnpy/archive/4e8810b1a8637695171ed346ce68f6984e585ef4.tar.gz"
sha256: "5120abc54a564efa92c642cc0199cc4fd3f345901157de9fbbdcedbb34d28d8a"
patches:
"cci.20180601":
- patch_file: "patches/0001-exclude-example.patch"
base_path: "source_subfolder"
73 changes: 73 additions & 0 deletions recipes/cnpy/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import os
import glob

from conans import ConanFile, CMake, tools

class CnpyConan(ConanFile):
name = "cnpy"
description = "library to read/write .npy and .npz files in C/C++"
license = "MIT"
topics = ("conan", "cnpy")
homepage = "https://github.com/hongyx11/cnpy"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = ["CMakeLists.txt", "patches/*"]
generators = "cmake", "cmake_find_package"
settings = "os", "arch", "compiler", "build_type"
_cmake = None

options = {
"shared": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": False,
"fPIC": True
}

@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

def requirements(self):
self.requires("zlib/1.2.11")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob.glob(self.name + "-*")[0]
os.rename(extracted_dir, self._source_subfolder)

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
cmake.build()

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "cnpy"
self.cpp_info.names["cmake_find_package_multi"] = "cnpy"
self.cpp_info.libs = ["cnpy"]
37 changes: 37 additions & 0 deletions recipes/cnpy/all/patches/0001-exclude-example.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9eb550f..d57c6dd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,26 +5,17 @@ endif(COMMAND cmake_policy)

project(CNPY)

-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-
-option(ENABLE_STATIC "Build static (.a) library" ON)
-
find_package(ZLIB REQUIRED)

include_directories(${ZLIB_INCLUDE_DIRS})

-add_library(cnpy SHARED "cnpy.cpp")
+add_library(cnpy "cnpy.cpp")
target_link_libraries(cnpy ${ZLIB_LIBRARIES})
-install(TARGETS "cnpy" LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-
-if(ENABLE_STATIC)
- add_library(cnpy-static STATIC "cnpy.cpp")
- set_target_properties(cnpy-static PROPERTIES OUTPUT_NAME "cnpy")
- install(TARGETS "cnpy-static" ARCHIVE DESTINATION lib)
-endif(ENABLE_STATIC)
+set_property(TARGET cnpy PROPERTY CXX_STANDARD 11)
+install(TARGETS "cnpy"
+ LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin)

install(FILES "cnpy.h" DESTINATION include)
-install(FILES "mat2npz" "npy2mat" "npz2mat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

-add_executable(example1 example1.cpp)
-target_link_libraries(example1 cnpy)
8 changes: 8 additions & 0 deletions recipes/cnpy/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1.0)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(${PROJECT_NAME} example1.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
17 changes: 17 additions & 0 deletions recipes/cnpy/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(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", "test_package")
self.run(bin_path, run_environment=True)
15 changes: 15 additions & 0 deletions recipes/cnpy/all/test_package/example1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <cstdlib>
#include<vector>
#include"cnpy.h"

int main() {
const size_t Nx = 16;
const size_t Ny = 16;
const size_t Nz = 16;

std::vector<double> data(Nx*Ny*Nz);
for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = rand();
cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w");
cnpy::NpyArray arr = cnpy::npy_load("arr1.npy");
return 0;
}
3 changes: 3 additions & 0 deletions recipes/cnpy/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20180601":
folder: all

0 comments on commit 93a325c

Please sign in to comment.