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
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,32 @@ It also allows *reading* .npy files, although only a very limited subset of data
- floating point
- complex floating point (std::complex<float>, ...)

## Usage
libnpy is a header only library. You only need to download `npy.hpp` into your include path. Neither special compiler flags nor a specific build system are required.
## Installation
libnpy is a header-only library. You only need to download `npy.hpp` into your include path and `#include "npy.hpp"`. Neither special compiler flags nor a specific build system are required.


### (Optional) Meson subproject
For projects using meson as build system, libnpy can be readily included as a subproject.

Optional: If you use meson, you can use the provided `meson.build` file to declare the dependency on libnpy.
After cloning or unpacking libnpy into the `subprojects` folder, the dependency can be declared in the `meson.build` file as
```
libnpy_subproj = subproject('libnpy')
libnpy_dep = libnpy_subproj.get_variable('libnpy_dep')
```

The API has changed in the last release. The old C-style API is still available, but might get removed in the future.
### (Optional) System-wide installation
libnpy can also be installed system-wide. This requires the meson build system. From within the sources call
```
meson setup builddir
cd builddir
meson install
```
This will copy the `npy.hpp` into `include/libnpy/` relative to your install prefix (/usr/local/ by default) and generate and install a matching `libnpy.pc`.

The required include path can then be obtained with `pkg-config -cflags libnpy`.

## Usage
The API has changed in the 1.0 release. The old C-style API is still available, but might get removed in the future.

### Reading data:
```c++
Expand Down
14 changes: 14 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ project('libnpy',
license : 'MIT'
)

# Allow system-wide installation
libnpy_subdir = 'libnpy'
libnpy_headers = ['include/npy.hpp']
install_headers(libnpy_headers, subdir : libnpy_subdir)

# Allow auto-configuration with pkg-config
pkg = import('pkgconfig')
pkg.generate(
name : meson.project_name(),
subdirs : [libnpy_subdir],
description : 'A lightweight library for reading and writing NumPy-compatible .npy files',
)

# Make this library usable as a Meson subproject
libnpy_dep = declare_dependency(
include_directories : include_directories('include')
)