Skip to content

Commit 34ecce0

Browse files
committed
rgb-lib-python is here
0 parents  commit 34ecce0

File tree

9 files changed

+124
-0
lines changed

9 files changed

+124
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**/__pycache__
2+
/dist/
3+
/poetry.lock
4+
/rgb_lib/_rgb_lib/librgblibffi.so
5+
/rgb_lib/_rgb_lib/rgb_lib.py

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "rgb-lib"]
2+
path = rgb-lib
3+
url = https://github.com/RGB-Tools/rgb-lib.git

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 RGB-Tools developers
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# RGB Lib Python bindings
2+
3+
This project builds a Python library, `rgb-lib`, for the [rgb-lib]
4+
Rust library, which is included as a git submodule. The bindings are created by
5+
the [rgb-lib-ffi] project, which is located inside the rgb-lib submodule.
6+
7+
## Install from PyPI
8+
9+
Install the [latest release] by running:
10+
```shell
11+
pip install rgb-lib
12+
```
13+
14+
## Install locally
15+
16+
### Requirements
17+
- [cargo]
18+
- [poetry]
19+
20+
In order to install the project locally, run:
21+
```shell
22+
# Update the submodule
23+
git submodule update --init
24+
25+
# Generate the bindings
26+
./generate.sh
27+
28+
# Build the source and wheels archives
29+
poetry build
30+
31+
# Install the wheel
32+
pip install ./dist/rgb_lib-<version>-py3-none-any.whl
33+
34+
# or install the sdist
35+
pip install ./dist/rgb-lib-<version>.tar.gz
36+
```
37+
38+
39+
[cargo]: https://github.com/rust-lang/cargo
40+
[rgb-lib]: https://github.com/RGB-Tools/rgb-lib
41+
[rgb-lib-ffi]: https://github.com/RGB-Tools/rgb-lib/tree/master/rgb-lib-ffi
42+
[latest release]: https://pypi.org/project/rgb-lib/
43+
[poetry]: https://github.com/python-poetry/poetry

generate.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
6+
PY_SRC="${SCRIPT_DIR}/rgb_lib/_rgb_lib/"
7+
8+
RGBLIBFFI_PATH="./rgb-lib/rgb-lib-ffi"
9+
MANIFEST_PATH=(--manifest-path "$RGBLIBFFI_PATH/Cargo.toml")
10+
11+
echo "Generating librgblibffi.so..."
12+
cargo build "${MANIFEST_PATH[@]}"
13+
cp "$RGBLIBFFI_PATH/target/debug/librgblibffi.so" "$PY_SRC/"
14+
15+
echo "Generating rgb_lib.py..."
16+
RGBFFI_BINDGEN_OUTPUT_DIR="$PY_SRC" cargo run "${MANIFEST_PATH[@]}" \
17+
--package rgb-lib-ffi-bindgen -- \
18+
--language python --udl-file $RGBLIBFFI_PATH/src/rgb-lib.udl

pyproject.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[tool.poetry]
2+
name = 'rgb-lib'
3+
version = '0.0.1'
4+
description = 'RGB Lib Python language bindings.'
5+
license = 'MIT'
6+
authors = ['Zoe Faltibà <zoefaltiba@gmail.com>', 'Nicola Busanello <nicola.busanello@gmail.com>']
7+
readme = 'README.md'
8+
homepage = 'https://github.com/RGB-Tools/rgb-lib-python'
9+
repository = 'https://github.com/RGB-Tools/rgb-lib-python'
10+
documentation = 'https://github.com/RGB-Tools/rgb-lib-python'
11+
keywords = ['rgb', 'bitcoin']
12+
classifiers = [
13+
'Development Status :: 4 - Beta',
14+
'Intended Audience :: Developers',
15+
'Natural Language :: English',
16+
'Operating System :: MacOS',
17+
'Operating System :: POSIX :: Linux',
18+
'Programming Language :: Python :: 3.9',
19+
'Programming Language :: Python :: 3.10',
20+
'Topic :: Other/Nonlisted Topic',
21+
]
22+
include = ["rgb_lib/_rgb_lib/*"]
23+
24+
[tool.poetry.dependencies]
25+
python = "^3.9.0"
26+
27+
[build-system]
28+
requires = ["poetry-core>=1.0.0"]
29+
build-backend = "poetry.core.masonry.api"

rgb-lib

Submodule rgb-lib added at 14a0f50

rgb_lib/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""RGB Lib package."""
2+
3+
from ._rgb_lib.rgb_lib import *

rgb_lib/_rgb_lib/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Private package containing generated files."""

0 commit comments

Comments
 (0)