Skip to content

Commit

Permalink
Update pyevt and add pysdk Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
harrywong committed Jul 4, 2018
1 parent 72763e8 commit 9ec8988
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ cmake-build-debug/
cmake-build-release/
diff/

bind/pyevt/build
bind/pyevt/dist
bind/pyevt/pyevt.egg-info

sdks/pysdk/build
sdks/pysdk/dist
sdks/pysdk/pysdk.egg-info
11 changes: 4 additions & 7 deletions Docker/pyevt/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM everitoken/builder:latest as builder
ARG branch=master

RUN git clone -b $branch https://github.com/everitoken/evt.git --recursive \
RUN git clone -b $branch https://github.com/everitoken/evt.git \
&& cd evt && echo "$branch:$(git rev-parse HEAD)" > /etc/evt-version \
&& cmake -H. -B"/tmp/build" -G"Ninja" -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/tmp/build -DSecp256k1_ROOT_DIR=/usr/local -DENABLE_BIND_LIBRARIES=ON
Expand All @@ -15,12 +15,9 @@ RUN pip3 install cffi wheel

WORKDIR /pyevt
COPY --from=builder /usr/local/lib/*.so* /usr/local/lib/
COPY --from=builder /tmp/build/lib/libevt.so lib/
COPY --from=builder /tmp/build/lib/libfc_lite.so lib/
COPY --from=builder /tmp/build/lib/libevt_chain_lite.so lib/
COPY --from=builder /evt/bind/pyevt/pyevt/* ./
COPY --from=builder /evt/bind/pyevt ./

ENV LD_LIBRARY_PATH /pyevt/lib:/usr/local/lib
ENV LD_LIBRARY_PATH /usr/local/lib
ENV PATH /usr/sbin:/usr/bin:/sbin:/bin

ENTRYPOINT ["python3", "/pyevt/unit_test.py"]
ENTRYPOINT ["python3", "/pyevt/pyevt/unit_test.py"]
24 changes: 24 additions & 0 deletions Docker/pysdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM everitoken/pyevt:latest as pyevt

RUN git clone -b $branch https://github.com/everitoken/evt.git
RUN python /pyevt/setup.py bdist_wheel


FROM ubuntu:18.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive && apt-get install -y python3 python3-pip openssl libssl1.1 && rm -rf /var/lib/apt/lists/*
RUN pip3 install cffi wheel

WORKDIR /pysdk

COPY --from=pyevt /pyevt/dist/*.whl ./
RUN pip install *.whl
RUN del -y *.whl

COPY --from=pyevt /usr/local/lib/*.so* /usr/local/lib/
COPY --from=pyevt /evt/sdks/pysdk ./

ENV LD_LIBRARY_PATH /usr/local/lib
ENV PATH /usr/sbin:/usr/bin:/sbin:/bin

ENTRYPOINT ["python3", "/pysdk/pysdk/unit_test.py"]
9 changes: 8 additions & 1 deletion bind/pyevt/pyevt/libevt.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from cffi import FFI

import evt_exception
Expand Down Expand Up @@ -78,5 +80,10 @@ def init_lib():
int evt_ref_block_num(evt_block_id_t* block_id, uint16_t* ref_block_num);
int evt_ref_block_prefix(evt_block_id_t* block_id, uint32_t* ref_block_prefix);
""")
LibEVT.lib = LibEVT.ffi.dlopen('./lib/libevt.so')

if "LIBEVT_PATH" in os.environ:
LibEVT.lib = LibEVT.ffi.dlopen(os.environ["LIBEVT_PATH"] + '/libevt.so')
else:
LibEVT.lib = LibEVT.ffi.dlopen('libevt.so')

LibEVT.abi = LibEVT.lib.evt_abi()
2 changes: 1 addition & 1 deletion bind/pyevt/pyevt/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest

import abi
from ecc import *
from abi import *
from ecc import *


class TestPyEVT(unittest.TestCase):
Expand Down
3 changes: 0 additions & 3 deletions bind/pyevt/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
license="MIT",
url="https://github.com/everitoken/evt/tree/master/bind/pyevt",
packages=find_packages(),
package_data={
'': ['*.so']
},
install_requires=['cffi'],
classifiers=[
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit 9ec8988

Please sign in to comment.