-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"cci.20210423": | ||
url: "https://codeload.github.com/lava/matplotlib-cpp/zip/ef0383f1315d32e0156335e10b82e90b334f6d9f" | ||
sha256: "d061c56d53cc2355e1543198a3899a361495f5c8a72b938204a5307614ca883f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.files import copy, get | ||
from conan.tools.layout import basic_layout | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class MatplotlibCppConan(ConanFile): | ||
name = "matplotlib-cpp" | ||
description = "Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/lava/matplotlib-cpp" | ||
|
||
topics = ("plotting", "matplotlib", "visualization") | ||
package_type = "header-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 11 | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def package_id(self): | ||
self.info.clear() | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def package(self): | ||
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||
copy(self, "matplotlibcpp.h", self.source_folder, os.path.join(self.package_folder, "include")) | ||
|
||
def package_info(self): | ||
# https://github.com/lava/matplotlib-cpp/blob/master/cmake/matplotlib_cppConfig.cmake.in | ||
self.cpp_info.set_property("cmake_file_name", "matplotlib_cpp") | ||
self.cpp_info.set_property("cmake_target_name", "matplotlib_cpp::matplotlib_cpp") | ||
|
||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(matplotlib_cpp REQUIRED CONFIG) | ||
find_package(Python3 COMPONENTS Interpreter Development REQUIRED) | ||
find_package(Python3 COMPONENTS NumPy) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE matplotlib_cpp::matplotlib_cpp) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE | ||
Python3::Python | ||
Python3::Module | ||
) | ||
if(Python3_NumPy_FOUND) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE | ||
Python3::NumPy | ||
) | ||
else() | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE WITHOUT_NUMPY) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
try: | ||
import matplotlib | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") | ||
except ImportError: | ||
self.output.warning("matplotlib not found, skipping test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <matplotlibcpp.h> | ||
|
||
#include <cmath> | ||
#include <vector> | ||
|
||
namespace plt = matplotlibcpp; | ||
|
||
int main() | ||
{ | ||
// u and v are respectively the x and y components of the arrows we're plotting | ||
std::vector<int> x, y, u, v; | ||
for (int i = -5; i <= 5; i++) { | ||
for (int j = -5; j <= 5; j++) { | ||
x.push_back(i); | ||
u.push_back(-i); | ||
y.push_back(j); | ||
v.push_back(-j); | ||
} | ||
} | ||
plt::quiver(x, y, u, v); | ||
plt::save("test.png"); | ||
|
||
// The interpreter segfaults if it is not shut down explicitly | ||
// https://github.com/lava/matplotlib-cpp/issues/248 | ||
plt::detail::_interpreter::kill(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20210423": | ||
folder: all |