Skip to content

Commit

Permalink
Merge branch 'release/v20180729'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Apr 25, 2019
2 parents 4f4d946 + 00522d6 commit 587f6f7
Show file tree
Hide file tree
Showing 74 changed files with 3,486 additions and 2,282 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
venv/
.git/
.buildozer/
.pytest_cache/
.tox/
bin/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.swp
*.pyc
*.pyo
venv/
bin/
.buildozer/
Expand Down
43 changes: 12 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
dist: trusty
sudo: required

language: generic

before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
# before_script:
# - "export DISPLAY=:99.0"
# - "sh -e /etc/init.d/xvfb start"
# - sleep 3 # give xvfb some time to start

before_install:
# Required by Buildozer Android
# https://buildozer.readthedocs.io/en/latest/installation.html#android-on-ubuntu-12-04-64bit
- sudo apt-get update -q
- sudo apt-get install build-essential ccache git lib32z1 lib32bz2-1.0 libncurses5:i386 libstdc++6:i386 python2.7 python2.7-dev openjdk-7-jdk unzip zlib1g-dev zlib1g:i386
# Required by Kivy
# https://kivy.org/docs/installation/installation-linux.html#dependencies-with-sdl2
- sudo apt-get install python-pip build-essential git python-dev
- sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev
# Optional dependency for the cut and multitouch support
- sudo apt-get install xclip libmtdev1
# Required for the project
- sudo apt-get install libzbar-dev

install:
- sudo pip install coveralls
services:
- docker

env:
global:
- COVERALLS_PARALLEL=true
matrix:
- SCRIPT_COMMAND="./travis/script_linux.sh"
- SCRIPT_COMMAND="./travis/script_android.sh"
- TAG=pywallet-linux DOCKERFILE=dockerfiles/Dockerfile-linux COMMAND='make test'
- TAG=pywallet-android DOCKERFILE=dockerfiles/Dockerfile-android COMMAND='buildozer android debug'

script:
# runs in parallel
- (eval "$SCRIPT_COMMAND")
install:
- docker build --tag=$TAG --file=$DOCKERFILE .

after_success:
- coveralls
script:
- travis_wait docker run $TAG $COMMAND
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
VENV_NAME=venv
ACTIVATE_PATH=$(VENV_NAME)/bin/activate
PIP=`. $(ACTIVATE_PATH); which pip`
TOX=`which tox`
GARDEN=`. $(ACTIVATE_PATH); which garden`
PYTHON=$(VENV_NAME)/bin/python
SYSTEM_DEPENDENCIES=virtualenv build-essential libpython2.7-dev \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \
cmake python-numpy tox wget curl libssl-dev libzbar-dev \
xclip xsel
OS=$(shell lsb_release -si)
OPENCV_VERSION=2.4.13.6
OPENCV_BASENAME=opencv-$(OPENCV_VERSION)
OPENCV_BUILD=$(OPENCV_BASENAME)/build/lib/cv2.so
OPENCV_DEPLOY=$(VENV_NAME)/lib/python2.7/site-packages/cv2.so
NPROC=`grep -c '^processor' /proc/cpuinfo`


all: system_dependencies opencv virtualenv

virtualenv:
test -d venv || virtualenv -p python2 venv
. venv/bin/activate
$(PIP) install Cython==0.26.1
$(PIP) install -r requirements/requirements.txt
$(GARDEN) install qrcode
$(GARDEN) install xcamera

system_dependencies:
ifeq ($(OS), Ubuntu)
sudo apt install --yes --no-install-recommends $(SYSTEM_DEPENDENCIES)
endif

$(OPENCV_BUILD):
curl --location https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).tar.gz \
--progress-bar --output $(OPENCV_BASENAME).tar.gz
tar -xf $(OPENCV_BASENAME).tar.gz
cmake \
-D BUILD_DOCS=OFF -D BUILD_PACKAGE=OFF -D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF -D BUILD_opencv_apps=OFF \
-D BUILD_opencv_nonfree=OFF -D BUILD_opencv_stitching=OFF \
-D BUILD_opencv_superres=OFF -D BUILD_opencv_ts=OFF \
-D BUILD_WITH_DEBUG_INFO=OFF -D WITH_1394=OFF -D WITH_CUDA=OFF \
-D WITH_CUFFT=OFF -D WITH_GIGEAPI=OFF -D WITH_JASPER=OFF \
-D WITH_OPENEXR=OFF -D WITH_PVAPI=OFF -D WITH_GTK=OFF \
-D BUILD_opencv_python=ON -B$(OPENCV_BASENAME)/build -H$(OPENCV_BASENAME)
cmake --build $(OPENCV_BASENAME)/build -- -j$(NPROC)

opencv_build: $(OPENCV_BUILD)

$(OPENCV_DEPLOY): opencv_build virtualenv
cp $(OPENCV_BUILD) $(OPENCV_DEPLOY)

opencv: $(OPENCV_DEPLOY)

clean:
rm -rf $(VENV_NAME) .tox/ $(OPENCV_BASENAME)

test:
$(TOX)
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![Join the chat at https://gitter.im/PyWallet/Lobby](https://badges.gitter.im/PyWallet/Lobby.svg)](https://gitter.im/PyWallet/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://secure.travis-ci.org/AndreMiras/PyWallet.png?branch=develop)](http://travis-ci.org/AndreMiras/PyWallet)
[![Coverage Status](https://coveralls.io/repos/github/AndreMiras/PyWallet/badge.svg?branch=develop)](https://coveralls.io/github/AndreMiras/PyWallet?branch=develop)

<a href="https://play.google.com/store/apps/details?id=com.github.andremiras.pywallet"><img src="https://cdn.rawgit.com/steverichey/google-play-badge-svg/master/img/en_get.svg" alt="Play Store" width="20%"></a>

Expand Down
24 changes: 15 additions & 9 deletions buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package.name = pywallet
package.domain = com.github.andremiras

# (str) Source code where the main.py live
source.dir = src/
source.dir = src

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas,md
Expand Down Expand Up @@ -48,27 +48,32 @@ requirements =
ethash,
scrypt,
bitcoin,
rlp,
rlp==0.6.0,
repoze.lru,
PyYAML,
https://github.com/ethereum/pyethereum/archive/0ae64823d1bccba9c8148adb462060cb83c08f06.zip,
https://github.com/ethereum/pydevp2p/archive/cc68f6d69fa88ffaac6f8483392c37eb9f19d712.zip,
https://github.com/ethereum/pyethereum/archive/2e53bf3.zip,
devp2p==0.9.3,
coincurve==7.1.0,
gevent,
pbkdf2,
https://github.com/ethereum/pyethapp/archive/409331e88a397ce5276c430aff4a8866d413e45d.zip,
https://gitlab.com/kivymd/KivyMD/repository/archive.zip?ref=e81c02afbca915a4d71c85d3486f6710b53df2c1,
requests,
eth-hash==0.1.1,
pyelliptic==1.5.7,
cffi,
secp256k1,
cffi==1.11.5,
libsecp256k1==355a38f,
asn1crypto==0.24.0,
coincurve==7.1.0,
qrcode,
contextlib2,
raven,
libiconv,
libzbar,
zbar,
pil,
https://github.com/AndreMiras/garden.zbarcam/archive/20171102.zip
https://github.com/AndreMiras/garden.zbarcam/archive/20171220.zip
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
Expand Down Expand Up @@ -186,6 +191,7 @@ android.blacklist_src = blacklist.txt
# (str) python-for-android branch to use, defaults to master
#p4a.branch = stable
p4a.branch = master
# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
Expand Down Expand Up @@ -232,7 +238,7 @@ android.arch = armeabi-v7a
# (str) The directory in which python-for-android should look for your own build recipes (if any)
#p4a.local_recipes =
p4a.local_recipes = ./src/python-for-android/recipes/
p4a.local_recipes = %(source.dir)s/python-for-android/recipes/
# (str) Filename to the hook for p4a
#p4a.hook =
Expand All @@ -259,7 +265,7 @@ p4a.local_recipes = ./src/python-for-android/recipes/
[buildozer]
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2
log_level = 1
# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 1
Expand Down
66 changes: 66 additions & 0 deletions dockerfiles/Dockerfile-android
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Docker image for building Android APKs via buildozer
# Build with:
# docker build --tag=pywallet-android --file=dockerfiles/Dockerfile-android .
# Run with:
# docker run pywallet-android /bin/sh -c 'buildozer android debug'
# Or using the entry point shortcut:
# docker run pywallet-android 'buildozer android debug'
# Or for interactive shell:
# docker run -it --rm pywallet-android
FROM ubuntu:18.04

ENV USER="user"
ENV HOME_DIR="/home/${USER}"
ENV WORK_DIR="${HOME_DIR}" \
PATH="${HOME_DIR}/.local/bin:${PATH}"
ENV DOCKERFILES_VERSION="master" \
DOCKERFILES_URL="https://raw.githubusercontent.com/AndreMiras/dockerfiles"
ENV MAKEFILES_URL="${DOCKERFILES_URL}/${DOCKERFILES_VERSION}/buildozer_android_new"
# currently needed because buildozer still uses `tools/android` binary
# even though we have the new `tools/bin/sdkmanager` available
ENV USE_SDK_WRAPPER=true


# configure locale
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
locales && \
locale-gen en_US.UTF-8
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"

# install system dependencies (required to setup all the tools)
RUN apt update -qq > /dev/null && apt install -qq --yes --no-install-recommends \
make curl ca-certificates xz-utils unzip openjdk-8-jdk sudo python-pip \
python-setuptools

# install build dependencies (required to successfully build the project)
# TODO: should this go to a Makefile instead so it can be shared/reused?
RUN apt install -qq --yes --no-install-recommends \
file autoconf automake libtool gettext pkg-config libltdl-dev

# prepare non root env
RUN useradd --create-home --shell /bin/bash ${USER}
# with sudo access and no password
RUN usermod -append --groups sudo ${USER}
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER ${USER}
WORKDIR ${WORK_DIR}

# downloads and installs Android SDK
# makes sure to have an up to date build-tools version to workaround buildozer bug, see:
# https://github.com/kivy/buildozer/commit/83ad94d#r29065648
RUN curl --location --progress-bar ${MAKEFILES_URL}/android_sdk.mk --output android_sdk.mk
RUN make -f android_sdk.mk

# install buildozer and dependencies
RUN curl --location --progress-bar ${MAKEFILES_URL}/buildozer.mk --output buildozer.mk
RUN make -f buildozer.mk

# links SDK to where buildozer is expecting to see it
RUN mkdir -p ${HOME}/.buildozer/android/platform
RUN ln -sfn ${HOME}/.android ${HOME}/.buildozer/android/platform/android-sdk-20

COPY . ${WORK_DIR}
ENTRYPOINT ["./dockerfiles/start.sh"]
35 changes: 35 additions & 0 deletions dockerfiles/Dockerfile-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Docker image for installing dependencies on Linux and running tests.
# Build with:
# docker build --tag=pywallet-linux --file=dockerfiles/Dockerfile-linux .
# Run with:
# docker run pywallet-linux /bin/sh -c 'make test'
# Or using the entry point shortcut:
# docker run pywallet-linux 'make test'
# Or for interactive shell:
# docker run -it --rm pywallet-linux
# TODO:
# - delete archives to keep small the container small
# - setup caching (for apt, and pip)
FROM ubuntu:18.04

# configure locale
RUN apt update -qq > /dev/null && apt install --yes --no-install-recommends \
locales && \
locale-gen en_US.UTF-8
ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8"

# install system dependencies
RUN apt update -qq > /dev/null && apt install --yes --no-install-recommends \
make lsb-release sudo

# install kivy system dependencies
# https://kivy.org/docs/installation/installation-linux.html#dependencies-with-sdl2
RUN apt install --yes --no-install-recommends \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev

WORKDIR /app
COPY . /app
RUN make
ENTRYPOINT ["./dockerfiles/start.sh"]
10 changes: 10 additions & 0 deletions dockerfiles/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

# if a some command has been passed to container, executes it and exit,
# otherwise runs bash
if [[ $@ ]]; then
eval $@
else
/bin/bash
fi
19 changes: 19 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Frequently Asked Questions


## Why another Ethereum wallet?
Back in 2016, I wanted to use an open source Android wallet with access to my private keys.
I waited until early 2017 before I decided to create one.

## Why in Python?
Because it's fun and I like it.

## Is it safe to use?
It always depends. If your device is not full of malware and if your passphrase is strong enought, then yes it's safe.
Since the private key is stored on device and not in some thirdparty service, you're responsible for keeping it safe.


## Decentralized?
There're different level of decentralization.
PyWallet is only a light Ethereum client that stores private keys (encrypted) on device.
But PyWallet doesn't keep track of the blockchain ledger.
27 changes: 7 additions & 20 deletions docs/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,15 @@
Project and dependencies are different depending on the host and target platform.

## Ubuntu host & target
To run the project on Ubuntu, you first need to install system dependencies. See Kivy guide: https://kivy.org/docs/installation/installation-linux.html.

Then install project dependencies using pip (in a virtualenv).
```
pip install --install-option="--no-cython-compile" $(grep Cython requirements/requirements.txt)
pip install -r requirements/test_requirements.txt
pip install -r requirements.txt
```
Cython needs to be installed explicitly because it's not in any sub-dependency `setup.py` `install_requires`.
You also need to install garden requirements:
```sh
make
```
garden install qrcode
garden install xcamera
```

Installing `test_requirements.txt` is only required if you want to contribute and run tests.
This `Makefile` installs (`apt`) [system dependencies](https://kivy.org/docs/installation/installation-linux.html),
[compiles OpenCV](/docs/OpenCV.md), `pip` and `garden` dependencies. Python dependencies are installed in a virtualenv.

You can also take a look at [script_linux.sh](/travis/script_linux.sh) to see how it's being automated for Travis.
You can also install `test_requirements.txt` if you want to contribute and run tests.

### Linux Camera support (optional)
See [OpenCV.md](/docs/OpenCV.md).
You also need to have previously installed `garden.xcamera` as it's a `garden.zbarcam` requirement.
You can also take a look at [.travis.yml](.travis.yml) and [dockerfiles/Dockerfile-linux](dockerfiles/Dockerfile-linux) to see how it's being automated in continuous integration testing.

## Ubuntu host, Android target
To be able to build the project for Android from Ubuntu, follow python-for-android official guide (for core dependencies):
Expand All @@ -34,7 +21,7 @@ Before installing additional dependencies.
```
sudo apt install zlib1g-dev default-jdk
```
Check [script_android.sh](/travis/script_android.sh) or [Dockerfile](https://github.com/AndreMiras/PyWallet/blob/feature/ticket37_travis_docker/Dockerfile) to see two different ways to do it in Travis.
Check [.travis.yml](.travis.yml) or [dockerfiles/Dockerfile-android](dockerfiles/Dockerfile-android) to see Travis automated build in Docker.

## Gentoo 64 host, Android target
Build zlib in 32-bit:
Expand Down
1 change: 1 addition & 0 deletions docs/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ git flow release finish
Push everything, make sure tags are also pushed:
```
git push
git push origin master:master
git push --tags
```

Expand Down
Loading

0 comments on commit 587f6f7

Please sign in to comment.